Skip to content

Commit 0de57fe

Browse files
arHSMjsjoeio
authored andcommitted
Fix : recreate the termux guide to adapt the recent changes (#4472)
* 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. * yarn-fmt and minor typos #4472 (comment) * Fix : replace unnecessary steps to be linked to a guide * Change from private gist to a section in Extra * Remove reference to non-existent step * ready to merge! Co-authored-by: Joe Previte <[email protected]>
1 parent 22231f4 commit 0de57fe

File tree

1 file changed

+115
-38
lines changed

1 file changed

+115
-38
lines changed

docs/termux.md

+115-38
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,144 @@
55
- [Install](#install)
66
- [Upgrade](#upgrade)
77
- [Known Issues](#known-issues)
8-
- [Search doesn't work](#search-doesnt-work)
9-
- [Backspace doesn't work](#backspace-doesnt-work)
8+
- [Git won't work in `/sdcard`](#git-wont-work-in-sdcard)
9+
- [Extra](#extra)
10+
- [Create a new user](#create-a-new-user)
11+
- [Install Go](#install-go)
12+
- [Install Python](#install-python)
1013

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

13-
Termux is a terminal application and Linux environment that you can also use to
14-
run code-server from your Android phone.
15-
1616
## Install
1717

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
18+
1. Get [Termux](https://f-droid.org/en/packages/com.termux/) from **F-Droid**.
19+
2. Install Debian by running the following.
20+
- Run `termux-setup-storage` to allow storage access, or else code-server won't be able to read from `/sdcard`.\
21+
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.
22+
> The following command was extracted from [Andronix](https://andronix.app/) you can also use [proot-distro](https://github.com/termux/proot-distro).
23+
> After Debian is installed the `~ $` will change to `root@localhost`.
24+
25+
```bash
26+
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
27+
```
28+
29+
3. Run the following commands to setup Debian.
30+
31+
```bash
32+
apt update
33+
apt upgrade -y
34+
apt-get install nano vim sudo curl wget git -y
35+
```
36+
37+
4. Install [NVM](https://github.com/nvm-sh/nvm) by following the install guide in the README, just a curl/wget command.
38+
5. 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;
39+
40+
- Copy the lines NVM asks you to run after running the install script.
41+
- Run `nano /root/.bashrc` and comment out those lines by adding a `#` at the start.
42+
- Run `nano /etc/profile` and paste those lines at the end and make sure to replace `$HOME` with `/root`
43+
- Now run `exit` and start Debain again.
44+
45+
6. 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`.
46+
7. To install `code-server` run the following.
47+
> To check the install process (Will not actually install code-server)
48+
> If it all looks good, you can install code-server by running the second command
49+
50+
```bash
51+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
52+
```
53+
54+
```bash
55+
curl -fsSL https://code-server.dev/install.sh | sh
56+
```
57+
58+
8. You can now start code server by simply running `code-server`.
59+
60+
> Consider using a new user instead of root, read [here](https://www.howtogeek.com/124950/htg-explains-why-you-shouldnt-log-into-your-linux-system-as-root/) why using root is not recommended.\
61+
> Learn how to add a user [here](#create-a-new-user).
2362
2463
## Upgrade
2564

26-
To upgrade run: `yarn global upgrade code-server --latest`
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`
2767

2868
## Known Issues
2969

30-
The following details known issues and suggested workarounds for using
31-
code-server with Termux.
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+
76+
1. Create a soft-link from the debian-fs to your folder in `/sdcard`
77+
2. Use git from termux (preferred)
78+
79+
## Extra
80+
81+
### Create a new user
82+
83+
To create a new user follow these simple steps -
84+
85+
1. Create a new user by running `useradd username -m`.
86+
2. Change the password by running `passwd username`.
87+
3. Give your new user sudo access by runnning `visudo`, scroll down to `User privilege specification` and add the following line after root `username ALL=(ALL:ALL) ALL`.
88+
4. Now edit the `/etc/passwd` file with your commadline editor of choice and at the end of the line that specifies your user change `/bin/sh` to `/bin/bash`.
89+
5. Now switch users, by running `su - username`
90+
91+
- Remember the `-` betweeen `su` and username is required to execute `/etc/profile`,\
92+
since `/etc/profile` may have some necessary things to be executed you should always add a `-`.
93+
94+
### Install Go
3295

33-
### Search doesn't work
96+
> From https://golang.org/doc/install
3497
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:
98+
1. Go to https://golang.org/dl/ and copy the download link for `linux arm` and run the following.
3799

38-
1. Install `ripgrep` with `pkg`
100+
```bash
101+
wget download_link
102+
```
39103

40-
```sh
41-
pkg install ripgrep
42-
```
104+
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)
43105

44-
1. Make a soft link using `ln -s`
106+
```bash
107+
rm -rf /usr/local/go && tar -C /usr/local -xzf archive_name
108+
```
45109

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-
```
110+
3. Run `nano /etc/profile` and add the following line `export PATH=$PATH:/usr/local/go/bin`.
111+
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.
112+
5. Check if your install was successful by running `go version`
50113

51-
### Backspace doesn't work
114+
### Install Python
52115

53-
When using Android's on-screen keyboard, the backspace key doesn't work
54-
properly. This is a known upstream issue:
116+
> Run these commands as root
55117
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)
118+
1. Run the following command to install required packages to build python.
58119

59-
There are two workarounds.
120+
```bash
121+
sudo apt-get update
122+
sudo apt-get install make build-essential libssl-dev zlib1g-dev \
123+
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
124+
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
125+
```
60126

61-
**Option 1:** Modify keyboard dispatch settings
127+
2. Install [pyenv](https://github.com/pyenv/pyenv/) from [pyenv-installer](https://github.com/pyenv/pyenv-installer) by running.
62128

63-
1. Open the Command Palette
64-
2. Search for **Preferences: Open Settings (JSON)**
65-
3. Add `"keyboard.dispatch": "keyCode"`
129+
```bash
130+
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
131+
```
66132

67-
The backspace button should work at this point.
133+
3. Run `nano /etc/profile` and add the following
68134

69-
_Thanks to @Nefomemes for the [suggestion](https://github.com/cdr/code-server/issues/1141#issuecomment-789463707)!_
135+
```bash
136+
export PYENV_ROOT="/root/.pyenv"
137+
export PATH="/root/.pyenv/bin:$PATH"
138+
eval "$(pyenv init --path)"
139+
eval "$(pyenv virtualenv-init -)"
140+
```
70141

71-
**Option 2:** Use a Bluetooth keyboard.
142+
4. Exit start Debian again.
143+
5. Run `pyenv versions` to list all installable versions.
144+
6. Run `pyenv install version` to install the desired python version.
145+
> The build process may take some time (an hour or 2 depending on your device).
146+
7. Run `touch /root/.pyenv/version && echo "your_version_here" > /root/.pyenv/version`
147+
8. (You may have to start Debian again) Run `python3 -V` to verify if PATH works or not.
148+
> If `python3` doesn't work but pyenv says that the install was successful in step 6 then try running `$PYENV_ROOT/versions/your_version/bin/python3`.

0 commit comments

Comments
 (0)