Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Visual Studio Code (actually code-server) on Android
  1. Install Termux, an Android terminal emulator that provides a Linux execution environment and various tools.

  2. Update system packages in Termux:

    $ pkg update -y
  3. Install dependencies, including python, nodejs, and yarn:

    $ pkg install -y python nodejs yarn git
  4. Install code-server, an adaptation of Visual Studio Code that runs as a web app using the following command. The installation may take a while:

    $ yarn global add code-server
  5. Before starting code-server, we are going to fix an error caused by spdlog, which is a dependency of Visual Studio Code. First, change your working directory to ~/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules/spdlog/:

    $ cd ~/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules/spdlog/
  6. You will need a text editor for the next step. Here Vim is used for this task, but you are free to use whatever text editor you love:

    $ pkg install vim
  7. Open binding.gyp and enter edit mode. You can do this by pressing i once you open the file using Vim:

    $ vim binding.gyp
  8. Add "libraries": [ "-latomic" ] below "target_name": "spdlog",. This helps spdlog compile on Android.

    "targets": [{
            "target_name": "spdlog",
    +       "libraries": [ "-latomic" ],
            "sources": [
                    "src/main.cc",
                    "src/logger.cc"
            ],
  9. Save the file and quit text editor. You can do this by pressing ESC and then wq in Vim:

  10. Recompile spdlog using the following command:

    $ npm install
  11. (Optional) To see if spdlog works, run:

    $ npm test
  12. To fix the file search function of code-server, install ripgrep via pkg and link it to the correct place:

    $ pkg install ripgrep -y
    $ cd ~/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules/vscode-ripgrep/bin
    $ ln -s $(which rg) .
  13. Finally, change the working directory back to home and start code-server with the following command:

    $ cd ~
    $ code-server --auth none --disable-telemetry
  14. Now, you can open your browser and visit code-server at http://localhost:8080.

  15. (Bonus) If you wish to visit this code-server from another device in the same local network, you can expose the HTTP service to all network interfaces by starting code-server with --bind-addr:

    $ code-server --bind-addr 0.0.0.0:8080 --disable-telemetry

    You can find the password under ~/.config/code-server/config.yaml:

    $ cat ~/.config/code-server/config.yaml

    You may also need to enable HTTPS to enable clipboard and others features of Visual Studio Code in browsers. To do this, install openssl-tool and let code-server generate a certificate on startup:

    $ pkg install openssl-tool
    $ code-server --bind-addr 0.0.0.0:8080 --cert --disable-telemetry

    You can get the public IP address of your device using the command below in Termux:

    $ ifconfig
@shivahuh1
Copy link

shivahuh1 commented Sep 22, 2021

Screenshot_20210922-225614

Why is this happening to me?

@9yaskhan
Copy link

9yaskhan commented Sep 26, 2021

Screenshot_20210922-225614

Why is this happening to me?

Run this👇
yarn config set ignore-engines true

@unbhopper
Copy link

unbhopper commented Oct 11, 2021

Screenshot_20210922-225614
Why is this happening to me?

Run this👇 yarn config set ignore-engines true

This not working. Command pkg install nodejs setup version 16.x, but VS code need 14.x. That fixes by
pkg remove nodejs
pkg install nodejs-lts

@unbhopper
Copy link

unbhopper commented Oct 11, 2021

but i cant download any extension

@Gunloverit
Copy link

Gunloverit commented Oct 11, 2021

Op

@Gunloverit
Copy link

Gunloverit commented Oct 11, 2021

Op

@Anonymous2716
Copy link

Anonymous2716 commented Jan 26, 2022

Installing nodejs-lts didn't fix the issue that it needs v14.

@errr-maxx
Copy link

errr-maxx commented Jan 26, 2022

Command to install code-server: FORCE_NODE_VERSION=17 yarn global add code-server

Replace 17 with your node.js major version

@FrassonReis
Copy link

FrassonReis commented Feb 18, 2022

"FORCE_NODE_VERSION=17 yarn global add code-server" this really force install but after open by command "code-server ." login page redirect to 404 error page. Anyboby knows how to fix this?

@Malith-Rukshan
Copy link

Malith-Rukshan commented Jun 3, 2022

Easy Method 😇

image

pkg install proot-distro

proot-distro install Ubuntu

proot-distro login Ubuntu

pkg update

pkg install wget

wget https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-arm64.tar.gz

tar -xvf code-server-4.4.0-linux-arm64.tar.gz

cd code-server-4.4.0-linux-arm64

cd bin

export PASSWORD="12345"

./code-server

Then open your browser minimizing the termux and search on the Google search bar
http://127.0.0.1:8080

@kalpeshmore1234
Copy link

kalpeshmore1234 commented Jun 11, 2022

Easy Method 😇

image

pkg install proot-distro

proot-distro install Ubuntu

proot-distro login Ubuntu

pkg update

pkg install wget

wget https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-arm64.tar.gz

tar -xvf code-server-4.4.0-linux-arm64.tar.gz

cd code-server-4.4.0-linux-arm64

cd bin

export PASSWORD="12345"

./code-server

Then open your browser minimizing the termux and search on the Google search bar http://127.0.0.1:8080

Can anyone confirm is this working or not.

@Anonymous2716
Copy link

Anonymous2716 commented Jun 11, 2022

Hello @kalpeshmore1234 . I tested few days ago and working flawlessly.

@kalpeshmore1234
Copy link

kalpeshmore1234 commented Jun 11, 2022

Hello @kalpeshmore1234 . I tested few days ago and working flawlessly.

Thank you for your confirmation.

@Adventuresofbot
Copy link

Adventuresofbot commented Jun 26, 2022

./code-server: 36: exec: /root/code-server-4.4.0-linux-arm64/lib/node: not found root@localhost:~/code-server-4.4.0-linux-arm64/bin#

Easy Method 😇

image

pkg install proot-distro

proot-distro install Ubuntu

proot-distro login Ubuntu

pkg update

pkg install wget

wget https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-arm64.tar.gz

tar -xvf code-server-4.4.0-linux-arm64.tar.gz

cd code-server-4.4.0-linux-arm64

cd bin

export PASSWORD="12345"

./code-server

Then open your browser minimizing the termux and search on the Google search bar http://127.0.0.1:8080

@Adventuresofbot
Copy link

Adventuresofbot commented Jun 26, 2022

Help

@Kingmir24
Copy link

Kingmir24 commented Jul 2, 2022

Screenshot_20220702-012019
I'm lost

@Kingmir24
Copy link

Kingmir24 commented Jul 2, 2022

Somebody help out pls... I have been on it for the past 2 days now... I feel like I'm a fool

@Anonymous2716
Copy link

Anonymous2716 commented Jul 2, 2022

@Kingmir24 First cd into the code-server-4.4.0-linux-arm64 then CD into bin. view the directories with ls. And never call yourself fool. You just started learning.

@Kingmir24
Copy link

Kingmir24 commented Jul 2, 2022

Thanks... I will really appreciate

@rpi-esp32
Copy link

rpi-esp32 commented Jul 4, 2022

./code-server: 36: exec: /root/code-server-4.4.0-linux-arm64/lib/node: not found root@localhost:~/code-server-4.4.0-linux-arm64/bin#

Encounter same error code as @Adventuresofbot, checked and confirmed node (an executable) is present in the /root/code-…/lib directory.

Any ideas??

@Anonymous2716
Copy link

Anonymous2716 commented Jul 4, 2022

Probably need node extension? BTW note that it won't work as fluent VScode but its just an IDE to write code.

@rpi-esp32
Copy link

rpi-esp32 commented Jul 5, 2022

Probably need node extension? BTW note that it won't work as fluent VScode but its just an IDE to write code.

@Anonymous2716 thanks for your suggestion. Checked with node -v and confirmed node v12.22.9 was already installed on Ubuntu and yet ./code-server produces the same error message …

Understood this version of VSC is not a full-blown version, yet still nice to have the IDE 👍.

@Jackie1430
Copy link

Jackie1430 commented Jul 28, 2022

Screenshot_20220728-125422_Termux

Code server version : v4.5.1-linux-arm64
Node version : v16.15.1
./code-server commend not working, need help 🥺

@iyadahmed
Copy link

iyadahmed commented Jul 29, 2022

note that ripgrep path changed somehow, not sure why but this is the path that worked for me, @vscode/ripgrep instead of vscode-ripgrep
cd ~/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules/@vscode/ripgrep/bin

@radaevm
Copy link

radaevm commented Aug 1, 2022

Another easy method 😜

termux-setup-storage

pkg install proot-distro (if it doesn't work, change the repository via termux-change-repo)

proot-distro install ubuntu

proot-distro login ubuntu

pkg update

curl -fsSL https://code-server.dev/install.sh | sh

code-server --auth none

Then open your browser minimizing the termux and search on the Google search bar
http://127.0.0.1:8080

This method install last version (4.5.1 at the moment)

To install extensions that are not available in the extensions menu (for example, copilot and copilot labs), you need to download the extension in the VSIX format link and install it in the code-server via Extensions: Install from VSIX in command palette

@radaevm
Copy link

radaevm commented Aug 12, 2022

this is an example in samsung dex mode

image

@Anonymous2716
Copy link

Anonymous2716 commented Aug 12, 2022

@radaevm awesome

@DNAMcKnight
Copy link

DNAMcKnight commented Aug 12, 2022

this is an example in samsung dex mode

image

Can you help me create a ssl certificate it doesn't work for me I get error RSA PRIVATE KEY not found from openssl output: error

@radaevm
Copy link

radaevm commented Aug 12, 2022

  1. Do you do pkg update after proot-distro login ubuntu?
  2. Try update system packages in Termux pkg update -y
  3. are you using termux version 118?
  4. Look this

@DNAMcKnight
Copy link

DNAMcKnight commented Aug 13, 2022

@radaevm step 1-3 are done and it still hasn't worked. I'm a noob but I'll try to make 4 work. Thanks, if you can explain in simple steps it would help me greatly if not then that's fine as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment