diff --git a/docs/install/install.sh.md b/docs/install/install.sh.md index 7b278676a9fae..ab23cec5731c6 100644 --- a/docs/install/install.sh.md +++ b/docs/install/install.sh.md @@ -27,6 +27,87 @@ manually via `coder server` or as a system package. By default, the Coder server runs on `http://127.0.0.1:3000` and uses a [public tunnel](../admin/configure.md#tunnel) for workspace connections. +## PATH conflicts + +It's possible to end up in situations where you have multiple `coder` binaries +in your `PATH`, and your system may use a version that you don't intend. Your +`PATH` is a variable that tells your shell where to look for programs to run. + +You can check where all of the versions are by running `which -a coder`. + +For example, a common conflict on macOS might be between a version installed by +Homebrew, and a version installed manually to the /usr/local/bin directory. + +```console +$ which -a coder +/usr/local/bin/coder +/opt/homebrew/bin/coder +``` + +Whichever binary comes first in this list will be used when running `coder` +commands. + +### Reordering your PATH + +If you use bash or zsh, you can update your `PATH` like this: + +```shell +# You might want to add this line to the end of your ~/.bashrc or ~/.zshrc file! +export PATH="/opt/homebrew/bin:$PATH" +``` + +If you use fish, you can update your `PATH` like this: + +```shell +# You might want to add this line to the end of your ~/.config/fish/config.fish file! +fish_add_path "/opt/homebrew/bin" +``` + +> ℹ If you ran install.sh with a `--prefix` flag, you can replace +> `/opt/homebrew` with whatever value you used there. Make sure to leave the +> `/bin` at the end! + +Now we can observe that the order has changed: + +```console +$ which -a coder +/opt/homebrew/bin/coder +/usr/local/bin/coder +``` + +### Removing unneeded binaries + +If you want to uninstall a version of `coder` that you installed with a package +manager, you can run whichever one of these commands applies: + +```shell +# On macOS, with Homebrew installed +brew uninstall coder +``` + +```shell +# On Debian/Ubuntu based systems +sudo dpkg -r coder +``` + +```shell +# On Fedora/RHEL-like systems +sudo rpm -e coder +``` + +```shell +# On Alpine +sudo apk del coder +``` + +If the conflicting binary is not installed by your system package manager, you +can just delete it. + +```shell +# You might not need `sudo`, depending on the location +sudo rm /usr/local/bin/coder +``` + ## Next steps - [Configuring Coder](../admin/configure.md) diff --git a/install.sh b/install.sh index 9831e0177545a..ba75e358f71c5 100755 --- a/install.sh +++ b/install.sh @@ -100,22 +100,35 @@ echo_standalone_postinstall() { cath < EOF + fi } echo_brew_postinstall() { @@ -124,9 +137,23 @@ echo_brew_postinstall() { return fi + BREW_PREFIX="$(brew --prefix)" + cath <((resolve, reject) => { const cp = spawn( - "sh", + path.join(__dirname, "../../install.sh"), [ - "-c", - [ - "curl", - "-L", - "https://coder.com/install.sh", - "|", - "sh", - "-s", - "--", - "--version", - version, - "--method", - "standalone", - "--prefix", - tempDir, - "--binary-name", - binaryName, - ].join(" "), + "--version", + version, + "--method", + "standalone", + "--prefix", + tempDir, + "--binary-name", + binaryName, ], { env: { ...process.env, XDG_CACHE_HOME: "/tmp/coder-e2e-cache", + TRACE: "1", // tells install.sh to `set -x`, helpful if something goes wrong }, }, ); // eslint-disable-next-line no-console -- Needed for debugging - cp.stderr.on("data", (data) => console.log(data.toString())); + cp.stderr.on("data", (data) => console.error(data.toString())); + // eslint-disable-next-line no-console -- Needed for debugging + cp.stdout.on("data", (data) => console.log(data.toString())); cp.on("close", (code) => { if (code === 0) { resolve(); } else { - reject(new Error("curl failed with code " + code)); + reject(new Error("install.sh failed with code " + code)); } }); });