enhancement(dev): make prepare.sh safer on workstations#25430
Closed
pront wants to merge 1 commit into
Closed
Conversation
prepare.sh is primarily a CI bootstrap, but contributors are increasingly the second audience (see the new tooling-shortcut note in docs/DEVELOPING.md). This adds three small CI-gated guards so running the script on a personal laptop is less surprising. Each guard preserves the existing CI behavior; the differences only apply when `CI` is unset. 1. `git config --global --add safe.directory "$(pwd)"` is now skipped outside CI. Contributors own their checkouts and don't hit git's dubious-ownership error, so we avoid a write to ~/.gitconfig. 2. The version-pin check no longer downgrades cargo tools the user has already installed at a newer version. CI starts from nothing and keeps installing the exact pin; on workstations, if the installed version is newer than the pin, the script keeps it and prints a notice. Setting CI=1 forces the pin. 3. The npm tool symlinks into the global npm bin dir are skipped outside CI. Avoids `sudo ln -sf` into /usr/local/bin (or equivalent) without the user opting in. The script prints a PATH hint pointing at the project-local `node_modules/.bin` directory instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9 tasks
Member
Author
|
Folded into #25429. The three CI-gated safety guards now ship as the last commit of that PR. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
prepare.shis primarily a CI bootstrap, but #25429 promotes it as the recommended one-shot install for contributor tooling indocs/DEVELOPING.md. That doc commit added a warning about three specific surprises the script causes on a personal laptop. This PR removes those surprises so the warning can shrink.Each change is a CI-gated guard: behavior on CI is unchanged (because the workflows set
CI=true); behavior differs only whenCIis unset.What changes
git config --global --add safe.directory "$(pwd)"runs only whenCIis set. Contributors own their checkouts and don't hit git's dubious-ownership error, so the global config write is unnecessary on a workstation.CI=1forces the pin.$(npm config get prefix -g)/bin) are skipped outside CI. This avoidssudo ln -sf /usr/local/bin/...without the user opting in. The script prints a PATH hint pointing at the project-localnode_modules/.bininstead.How did you test this PR?
bash -n scripts/environment/prepare.shpasses.shellcheck scripts/environment/prepare.shis clean.if [[ -n "${CI:-}" ]]/if [[ -z "${CI:-}" ]]reads correctly for bothCI=true(CI path retained) andCIunset (new local path taken).grep -oE '[0-9]+\.[0-9]+\.[0-9]+') andsort -Vproduce the expected newer/older ordering on the pinned tools.Change Type
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.References
prepare.shas a contributor shortcut and adds the workstation warning this PR shortens).