Skip to content

fix(build): stop piped installs from falling back to the cwd - #294

Open
arelchan wants to merge 1 commit into
mainfrom
fix/install_sh_piped_local_mode
Open

fix(build): stop piped installs from falling back to the cwd#294
arelchan wants to merge 1 commit into
mainfrom
fix/install_sh_piped_local_mode

Conversation

@arelchan

Copy link
Copy Markdown
Contributor

Summary

The one-line install silently installed a local checkout instead of the published release wheel.

install_raven picked its mode from dirname "$0". $0 names a real file only when
the installer runs as a file (./install.sh); piped through curl ... | sh the script
arrives on stdin, $0 is sh and its dirname is ., so the "is this a raven source
checkout?" test ran against the current working directory. Anyone running the documented
one-liner from inside a clone (a natural thing for a contributor to do) got a silent
editable install of that working tree: raven --version then reports whatever the
checkout is rather than the release, and the runtime reads a config that the checkout's
branch may not even support. The script prints Local raven source detected, but a user
who typed the official one-liner has no reason to read that as "I am not installing the
release".

Local mode now requires $0 to be an existing file, so a piped run always resolves the
release wheel. RAVEN_LOCAL_SRC=<dir> is the explicit opt-in for a piped run, and a value
that is not a raven checkout fails loudly rather than falling through to remote mode.

install.ps1 had the same fallback, through (Get-Location).Path when $PSScriptRoot is
empty under irm ... | iex; it is fixed the same way.

Type

  • Fix
  • Feature
  • Docs
  • CI / tooling
  • Refactor
  • Other

Verification

Ran install.sh end to end against stub uv / curl / node / npm on the PATH, so the
chosen install command is observable without touching a real environment. Four cases, all
from inside a raven checkout:

Invocation Before After
cat install.sh | sh editable install of the cwd checkout tool install --force raven[channels] @ .../raven-0.1.11-py3-none-any.whl
sh ./install.sh editable install editable install (unchanged)
RAVEN_LOCAL_SRC=<checkout> piped n/a editable install of that checkout
RAVEN_LOCAL_SRC=/nonexistent-dir piped n/a x RAVEN_LOCAL_SRC is not a directory: /nonexistent-dir, exit 1
  • Relevant tests pass locally
  • Relevant lint / type checks pass locally
  • User-facing docs or screenshots are updated when needed

Notes on the unchecked box: the repo has no shell test suite and no shellcheck / shfmt hook,
so "tests" here means the stubbed end-to-end runs above; the pre-commit hooks that do exist
(ruff, prettier, eslint) do not cover .sh / .ps1. install.ps1 was reviewed by reading,
not executed, since this was verified on macOS. Both installers document RAVEN_LOCAL_SRC in
their header comment; the README one-liner is unchanged and needs no edit.

Risk

  • Security impact considered
  • Backward compatibility considered
  • Rollback path is clear for risky changes

Notes: this narrows what a piped script will install from the machine it runs on, so it
removes a way for the installer to pick up unexpected local code. The documented developer
path (./install.sh inside a clone) is unchanged. The only behavior anyone could have relied
on is "pipe the installer while sitting in a clone and get an editable install"; that now
needs RAVEN_LOCAL_SRC=.. Rollback is a revert of this commit.

Related Issues

N/A

"$0" names a real file only when the installer runs as a file. Piped
through `curl ... | sh` the script arrives on stdin, "$0" is "sh" and its
dirname is "." -- so the local-source check ran against the current
directory. A one-line install started from inside a clone therefore
became a silent editable install of that working tree instead of the
published release wheel, leaving `raven --version` reporting whatever the
checkout happened to be and the runtime reading a config the checkout's
branch may not support.

Local mode now requires "$0" to be an existing file (./install.sh), and
RAVEN_LOCAL_SRC=<dir> is the explicit opt-in for a piped run; a value
that is not a raven checkout fails loudly instead of silently falling
through to remote mode. install.ps1 had the same fallback, through
(Get-Location).Path when $PSScriptRoot is empty under `irm ... | iex`.

Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant