Skip to content

fix(install): make install.sh run under any /bin/sh - #1037

Merged
codyde merged 2 commits into
masterfrom
fix/installer-posix-sh
Aug 3, 2026
Merged

fix(install): make install.sh run under any /bin/sh#1037
codyde merged 2 commits into
masterfrom
fix/installer-posix-sh

Conversation

@codyde

@codyde codyde commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

The published one-liner curl -fsSL agents.railway.com | sh fails on every Debian/Ubuntu host, where /bin/sh is dash:

✓ CLI — v5.30.3 · ~/.railway/bin
sh: 146: Bad substitution

Fixes #990 (bug 3). Same class as #319.

Why POSIX, not | bash — only 3 constructs were bash-only. Going POSIX keeps the published command unchanged, drops the bash dependency entirely, and fixes Alpine. Switching the wrapper to bash leaves every already-published copy of | sh broken.

Changes

  • shell_quote/fish_quote: 3 × ${var//…}replace_all helper
  • $RANDOM fallback aborts under dash + set -u$$
  • unpack(): flags=$(test -n) passed an empty quoted arg to tar. GNU tar ignores it; busybox tar reads it as a member name → tar: : not found in archive. Also makes -V verbose work for the first time.
  • setup agent failures no longer abort bare under set -e — the silent "exit 1" half of agents.railway.com install fails silently in several common cases (segfault, set -e + whoami, sh vs bash) #990. Reachable in practice: v4.5.3 exits 2 on setup agent, and the brew/sandbox branches deliberately continue with an old CLI.

The shell and tar bugs blocked Alpine independently; both fixed, so Alpine works now.

Verification

  • quoting helpers byte-identical to the bash originals (quote / backslash / glob / empty inputs) under dash, bash and busybox ash
  • full installs pass: ubuntu:24.04, debian:12-slim × sh/dash/bash; alpine:3.20 × sh/ash
  • new CI job lints install.sh + agents.sh as dash, then runs a real install under dash and under busybox ash

🤖 Generated with Claude Code

`curl -fsSL agents.railway.com | sh` fails on Debian/Ubuntu, where /bin/sh is
dash: `sh: 146: Bad substitution` (#990, also #319). agents.sh pipes install.sh
to `sh`, but install.sh used bash-only `${var//needle/repl}`.

Made the script POSIX rather than switching the wrapper to bash, so the
published one-liner keeps working verbatim and no bash is needed:

- Replace the three `${var//…}` expansions with a `replace_all` helper.
- Drop the `$RANDOM` fallback. Under dash + `set -u` it aborts with
  "RANDOM: parameter not set" whenever the /dev/urandom path yields empty.
- Fix `unpack()`: `flags=$(test -n)` always expanded to an empty *quoted*
  argument. GNU tar ignores it; busybox tar reads it as a member name and fails
  with "tar: : not found in archive". Also makes `-V` verbose extraction work.

This makes Alpine work too, which was blocked by both bugs independently.

Also stop `setup agent` failures aborting bare under `set -e` — the silent
"exit 1" half of #990. A crash, or an older CLI with no `setup` subcommand
(v4.5.3 exits 2), now reports the real status instead of dying with no message.

Verified: the quoting helpers are byte-identical to the bash originals across
quote, backslash, glob and empty inputs under dash, bash and busybox ash; full
installs pass on ubuntu/debian × sh,dash,bash and alpine × sh,ash. New CI job
lints both scripts as dash and runs a real install under dash and under ash.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codyde codyde added release/patch Author patch release release/skip Author no release and removed release/patch Author patch release labels Aug 3, 2026
An empty needle matches at every position, so the substitution loop would never
advance and the installer would hang with no output. No current caller passes
one; guard rather than leave the trap for a future one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codyde
codyde merged commit 064e543 into master Aug 3, 2026
7 checks passed
@codyde
codyde deleted the fix/installer-posix-sh branch August 3, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/skip Author no release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agents.railway.com install fails silently in several common cases (segfault, set -e + whoami, sh vs bash)

1 participant