Skip to content

Instantly share code, notes, and snippets.

@ppoffice
Last active February 27, 2025 15:58
Show Gist options
  • Save ppoffice/b9e88c9fd1daf882bc0e7f31221dda01 to your computer and use it in GitHub Desktop.
Save ppoffice/b9e88c9fd1daf882bc0e7f31221dda01 to your computer and use it in GitHub Desktop.
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
@Amrinder-S
Copy link

you really complicating things.
just do apt install code-server or pkg install code-server
and it would work out just fine.

@Amrinder-S this only works if you have TUR installed, which is not part of the official Termux repos

I guess it doesn't hurt to just install code-server with it and then get on with your day. (i ran into the same issue with node version and i got many flashbacks and nightmares from it. i rather not look back into it)

@jaimemrjm
Copy link

you really complicating things.

just do apt install code-server or pkg install code-server

and it would work out just fine.

Since the issue is still open, I suppose pkg install code-server means the Terminal in that vscode is broken.

@carlosdarkoficial
Copy link

Funcionando normalmente show
Só achei complicado as configurações

@AhmdHaris
Copy link

Screenshot_20240306-001348_Termux
error

@PillFall
Copy link

PillFall commented Mar 9, 2024

Screenshot_20240306-001348_Termux error

@AhmdHaris use nodejs-18 (or better code-server directly) from the TUR repo or ignore engine dependencies, early in this gist there is a command on how to install ignoring engine

Copy link

ghost commented Mar 9, 2024

We should all use something else other than vscode like Nano or Vim,
https://youtu.be/m8C0Cq9Uv9o?si=5qD0JGKFF3IhR-8C
I think vscode is bad sometimes, I used to love it and still, but something about its asynchronousity is flawed

@Aeryyychu
Copy link

Aeryyychu commented May 16, 2024

1000021728
hehelp im stockk
Screenshot_20240516_130301_Termux

@ff-redeem-code-2024
Copy link

😍😍

@ReeaoX
Copy link

ReeaoX commented Aug 15, 2024

1000021728 hehelp im stockk Screenshot_20240516_130301_Termux

Execute code-server command initially, Not that.

If you switch into the non-root user, Try them as sudo.

If that doesn't work, It's mean there no "code-server" file in /bin,
Text PATH="~/.local/bin:$PATH" into .bashrc files.

@Binvnhehe999
Copy link

I can't connect to the IP of the device where the code-server is installed, it says connection error

@PillFall
Copy link

I can't connect to the IP of the device where the code-server is installed, it says connection error

@Binvnhehe999 check if code-server to listening to all IPs connection, not only the localhost ones. Check if the port is exposed, I do not know how you are trying to connect or where, but check if the port is exposed outside of LAN to WAN, check also if your firewall rules are blocking inbound or outbound traffic through this port.

There are several ways for you to get a connection refused error, it all depends on how you configure your network.

To solve this issue you have to analyze and fix port forwarding, IP listening and/or firewall rules.

All of this is assuming code-server is up and running.

Here the docs for code-server https://coder.com/docs/code-server/guide

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