Skip to content

Commit d66ed43

Browse files
authored
Merge branch 'main' into renovate/minor-dependency-updates
2 parents bd0efe1 + dd29a82 commit d66ed43

File tree

13 files changed

+256
-126
lines changed

13 files changed

+256
-126
lines changed

ci/dev/watch.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,10 @@ class Watcher {
106106
plugin.stderr.on("data", (d) => process.stderr.write(d))
107107
}
108108

109-
let startingVscode = false
110-
let startedVscode = false
111109
onLine(vscode, (line, original) => {
112110
console.log("[vscode]", original)
113-
// Wait for watch-client since "Finished compilation" will appear multiple
114-
// times before the client starts building.
115-
if (!startingVscode && line.includes("Starting watch-client")) {
116-
startingVscode = true
117-
} else if (startingVscode && line.includes("Finished compilation")) {
118-
if (startedVscode) {
119-
restartServer()
120-
}
121-
startedVscode = true
111+
if (line.includes("Finished compilation")) {
112+
restartServer()
122113
}
123114
})
124115

ci/helm-chart/templates/NOTES.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "code-server.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
1616
echo http://$SERVICE_IP:{{ .Values.service.port }}
1717
{{- else if contains "ClusterIP" .Values.service.type }}
18-
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "code-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
1918
echo "Visit http://127.0.0.1:8080 to use your application"
20-
kubectl port-forward $POD_NAME 8080:80
19+
kubectl port-forward --namespace {{ .Release.Namespace }} service/{{ include "code-server.fullname" . }} 8080:http
2120
{{- end }}
2221

2322
Administrator credentials:

docs/CONTRIBUTING.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Development workflow](#development-workflow)
1010
- [Updates to VS Code](#updates-to-vs-code)
1111
- [Build](#build)
12+
- [Help](#help)
1213
- [Test](#test)
1314
- [Unit tests](#unit-tests)
1415
- [Script tests](#script-tests)
@@ -77,16 +78,23 @@ we'll guide you.
7778

7879
## Development workflow
7980

80-
```shell
81-
yarn
82-
yarn watch
83-
# Visit http://localhost:8080 once the build is completed.
84-
```
81+
The current development workflow is a bit tricky because we have this repo and we use our `cdr/vscode` fork inside it with [`yarn link`](https://classic.yarnpkg.com/lang/en/docs/cli/link/).
82+
83+
Here are these steps you should follow to get your dev environment setup:
8584

86-
`yarn watch` will live reload changes to the source.
85+
1. `git clone https://github.com/cdr/code-server.git` - Clone `code-server`
86+
2. `git clone https://github.com/cdr/vscode.git` - Clone `vscode`
87+
3. `cd vscode && git checkout code-server-v2` - checkout the branch we use (not the default)
88+
4. `cd vscode && yarn install` - install the dependencies in the `vscode` repo
89+
5. `cd code-server && yarn install` - install the dependencies in the `code-server` repo
90+
6. `cd vscode && yarn link` - use `yarn` to create a symlink to the `vscode` repo (`code-oss-dev` package)
91+
7. `cd code-server && yarn link code-oss-dev --modules-folder vendor/modules` - links your local `vscode` repo (`code-oss-dev` package) inside your local version of code-server
92+
8. `cd code-server && yarn watch` - this will spin up code-server on localhost:8080 which you can start developing. It will live reload changes to the source.
8793

8894
### Updates to VS Code
8995

96+
If changes are made and merged into `code-server-v2` in the `cdr/vscode` repo, then you'll need to update the version in the `code-server` repo by following these steps:
97+
9098
1. Update the package tag listed in `vendor/package.json`:
9199

92100
```json
@@ -97,7 +105,7 @@ yarn watch
97105
}
98106
```
99107

100-
2. From the code-server **project root**, run `yarn install`.
108+
1. From the code-server **project root**, run `yarn install`.
101109
Then, test code-server locally to make sure everything works.
102110
1. Check the Node.js version that's used by Electron (which is shipped with VS
103111
Code. If necessary, update your version of Node.js to match.
@@ -139,6 +147,10 @@ yarn package
139147
> If you need your builds to support older distros, run the build commands
140148
> inside a Docker container with all the build requirements installed.
141149
150+
### Help
151+
152+
If you get stuck or need help, you can always start a new GitHub Discussion [here](https://github.com/cdr/code-server/discussions). One of the maintainers will respond and help you out.
153+
142154
## Test
143155

144156
There are four kinds of tests in code-server:

docs/termux.md

Lines changed: 115 additions & 38 deletions
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`.

src/node/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ export async function readConfigFile(configPath?: string): Promise<ConfigArgs> {
606606
await fs.writeFile(configPath, defaultConfigFile(generatedPassword), {
607607
flag: "wx", // wx means to fail if the path exists.
608608
})
609-
logger.info(`Wrote default config file to ${humanPath(configPath)}`)
609+
logger.info(`Wrote default config file to ${humanPath(os.homedir(), configPath)}`)
610610
} catch (error: any) {
611611
// EEXIST is fine; we don't want to overwrite existing configurations.
612612
if (error.code !== "EEXIST") {

src/node/main.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { field, logger } from "@coder/logger"
2+
import * as os from "os"
23
import http from "http"
34
import path from "path"
45
import { Disposable } from "../common/emitter"
@@ -95,8 +96,8 @@ export const runCodeServer = async (
9596
): Promise<{ dispose: Disposable["dispose"]; server: http.Server }> => {
9697
logger.info(`code-server ${version} ${commit}`)
9798

98-
logger.info(`Using user-data-dir ${humanPath(args["user-data-dir"])}`)
99-
logger.trace(`Using extensions-dir ${humanPath(args["extensions-dir"])}`)
99+
logger.info(`Using user-data-dir ${humanPath(os.homedir(), args["user-data-dir"])}`)
100+
logger.trace(`Using extensions-dir ${humanPath(os.homedir(), args["extensions-dir"])}`)
100101

101102
if (args.auth === AuthType.Password && !args.password && !args["hashed-password"]) {
102103
throw new Error(
@@ -109,7 +110,7 @@ export const runCodeServer = async (
109110
const serverAddress = ensureAddress(app.server, protocol)
110111
const disposeRoutes = await register(app, args)
111112

112-
logger.info(`Using config file ${humanPath(args.config)}`)
113+
logger.info(`Using config file ${humanPath(os.homedir(), args.config)}`)
113114
logger.info(
114115
`${protocol.toUpperCase()} server listening on ${serverAddress.toString()} ${
115116
args.link ? "(randomized by --link)" : ""
@@ -123,14 +124,14 @@ export const runCodeServer = async (
123124
} else if (args.usingEnvHashedPassword) {
124125
logger.info(" - Using password from $HASHED_PASSWORD")
125126
} else {
126-
logger.info(` - Using password from ${humanPath(args.config)}`)
127+
logger.info(` - Using password from ${humanPath(os.homedir(), args.config)}`)
127128
}
128129
} else {
129130
logger.info(` - Authentication is disabled ${args.link ? "(disabled by --link)" : ""}`)
130131
}
131132

132133
if (args.cert) {
133-
logger.info(` - Using certificate for HTTPS: ${humanPath(args.cert.value)}`)
134+
logger.info(` - Using certificate for HTTPS: ${humanPath(os.homedir(), args.cert.value)}`)
134135
} else {
135136
logger.info(` - Not serving HTTPS ${args.link ? "(disabled by --link)" : ""}`)
136137
}

src/node/routes/index.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { HttpCode, HttpError } from "../../common/http"
1010
import { plural } from "../../common/util"
1111
import { App } from "../app"
1212
import { AuthType, DefaultedArgs } from "../cli"
13-
import { commit, isDevMode, rootPath } from "../constants"
13+
import { commit, rootPath } from "../constants"
1414
import { Heart } from "../heart"
1515
import { ensureAuthenticated, redirect } from "../http"
1616
import { PluginAPI } from "../plugin"
@@ -23,7 +23,7 @@ import * as login from "./login"
2323
import * as logout from "./logout"
2424
import * as pathProxy from "./pathProxy"
2525
import * as update from "./update"
26-
import { createVSServerRouter, VSServerResult } from "./vscode"
26+
import { CodeServerRouteWrapper } from "./vscode"
2727

2828
/**
2929
* Register all routes and middleware.
@@ -138,20 +138,12 @@ export const register = async (app: App, args: DefaultedArgs): Promise<Disposabl
138138

139139
app.router.use("/update", update.router)
140140

141-
let vscode: VSServerResult
142-
try {
143-
vscode = await createVSServerRouter(args)
144-
app.router.use("/", vscode.router)
145-
app.wsRouter.use("/", vscode.wsRouter.router)
146-
app.router.use("/vscode", vscode.router)
147-
app.wsRouter.use("/vscode", vscode.wsRouter.router)
148-
} catch (error: any) {
149-
if (isDevMode) {
150-
logger.warn(error)
151-
logger.warn("VS Server router may still be compiling.")
152-
} else {
153-
throw error
154-
}
141+
const vsServerRouteHandler = new CodeServerRouteWrapper()
142+
143+
// Note that the root route is replaced in Coder Enterprise by the plugin API.
144+
for (const routePrefix of ["/vscode", "/"]) {
145+
app.router.use(routePrefix, vsServerRouteHandler.router)
146+
app.wsRouter.use(routePrefix, vsServerRouteHandler.wsRouter)
155147
}
156148

157149
app.router.use(() => {
@@ -164,6 +156,6 @@ export const register = async (app: App, args: DefaultedArgs): Promise<Disposabl
164156
return () => {
165157
heart.dispose()
166158
pluginApi?.dispose()
167-
vscode?.codeServerMain.dispose()
159+
vsServerRouteHandler.dispose()
168160
}
169161
}

src/node/routes/login.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Router, Request } from "express"
22
import { promises as fs } from "fs"
33
import { RateLimiter as Limiter } from "limiter"
4+
import * as os from "os"
45
import * as path from "path"
56
import { rootPath } from "../constants"
67
import { authenticated, getCookieDomain, redirect, replaceTemplates } from "../http"
@@ -30,7 +31,7 @@ export class RateLimiter {
3031

3132
const getRoot = async (req: Request, error?: Error): Promise<string> => {
3233
const content = await fs.readFile(path.join(rootPath, "src/browser/pages/login.html"), "utf8")
33-
let passwordMsg = `Check the config file at ${humanPath(req.args.config)} for the password.`
34+
let passwordMsg = `Check the config file at ${humanPath(os.homedir(), req.args.config)} for the password.`
3435
if (req.args.usingEnvPassword) {
3536
passwordMsg = "Password was set from $PASSWORD."
3637
} else if (req.args.usingEnvHashedPassword) {

0 commit comments

Comments
 (0)