fix: hint when sudo cannot find bootit after cargo install - #12
Merged
Conversation
`cargo install` places bootit in ~/.cargo/bin, which is not part of sudo's secure_path. Running `sudo bootit` then fails with "command not found", making the "try: sudo bootit ..." error message misleading. Detect a user-local install and print the working full-path invocation (or a one-time symlink) as help text. Add unit tests for the hint generation, run tests in CI, and document the workaround in the README. Closes #11
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.
Problem
Closes #11
After
cargo install bootit, runningbootit scanas a normal user shows:but following that advice fails:
Root cause
cargo installplaces the binary in~/.cargo/bin, which is on the user's PATH but not on sudo'ssecure_path(Debian/Ubuntu default:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin).sudoresets the environment and only searchessecure_path, so it cannot find the binary at all —sudo -Edoesn't help either, becausesecure_pathoverrides PATH even with-E.Fix
src/util.rs— when run as non-root, detect a user-local install (binary under$HOMEor in.cargo/bin) and attach an actionablehelpto the error:cargo testin addition tocargo build.[Unreleased]entry.Verified locally: built clean on Rust 1.97, 3 tests pass, and the rendered error output was checked for both the system-dir and
~/.cargo/bincases.