Skip to content

fix: hint when sudo cannot find bootit after cargo install - #12

Merged
mincomk merged 1 commit into
mainfrom
fix/sudo-command-not-found
Jul 31, 2026
Merged

fix: hint when sudo cannot find bootit after cargo install#12
mincomk merged 1 commit into
mainfrom
fix/sudo-command-not-found

Conversation

@mincomk

@mincomk mincomk commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Problem

Closes #11

After cargo install bootit, running bootit scan as a normal user shows:

Error: This program must be run as root (try: sudo bootit ...)

but following that advice fails:

$ sudo bootit scan
sudo: bootit: command not found

Root cause

cargo install places the binary in ~/.cargo/bin, which is on the user's PATH but not on sudo's secure_path (Debian/Ubuntu default: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin). sudo resets the environment and only searches secure_path, so it cannot find the binary at all — sudo -E doesn't help either, because secure_path overrides PATH even with -E.

Fix

  • src/util.rs — when run as non-root, detect a user-local install (binary under $HOME or in .cargo/bin) and attach an actionable help to the error:
    sudo /home/user/.cargo/bin/bootit ...
    
    or the one-time symlink:
    sudo ln -s /home/user/.cargo/bin/bootit /usr/local/bin/bootit
    
    When the binary lives in a system directory, the error message is unchanged.
  • Unit tests for the hint generation (system dir → no hint, cargo install → hint).
  • CI — run cargo test in addition to cargo build.
  • README — new Troubleshooting section documenting the issue and both workarounds.
  • CHANGELOG[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/bin cases.

`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
Repository owner deleted a comment from gemini-code-assist Bot Jul 31, 2026
@mincomk
mincomk merged commit 2a1d4ad into main Jul 31, 2026
2 checks passed
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.

"sudo bootit" isn't working.

2 participants