how to run VS code with the help of termux on Android? : r/termux

https://www.reddit.com/r/termux/comments/10ddnij/how_to_run_vs_code_with_the_help_of_termux_on/

how to run VS code with the help of termux on Android?

I’ve got to know about termux today and I was amazed to see how much you can do with it. So i tried to run VS code on my android phone after watching a tutorial but it didn’t worked, i got errors at some steps. I’ve watched more tutorials but none of them worked. I tried the help of chatgpt but it got more confusing. Can anyone provide me a guide to run VS code? Also my CPU is 32bit, is it even possible for me to run it?

u/FreeCash_DE avatar

FreeCash_DE

• Promoted Freecash is the best-kept secret in gaming! Play games, earn money, and turn them into gift cards. Start your earning journey now!

Thumbnail image: Freecash is the best-kept secret in gaming! Play games, earn money, and turn them into gift cards. Start your earning journey now!

freecash.com Sign Up

Sort by: lengors

Yes. Steps (assuming you have termux installed):

  1. Install termux-x11 application:
    1. Download the artifact in the page: https://github.com/termux/termux-x11/actions/runs/3681182476 (you need an account)
    2. Extract the files and install the apk in there
    3. In termux run the command: termux-setup-storage and give the requested permissions
    4. termux-change-repo'
    5. Now cd into storage. This folder will contain the same file structure you will find on your files app. Then cd into the folder to where you extracted the files. Install the .deb package with the command: pkg install <termux-x11 filename>.deb
    6. Go to the app settings of both termux and termux-x11 and give all the permissions to those two apps.
  2. Install proot and proot-distro and the given distro:
    1. pkg install proot proot-distro
    2. proot-distro install <your distro of choice> (you can list the available distros with: proot-distro list)
  3. Login into the proot distro, install xfce4 and, optionally, create a user:
    1. proot-distro login <your distro of choice> --shared-tmp
    2. apt install xfce4 xfce4-goodies sudo (this assumes debian-based with the apt package manager, but equivalent depending on your package manager)
    3. apt remove xfce4-power-manager-plugins (I’m not sure this is required for every distro, but some crash if you don’t do this)
    4. useradd -m <youruser> (optional)
    5. passwd <youruser> (optional but recommended if you did the previous step)
    6. add user to sudoers, in debian add the following line: <youruser> ALL=(ALL:ALL) ALL to the file: /etc/sudoers
  4. (Required only for Android 12+) Prevent crashing with signal 9 (you need adb and to connect your smartphone to your laptop, as well as enabling debug through usb):
    1. adb shell "/system/bin/device_config put activity_manager max_phantom_processes 2147483647"
    2. adb shell "/system/bin/device_config set_sync_disabled_for_tests persistent; /system/bin/device_config put activity_manager max_phantom_processes 2147483647" (optional, will prevent the setting from resetting to the default value of 32)
  5. Now, start termux, termux-x11 and initialize your XFCE4 session as such by running the following commands in termux:
    1. export XDG_RUNTIME_DIR=${TMPDIR}
    2. termux-x11 :0 & (this will open a new application on top of termux, go back to termux without closing it)
    3. proot-distro login <your distro of choice> --shared-tmp -- runuser -l <youruser> -c 'DISPLAY=:0 xfce4-session'
    4. now go back to the open termux-x11 app and voila, you have a working desktop environment
  6. Install vscode and run it:
    1. Now all you need to do is go to the vscode page, download the ARM32 version of vscode for linux and install it with: sudo dpkg -i <vscode_install_filename>.deb
    2. Finally, run it with: code --no-sandbox (big coincidence as people in the sub helped me yesterday with this step because, without the no sandbox option, it won’t run and I didn’t know that)
u/PavloPub avatar

PavloPub

Just in case, “proper” link to the latest companion package (aith APK) is https://github.com/termux/termux-x11/actions/workflows/debug_build.yml , there is no release version, as far as I can see

u/PavloPub avatar

PavloPub

• Edited 2y ago

don’t yet know if I’ve missed some step apart from those I intentionally skipped (like granting “all access” to my phone data, don’t configure “storage”, so my personal data is not overexposed, skipping unclear/unstable? shell-loader-nighly.apk), but when I’m on final stage with proot-distro login , I’m getting error “Failed to execute child process “dbus-launch” (No such file or directory)” as dbus-launch is indeed missing. If I install it by apt dbus-x11 it works. Maybe it has to do with my debloating –no-install-recommends for apt. Will retry.

u/PavloPub avatar

PavloPub

Also, just in case, one may need to run “apt update” once in the newly installed proot-distro ubuntu. so xfce etc can be located

u/PavloPub avatar

PavloPub

What’s also nice, is that if your phone does support wireless debugging, you may no longer need any PC to run adb shell. Just in install android-tools pkg in termux and then follow the comment below to connect from within termux) https://www.reddit.com/r/termux/comments/vx8vnb/comment/ifz7wpt/?utm_source=reddit&utm_medium=web2x&context=3 Anonymo2786

Yes it is possible. You have to install a distro first. Use proot-distro for it. And after you install the distro you have to setup GUI environment. After that download the vscodes arm32 deb package or the tar.gz archive . install the deb or unpack the tar.gz archive in a directory. There you will find code in a bin directory.

Now inside termux proot you won’t have sandboxed application like chromium or vscode . so you have to run it with this command:

code --no-sandbox --user-data-dir vscodeDataDirectory

if you are running with root (in proot) then you have to specify the –user-data-dir and point it to a directoey where vscode will store all its cache data and installed extensions. replace vscodeDataDirectory with yours. Tho the performance wont be great. But you can always try and there is a thing called code server .

More posts you may like

0:41 100

upvotes ·34

comments


r/termux

Termux vs using proot-distro 11

upvotes ·18

comments


r/termux

VSCode installation tutorial with Termux-x11 11

upvotes ·15

comments


r/termux

What do you use Termux for? 35

upvotes ·59

comments


r/termux

What are the coolest stuff you tried with termux? 36

upvotes ·54

comments


r/termux

how to start using termux? like what is the language for the codes, etc 2

upvotes ·5

comments


r/termux

ALTERNATIVES FOR TERMUX 14

comments


r/termux

Might Termux stop working in the future due to Android API restrictions? 35

upvotes ·15

comments


r/learnprogramming

Is there an app like vs code on android? 2

upvotes ·8

comments


r/termux

Installing Vscode on Mobile

r/termux - Installing Vscode on Mobile

24

upvotes ·37

comments


r/termux

Install f-droid vs github vs google playstore

r/termux - Install f-droid vs github vs google playstore

17

upvotes ·25

comments


r/termux

[UPDATE] Official VSCode Server (Setup & Tips)

r/termux - [UPDATE] Official VSCode Server (Setup & Tips)

Leave a comment

Design a site like this with WordPress.com
Get started