fix(build): stop piped installs from falling back to the cwd - #294
Open
arelchan wants to merge 1 commit into
Open
fix(build): stop piped installs from falling back to the cwd#294arelchan wants to merge 1 commit into
arelchan wants to merge 1 commit into
Conversation
"$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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The one-line install silently installed a local checkout instead of the published release wheel.
install_ravenpicked its mode fromdirname "$0".$0names a real file only whenthe installer runs as a file (
./install.sh); piped throughcurl ... | shthe scriptarrives on stdin,
$0isshand its dirname is., so the "is this a raven sourcecheckout?" 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 --versionthen reports whatever thecheckout 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 userwho typed the official one-liner has no reason to read that as "I am not installing the
release".
Local mode now requires
$0to be an existing file, so a piped run always resolves therelease wheel.
RAVEN_LOCAL_SRC=<dir>is the explicit opt-in for a piped run, and a valuethat is not a raven checkout fails loudly rather than falling through to remote mode.
install.ps1had the same fallback, through(Get-Location).Pathwhen$PSScriptRootisempty under
irm ... | iex; it is fixed the same way.Type
Verification
Ran
install.shend to end against stubuv/curl/node/npmon the PATH, so thechosen install command is observable without touching a real environment. Four cases, all
from inside a raven checkout:
cat install.sh | shtool install --force raven[channels] @ .../raven-0.1.11-py3-none-any.whlsh ./install.shRAVEN_LOCAL_SRC=<checkout>pipedRAVEN_LOCAL_SRC=/nonexistent-dirpipedx RAVEN_LOCAL_SRC is not a directory: /nonexistent-dir, exit 1Notes 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.ps1was reviewed by reading,not executed, since this was verified on macOS. Both installers document
RAVEN_LOCAL_SRCintheir header comment; the README one-liner is unchanged and needs no edit.
Risk
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.shinside a clone) is unchanged. The only behavior anyone could have reliedon 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