Skip to content

Commit bfff88d

Browse files
authored
revert: improve flag interpretation for install.sh (#9566)
1 parent 2dae600 commit bfff88d

File tree

3 files changed

+33
-171
lines changed

3 files changed

+33
-171
lines changed

.github/workflows/ci.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ jobs:
512512
test-e2e:
513513
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
514514
needs: changes
515-
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
515+
# if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
516+
if: false
516517
timeout-minutes: 20
517518
steps:
518519
- name: Checkout
@@ -691,7 +692,7 @@ jobs:
691692
- test-go-pg
692693
- test-go-race
693694
- test-js
694-
- test-e2e
695+
# - test-e2e
695696
- offlinedocs
696697
# Allow this job to run even if the needed jobs fail, are skipped or
697698
# cancelled.

docs/install/install.sh.md

+3-91
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,20 @@ and macOS.
44

55
To install, run:
66

7-
```shell
8-
# This will automatically use supported package managers when available
7+
```bash
98
curl -fsSL https://coder.com/install.sh | sh
109
```
1110

12-
To install without using a system package manager:
13-
14-
```shell
15-
curl -fsSL https://coder.com/install.sh | sh -s -- --method standalone
16-
```
17-
1811
You can preview what occurs during the install process:
1912

20-
```shell
13+
```bash
2114
curl -fsSL https://coder.com/install.sh | sh -s -- --dry-run
2215
```
2316

2417
You can modify the installation process by including flags. Run the help command
2518
for reference:
2619

27-
```shell
20+
```bash
2821
curl -fsSL https://coder.com/install.sh | sh -s -- --help
2922
```
3023

@@ -34,87 +27,6 @@ manually via `coder server` or as a system package.
3427
By default, the Coder server runs on `http://127.0.0.1:3000` and uses a
3528
[public tunnel](../admin/configure.md#tunnel) for workspace connections.
3629

37-
## `PATH` conflicts
38-
39-
It's possible to end up in situations where you have multiple `coder` binaries
40-
in your `PATH`, and your system may use a version that you don't intend. Your
41-
`PATH` is a variable that tells your shell where to look for programs to run.
42-
43-
You can check where all of the versions are by running `which -a coder`.
44-
45-
For example, a common conflict on macOS might be between a version installed by
46-
Homebrew, and a version installed manually to the /usr/local/bin directory.
47-
48-
```console
49-
$ which -a coder
50-
/usr/local/bin/coder
51-
/opt/homebrew/bin/coder
52-
```
53-
54-
Whichever binary comes first in this list will be used when running `coder`
55-
commands.
56-
57-
### Reordering your `PATH`
58-
59-
If you use bash or zsh, you can update your `PATH` like this:
60-
61-
```shell
62-
# You might want to add this line to the end of your ~/.bashrc or ~/.zshrc file!
63-
export PATH="/opt/homebrew/bin:$PATH"
64-
```
65-
66-
If you use fish, you can update your `PATH` like this:
67-
68-
```shell
69-
# You might want to add this line to the end of your ~/.config/fish/config.fish file!
70-
fish_add_path "/opt/homebrew/bin"
71-
```
72-
73-
> ℹ If you ran install.sh with a `--prefix` flag, you can replace
74-
> `/opt/homebrew` with whatever value you used there. Make sure to leave the
75-
> `/bin` at the end!
76-
77-
Now we can observe that the order has changed:
78-
79-
```console
80-
$ which -a coder
81-
/opt/homebrew/bin/coder
82-
/usr/local/bin/coder
83-
```
84-
85-
### Removing unneeded binaries
86-
87-
If you want to uninstall a version of `coder` that you installed with a package
88-
manager, you can run whichever one of these commands applies:
89-
90-
```shell
91-
# On macOS, with Homebrew installed
92-
brew uninstall coder
93-
```
94-
95-
```shell
96-
# On Debian/Ubuntu based systems
97-
sudo dpkg -r coder
98-
```
99-
100-
```shell
101-
# On Fedora/RHEL-like systems
102-
sudo rpm -e coder
103-
```
104-
105-
```shell
106-
# On Alpine
107-
sudo apk del coder
108-
```
109-
110-
If the conflicting binary is not installed by your system package manager, you
111-
can just delete it.
112-
113-
```shell
114-
# You might not need `sudo`, depending on the location
115-
sudo rm /usr/local/bin/coder
116-
```
117-
11830
## Next steps
11931

12032
- [Configuring Coder](../admin/configure.md)

install.sh

+27-78
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,18 @@ Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/bin/$STAND
104104
105105
EOF
106106

107-
CODER_COMMAND="$(command -v "$STANDALONE_BINARY_NAME")"
108-
109-
if [ ! "$CODER_COMMAND" ]; then
107+
if [ "$STANDALONE_INSTALL_PREFIX" != /usr/local ]; then
110108
cath <<EOF
111109
Extend your path to use Coder:
112-
113-
$ PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"
110+
PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"
114111
115112
EOF
116-
elif [ "$CODER_COMMAND" != "$STANDALONE_BINARY_LOCATION" ]; then
117-
echo_path_conflict "$CODER_COMMAND" "$STANDALONE_INSTALL_PREFIX"
118-
else
119-
cath <<EOF
120-
To run a Coder server:
121-
122-
$ $STANDALONE_BINARY_NAME server
123-
124-
To connect to a Coder deployment:
125-
126-
$ $STANDALONE_BINARY_NAME login <deployment url>
113+
fi
114+
cath <<EOF
115+
Run Coder:
116+
$STANDALONE_BINARY_NAME server
127117
128118
EOF
129-
fi
130119
}
131120

132121
echo_brew_postinstall() {
@@ -135,15 +124,8 @@ echo_brew_postinstall() {
135124
return
136125
fi
137126

138-
CODER_COMMAND="$(command -v "coder")"
139-
BREW_PREFIX="$(brew --prefix)"
140-
141-
if [ "$CODER_COMMAND" != "$BREW_PREFIX/bin/coder" ]; then
142-
echo_path_conflict "$CODER_COMMAND" "$BREW_PREFIX"
143-
fi
144-
145127
cath <<EOF
146-
Homebrew formula has been installed.
128+
brew formula has been installed.
147129
148130
To run a Coder server:
149131
@@ -175,6 +157,7 @@ To run a Coder server:
175157
# Or just run the server directly
176158
$ coder server
177159
160+
Default URL: http://127.0.0.1:3000
178161
Configuring Coder: https://coder.com/docs/v2/latest/admin/configure
179162
180163
To connect to a Coder deployment:
@@ -186,45 +169,28 @@ EOF
186169

187170
echo_dryrun_postinstall() {
188171
cath <<EOF
172+
189173
Dry-run complete.
190174
191175
To install Coder, re-run this script without the --dry-run flag.
192-
193-
EOF
194-
}
195-
196-
echo_path_conflict() {
197-
cath <<EOF
198-
There is another binary in your PATH that conflicts with the binary we've installed.
199-
200-
$1
201-
202-
This is likely because of an existing installation of Coder. See our documentation for suggests on how to resolve this.
203-
204-
https://coder.com/docs/v2/latest/install/install.sh#path-conflicts
205-
206176
EOF
207177
}
208178

209179
main() {
210180
TERRAFORM_VERSION="1.3.4"
211-
212181
if [ "${TRACE-}" ]; then
213182
set -x
214183
fi
215-
216184
unset \
217185
DRY_RUN \
218186
METHOD \
219187
OPTIONAL \
220188
ALL_FLAGS \
221189
RSH_ARGS \
222190
EDGE \
223-
RSH \
224-
WITH_TERRAFORM
191+
RSH
225192

226193
ALL_FLAGS=""
227-
228194
while [ "$#" -gt 0 ]; do
229195
case "$1" in
230196
-*)
@@ -279,7 +245,7 @@ main() {
279245
exit 0
280246
;;
281247
--with-terraform)
282-
WITH_TERRAFORM=1
248+
METHOD=with_terraform
283249
;;
284250
--)
285251
shift
@@ -309,29 +275,8 @@ main() {
309275
return
310276
fi
311277

312-
# These can be overridden for testing but shouldn't normally be used as it can
313-
# result in a broken coder.
314-
OS=${OS:-$(os)}
315-
ARCH=${ARCH:-$(arch)}
316-
TERRAFORM_ARCH=${TERRAFORM_ARCH:-$(terraform_arch)}
317-
318-
# We can't reasonably support installing specific versions of Coder through
319-
# Homebrew, so if we're on macOS and the `--version` flag was set, we should
320-
# "detect" standalone to be the appropriate installation method. This check
321-
# needs to occur before we set `VERSION` to a default of the latest release.
322-
if [ "$OS" = "darwin" ] && [ "${VERSION-}" ]; then
323-
METHOD=standalone
324-
fi
325-
326-
# If we've been provided a flag which is specific to the standalone installation
327-
# method, we should "detect" standalone to be the appropriate installation method.
328-
# This check needs to occur before we set these variables with defaults.
329-
if [ "${STANDALONE_INSTALL_PREFIX-}" ] || [ "${STANDALONE_BINARY_NAME-}" ]; then
330-
METHOD=standalone
331-
fi
332-
333278
METHOD="${METHOD-detect}"
334-
if [ "$METHOD" != detect ] && [ "$METHOD" != standalone ]; then
279+
if [ "$METHOD" != detect ] && [ "$METHOD" != with_terraform ] && [ "$METHOD" != standalone ]; then
335280
echoerr "Unknown install method \"$METHOD\""
336281
echoerr "Run with --help to see usage."
337282
exit 1
@@ -340,10 +285,15 @@ main() {
340285
# These are used by the various install_* functions that make use of GitHub
341286
# releases in order to download and unpack the right release.
342287
CACHE_DIR=$(echo_cache_dir)
343-
TERRAFORM_INSTALL_PREFIX=${TERRAFORM_INSTALL_PREFIX:-/usr/local}
344288
STANDALONE_INSTALL_PREFIX=${STANDALONE_INSTALL_PREFIX:-/usr/local}
289+
TERRAFORM_INSTALL_PREFIX=${TERRAFORM_INSTALL_PREFIX:-/usr/local}
345290
STANDALONE_BINARY_NAME=${STANDALONE_BINARY_NAME:-coder}
346291
VERSION=${VERSION:-$(echo_latest_version)}
292+
# These can be overridden for testing but shouldn't normally be used as it can
293+
# result in a broken coder.
294+
OS=${OS:-$(os)}
295+
ARCH=${ARCH:-$(arch)}
296+
TERRAFORM_ARCH=${TERRAFORM_ARCH:-$(terraform_arch)}
347297

348298
distro_name
349299

@@ -352,11 +302,6 @@ main() {
352302
echoh
353303
fi
354304

355-
# Start by installing Terraform, if requested
356-
if [ "${WITH_TERRAFORM-}" = 1 ]; then
357-
with_terraform
358-
fi
359-
360305
# Standalone installs by pulling pre-built releases from GitHub.
361306
if [ "$METHOD" = standalone ]; then
362307
if has_standalone; then
@@ -368,6 +313,10 @@ main() {
368313
exit 1
369314
fi
370315
fi
316+
if [ "$METHOD" = with_terraform ]; then
317+
# Install terraform then continue the script
318+
with_terraform
319+
fi
371320

372321
# DISTRO can be overridden for testing but shouldn't normally be used as it
373322
# can result in a broken coder.
@@ -480,7 +429,7 @@ with_terraform() {
480429
install_macos() {
481430
# If there is no `brew` binary available, just default to installing standalone
482431
if command_exists brew; then
483-
echoh "Installing coder with Homebrew from the coder/coder tap."
432+
echoh "Installing v$VERSION of the coder formula from coder/coder."
484433
echoh
485434

486435
sh_c brew install coder/coder/coder
@@ -556,16 +505,16 @@ install_standalone() {
556505
"$sh_c" unzip -d "$CACHE_DIR" -o "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.zip"
557506
fi
558507

559-
STANDALONE_BINARY_LOCATION="$STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME"
508+
COPY_LOCATION="$STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME"
560509

561510
# Remove the file if it already exists to
562511
# avoid https://github.com/coder/coder/issues/2086
563-
if [ -f "$STANDALONE_BINARY_LOCATION" ]; then
564-
"$sh_c" rm "$STANDALONE_BINARY_LOCATION"
512+
if [ -f "$COPY_LOCATION" ]; then
513+
"$sh_c" rm "$COPY_LOCATION"
565514
fi
566515

567516
# Copy the binary to the correct location.
568-
"$sh_c" cp "$CACHE_DIR/coder" "$STANDALONE_BINARY_LOCATION"
517+
"$sh_c" cp "$CACHE_DIR/coder" "$COPY_LOCATION"
569518

570519
echo_standalone_postinstall
571520
}

0 commit comments

Comments
 (0)