install.md 7.0 KB
Newer Older
1 2
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
A
Anmol Sethi 已提交
3 4
# Install

5
- [install.sh](#installsh)
A
Anmol Sethi 已提交
6
  - [Flags](#flags)
A
Anmol Sethi 已提交
7
  - [Detection Reference](#detection-reference)
8 9 10 11 12
- [Debian, Ubuntu](#debian-ubuntu)
- [Fedora, CentOS, RHEL, SUSE](#fedora-centos-rhel-suse)
- [Arch Linux](#arch-linux)
- [yarn, npm](#yarn-npm)
- [macOS](#macos)
13
- [Standalone Releases](#standalone-releases)
14 15 16 17
- [Docker](#docker)

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

A
Anmol Sethi 已提交
18 19 20
This document demonstrates how to install `code-server` on
various distros and operating systems.

A
Anmol Sethi 已提交
21 22
## install.sh

23
We have a [script](../install.sh) to install code-server for Linux, macOS and FreeBSD.
A
Anmol Sethi 已提交
24

A
Anmol Sethi 已提交
25
It tries to use the system package manager if possible.
A
Anmol Sethi 已提交
26 27 28 29

First run to print out the install process:

```bash
30
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
A
Anmol Sethi 已提交
31 32 33 34 35 36 37 38
```

Now to actually install:

```bash
curl -fsSL https://code-server.dev/install.sh | sh
```

A
Anmol Sethi 已提交
39 40
The script will print out how to run and start using code-server.

A
Anmol Sethi 已提交
41 42 43 44
If you believe an install script used with `curl | sh` is insecure, please give
[this wonderful blogpost](https://sandstorm.io/news/2015-09-24-is-curl-bash-insecure-pgp-verified-install) by
[sandstorm.io](https://sandstorm.io) a read.

A
Anmol Sethi 已提交
45
If you'd still prefer manual installation despite the below [detection reference](#detection-reference) and `--dry-run`
46
then continue on for docs on manual installation. The [`install.sh`](../install.sh) script runs the _exact_ same
A
Anmol Sethi 已提交
47 48 49 50 51
commands presented in the rest of this document.

### Flags

- `--dry-run` to echo the commands for the install process without running them.
A
Anmol Sethi 已提交
52
- `--method` to choose the installation method.
53 54 55
  - `--method=detect` to detect the package manager but fallback to `--method=standalone`.
  - `--method=standalone` to install a standalone release archive into `~/.local`.
- `--prefix=/usr/local` to install a standalone release archive system wide.
A
Anmol Sethi 已提交
56 57 58
- `--version=X.X.X` to install version `X.X.X` instead of latest.
- `--help` to see full usage docs.

A
Anmol Sethi 已提交
59
### Detection Reference
A
Anmol Sethi 已提交
60

A
Anmol Sethi 已提交
61 62
- For Debian, Ubuntu and Raspbian it will install the latest deb package.
- For Fedora, CentOS, RHEL and openSUSE it will install the latest rpm package.
A
Anmol Sethi 已提交
63
- For Arch Linux it will install the AUR package.
64
- For any unrecognized Linux operating system it will install the latest standalone release into `~/.local`.
65

A
Anmol Sethi 已提交
66
  - Add `~/.local/bin` to your `$PATH` to run code-server.
A
Anmol Sethi 已提交
67 68

- For macOS it will install the Homebrew package.
69

70
  - If Homebrew is not installed it will install the latest standalone release into `~/.local`.
A
Anmol Sethi 已提交
71
  - Add `~/.local/bin` to your `$PATH` to run code-server.
A
Anmol Sethi 已提交
72

73 74
- For FreeBSD, it will install the [npm package](#yarn-npm) with `yarn` or `npm`.

A
Anmol Sethi 已提交
75
- If ran on an architecture with no releases, it will install the [npm package](#yarn-npm) with `yarn` or `npm`.
76
  - We only have releases for amd64 and arm64 presently.
A
Anmol Sethi 已提交
77
  - The [npm package](#yarn-npm) builds the native modules on postinstall.
A
Anmol Sethi 已提交
78

A
Anmol Sethi 已提交
79 80 81
## Debian, Ubuntu

```bash
A
v3.6.0  
Anmol Sethi 已提交
82 83
curl -fOL https://github.com/cdr/code-server/releases/download/v3.6.0/code-server_3.6.0_amd64.deb
sudo dpkg -i code-server_3.6.0_amd64.deb
A
Anmol Sethi 已提交
84
sudo systemctl enable --now code-server@$USER
A
Anmol Sethi 已提交
85 86 87
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
```

88
## Fedora, CentOS, RHEL, SUSE
A
Anmol Sethi 已提交
89 90

```bash
A
v3.6.0  
Anmol Sethi 已提交
91 92
curl -fOL https://github.com/cdr/code-server/releases/download/v3.6.0/code-server-3.6.0-amd64.rpm
sudo rpm -i code-server-3.6.0-amd64.rpm
A
Anmol Sethi 已提交
93
sudo systemctl enable --now code-server@$USER
A
Anmol Sethi 已提交
94 95 96 97 98 99 100 101
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
```

## Arch Linux

```bash
# Installs code-server from the AUR using yay.
yay -S code-server
A
Anmol Sethi 已提交
102
sudo systemctl enable --now code-server@$USER
A
Anmol Sethi 已提交
103 104 105 106 107 108 109 110
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
```

```bash
# Installs code-server from the AUR with plain makepkg.
git clone https://aur.archlinux.org/code-server.git
cd code-server
makepkg -si
A
Anmol Sethi 已提交
111
sudo systemctl enable --now code-server@$USER
A
Anmol Sethi 已提交
112 113 114 115 116
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
```

## yarn, npm

A
Anmol Sethi 已提交
117
We recommend installing with `yarn` or `npm` when:
118

A
Anmol Sethi 已提交
119
1. You aren't on `amd64` or `arm64`.
A
v3.4.1  
Anmol Sethi 已提交
120
2. If you're on Linux with glibc < v2.17 or glibcxx < v3.4.18
A
Anmol Sethi 已提交
121 122

**note:** Installing via `yarn` or `npm` builds native modules on install and so requires C dependencies.
123
See [./npm.md](./npm.md) for installing these dependencies.
A
Anmol Sethi 已提交
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141

You will need at least node v12 installed. See [#1633](https://github.com/cdr/code-server/issues/1633).

```bash
yarn global add code-server
# Or: npm install -g code-server
code-server
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
```

## macOS

```bash
brew install code-server
brew services start code-server
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
```

142
## Standalone Releases
A
Anmol Sethi 已提交
143 144

We publish self contained `.tar.gz` archives for every release on [github](https://github.com/cdr/code-server/releases).
A
Anmol Sethi 已提交
145
They bundle the node binary and `node_modules`.
A
Anmol Sethi 已提交
146

A
Fix CI  
Anmol Sethi 已提交
147
These are created from the [npm package](#yarn-npm) and the rest of the releases are created from these.
A
v3.4.1  
Anmol Sethi 已提交
148
Only requirement is glibc >= 2.17 && glibcxx >= v3.4.18 on Linux and for macOS there is no minimum system requirement.
A
Fix CI  
Anmol Sethi 已提交
149

A
Anmol Sethi 已提交
150 151 152 153
1. Download the latest release archive for your system from [github](https://github.com/cdr/code-server/releases).
2. Unpack the release.
3. You can run code-server by executing `./bin/code-server`.

A
Anmol Sethi 已提交
154 155
You can add the code-server `bin` directory to your `$PATH` to easily execute `code-server`
without the full path every time.
A
Anmol Sethi 已提交
156

157
Here is an example script for installing and using a standalone `code-server` release on Linux:
A
Anmol Sethi 已提交
158 159

```bash
160
mkdir -p ~/.local/lib ~/.local/bin
A
v3.6.0  
Anmol Sethi 已提交
161
curl -fL https://github.com/cdr/code-server/releases/download/v3.6.0/code-server-3.6.0-linux-amd64.tar.gz \
162
  | tar -C ~/.local/lib -xz
A
v3.6.0  
Anmol Sethi 已提交
163 164
mv ~/.local/lib/code-server-3.6.0-linux-amd64 ~/.local/lib/code-server-3.6.0
ln -s ~/.local/lib/code-server-3.6.0/bin/code-server ~/.local/bin/code-server
165
PATH="~/.local/bin:$PATH"
A
Anmol Sethi 已提交
166 167 168
code-server
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
```
169 170 171

## Docker

A
Anmol Sethi 已提交
172 173 174 175 176
```bash
# This will start a code-server container and expose it at http://127.0.0.1:8080.
# It will also mount your current directory into the container as `/home/coder/project`
# and forward your UID/GID so that all file system operations occur as your user outside
# the container.
177 178 179 180 181
#
# Your $HOME/.config is mounted at $HOME/.config within the container to ensure you can
# easily access/modify your code-server config in $HOME/.config/code-server/config.json
# outside the container.
mkdir -p ~/.config
A
Anmol Sethi 已提交
182
docker run -it --name code-server -p 127.0.0.1:8080:8080 \
183
  -v "$HOME/.config:/home/coder/.config" \
A
Anmol Sethi 已提交
184 185
  -v "$PWD:/home/coder/project" \
  -u "$(id -u):$(id -g)" \
A
Anmol Sethi 已提交
186
  -e "DOCKER_USER=$USER" \
A
Anmol Sethi 已提交
187 188 189
  codercom/code-server:latest
```

190 191
Our official image supports `amd64` and `arm64`.

A
Anmol Sethi 已提交
192
For `arm32` support there is a popular community maintained alternative:
193 194

https://hub.docker.com/r/linuxserver/code-server