Skip to content

Commit 4d9fb66

Browse files
authored
Fix : recreate the termux guide to adapt the recent changes
Termux nodejs-lts changed from v14 to v16 and there are many issues people are facing such as with argon2. Hence I recommend changing it to this install process which is comparably better and has one less issue :^) I've also added some extra things such as installing GO and Python, idk about the TOC tree but this is pretty much it.
1 parent 94b2774 commit 4d9fb66

File tree

1 file changed

+112
-59
lines changed

1 file changed

+112
-59
lines changed

docs/termux.md

Lines changed: 112 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,115 @@
1010

1111
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1212

13-
Termux is a terminal application and Linux environment that you can also use to
14-
run code-server from your Android phone.
15-
16-
## Install
17-
18-
1. Install Termux from [F-Droid](https://f-droid.org/en/packages/com.termux/).
19-
1. Make sure it's up-to-date: `apt update && apt upgrade`
20-
1. Install required packages: `apt install build-essential python git nodejs-lts yarn`
21-
1. Install code-server: `yarn global add code-server`
22-
1. Run code-server: `code-server` and navigate to localhost:8080 in your browser
23-
24-
## Upgrade
25-
26-
To upgrade run: `yarn global upgrade code-server --latest`
27-
28-
## Known Issues
29-
30-
The following details known issues and suggested workarounds for using
31-
code-server with Termux.
32-
33-
### Search doesn't work
34-
35-
There is a known issue with search not working on Android because it's missing
36-
`bin/rg` ([context](https://github.com/cdr/code-server/issues/1730#issuecomment-721515979)). To fix this:
37-
38-
1. Install `ripgrep` with `pkg`
39-
40-
```sh
41-
pkg install ripgrep
42-
```
43-
44-
1. Make a soft link using `ln -s`
45-
46-
```sh
47-
# run this command inside the code-server directory
48-
ln -s $PREFIX/bin/rg ./vendor/modules/code-oss-dev/vscode-ripgrep/bin/rg
49-
```
50-
51-
### Backspace doesn't work
52-
53-
When using Android's on-screen keyboard, the backspace key doesn't work
54-
properly. This is a known upstream issue:
55-
56-
- [Issues with backspace in Codespaces on Android (Surface Duo)](https://github.com/microsoft/vscode/issues/107602)
57-
- [Support mobile platforms](https://github.com/xtermjs/xterm.js/issues/1101)
58-
59-
There are two workarounds.
60-
61-
**Option 1:** Modify keyboard dispatch settings
62-
63-
1. Open the Command Palette
64-
2. Search for **Preferences: Open Settings (JSON)**
65-
3. Add `"keyboard.dispatch": "keyCode"`
66-
67-
The backspace button should work at this point.
68-
69-
_Thanks to @Nefomemes for the [suggestion](https://github.com/cdr/code-server/issues/1141#issuecomment-789463707)!_
70-
71-
**Option 2:** Use a Bluetooth keyboard.
13+
### Install
14+
15+
1. Get [Termux](https://f-droid.org/en/packages/com.termux/) from **F-Droid**.
16+
2. Install Debian by running the following.
17+
- Also run `termux-setup-storage` to allow storage access or else code-server won't be able to read from `/sdcard/`.\
18+
If you used the Andronix command \\/ then you may have to edit the `start-debian.sh` script to mount `/sdcard` just as simple as uncommenting the `command+=" -b /sdcard"` line.
19+
> The following command was extracted from [Andronix](https://andronix.app/) you can also use [proot-distro](https://github.com/termux/proot-distro).
20+
```bash
21+
pkg update -y && pkg install wget curl proot tar -y && wget https://raw.githubusercontent.com/AndronixApp/AndronixOrigin/master/Installer/Debian/debian.sh -O debian.sh && chmod +x debian.sh && bash debian.sh
22+
```
23+
> After Debian is installed the `~ $` will change to `root@localhost`.
24+
3. Run the following commands to setup Debian.
25+
```bash
26+
apt update
27+
apt upgrade -y
28+
apt-get install nano vim sudo curl wget git -y
29+
```
30+
4. Then create a new user to use later and change its password.
31+
```bash
32+
useradd username -m
33+
passwd username
34+
```
35+
5. Install [NVM](https://github.com/nvm-sh/nvm) by following the install guide in the README, just a curl/wget command.
36+
6. Set up NVM for multi-user. After installing NVM it automatically adds the necessary commands for it to work but it will only work if you are logged in as root which we do not want (see step 9) so do the following things.
37+
- Copy the lines NVM asks you to run after running the install script.
38+
- Run `nano /root/.bashrc` and comment out those lines by adding a `#` at the start.
39+
- Run `nano /etc/profile` and paste those lines at the end and make sure to replace `$HOME` with `/root`
40+
- Now run `exit` and start Debain again.
41+
42+
7. After following the instructions and setting up NVM you can now install the [required node version](https://coder.com/docs/code-server/latest/npm#nodejs-version) using `nvm install version_here`.
43+
8. You don't need to install yarn.
44+
9. Now you are ready to install code server but first lets switch users.
45+
- There are many answers on Stack Exchange for why logging in as root is not recommended,\
46+
but heres a [short article](https://www.howtogeek.com/124950/htg-explains-why-you-shouldnt-log-into-your-linux-system-as-root/) for you.
47+
- Run the following `visudo` to give your user (created in step 4) sudo privileges.
48+
- After executing the command scroll to `User privilege specification` and add `username ALL=(ALL:ALL) ALL`.
49+
10. To switch users run `su - username`. **DO NOT forget to add the `-` between `su` and the username or else the `/etc/profile` file won't be executed,** you may instead follow step 6 but edit the `/etc/bash.bashrc` file intead of `/etc/profile` if you don't want to add a `-` between `su` and username.
50+
51+
11. To install `code-server` run the following.
52+
53+
To check the install process (Will not actually install code-server)
54+
```bash
55+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
56+
```
57+
Now if all looks good you can run to install code-server.
58+
```bash
59+
curl -fsSL https://code-server.dev/install.sh | sh
60+
```
61+
12. Now everytime you run `./start-debian.sh` (or `proot-distro login debian` if you used proot-distro) you can switch to your user `su - username` and run code-server.
62+
63+
### Upgrade
64+
65+
1. Remove all previous installs `rm -rf ~/.local/lib/code-server-*`
66+
2. Run the install script again `curl -fsSL https://code-server.dev/install.sh | sh`
67+
68+
### Known Issues
69+
70+
#### Git won't work in `/sdcard`
71+
72+
Issue : Using git in the `/sdcard` directory will fail during cloning/commit/staging/etc...\
73+
Fix : None\
74+
Potential Workaround :
75+
1. Create a soft-link from the debian-fs to your folder in `/sdcard`
76+
2. Use git from termux (preferred)
77+
78+
### Extra
79+
80+
#### Install GO
81+
82+
> From https://golang.org/doc/install
83+
84+
1. Go to https://golang.org/dl/ and copy the downloadlink for `linux arm` and run the following.
85+
```bash
86+
wget download_link
87+
```
88+
2. Extract the downloaded archive. (This step will erase all previous GO installs make sure to create a backup if you have previously installed GO)
89+
```bash
90+
rm -rf /usr/local/go && tar -C /usr/local -xzf archive_name
91+
```
92+
3. Run `nano /etc/profile` and add the following line `export PATH=$PATH:/usr/local/go/bin`.
93+
4. Now run `exit` (depending on if you have switched users or not you may have to run `exit` multiple times to get to normal termux shell) and start Debian again.
94+
5. Check if your install was successful by running `go version`
95+
96+
#### Install Python
97+
98+
> Run these commands as root
99+
100+
1. Run the following command to install required packages to build python.
101+
```bash
102+
sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
103+
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
104+
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
105+
```
106+
2. Install [pyenv](https://github.com/pyenv/pyenv/) from [pyenv-installer](https://github.com/pyenv/pyenv-installer) by running.
107+
```bash
108+
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
109+
```
110+
3. Run `nano /etc/profile` and add the following
111+
```bash
112+
export PYENV_ROOT="/root/.pyenv"
113+
export PATH="$HOME/.pyenv/bin:$PATH"
114+
eval "$(pyenv init --path)"
115+
eval "$(pyenv virtualenv-init -)"
116+
```
117+
4. Exit start Debian again.
118+
5. Run `pyenv versions` to list all installable versions.
119+
6. Run `pyenv install version` to install the desired python version.
120+
> The build process may take some time (an hour or 2 depending on your device).
121+
7. Run `touch /root/.pyenv/version && echo "your_version_here" > /root/.pyenv/version`
122+
8. (You may have to start Debian again) Run `python3 -V` to verify if PATH works or not.
123+
> If `python3` doesnt work but pyenv says thst the install was successfull in step 6 then try running `$PYENV_ROOT/versions/your_version/bin/python3`.
124+
9. You can now swith users by `su - username` and try runnning `python3 -V` and `pip -V` to check if it works or not.

0 commit comments

Comments
 (0)