Skip to content

fix: use absolute path when invoking once in install script#14

Merged
kevinmcconnell merged 1 commit intobasecamp:mainfrom
baggiiiie:yc/fix/install
Mar 23, 2026
Merged

fix: use absolute path when invoking once in install script#14
kevinmcconnell merged 1 commit intobasecamp:mainfrom
baggiiiie:yc/fix/install

Conversation

@baggiiiie
Copy link
Copy Markdown
Contributor

sudo resets PATH to a restricted set defined by secure_path in /etc/sudoers Running sudo once gives below error:

Installing background service...
sudo: once: command not found

Fix by introducing a ONCE_BIN variable that is set to the existing path if once is already installed, or to "${INSTALL_DIR}/once" after a fresh install. This avoids PATH resolution issues under sudo and correctly handles the case where once was previously installed to a non-standard location.

Closes #13

`sudo` resets PATH to a restricted set defined by secure_path in `/etc/sudoers`
Running `sudo once` gives below error:

```
Installing background service...
sudo: once: command not found
```

Fix by introducing a `ONCE_BIN` variable that is set to the existing
path if `once` is already installed, or to `"${INSTALL_DIR}/once"` after
a fresh install. This avoids PATH resolution issues under `sudo` and
correctly handles the case where `once` was previously installed to a
non-standard location.

Closes basecamp#13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the install script to invoke once via an absolute path (stored in a new ONCE_BIN variable) so that sudo calls don’t fail due to secure_path PATH restrictions, addressing issue #13.

Changes:

  • Introduce ONCE_BIN and set it to either the existing once location or ${INSTALL_DIR}/once after installation.
  • Use ONCE_BIN for background service installation and for subsequent run_once execution across Docker modes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +85 to 86
echo "once is already installed at ${ONCE_BIN}"
return
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thin this is overly paranoid for this context.
This is an install script that the user is already running (with curl | sh). If an attacker can place a malicious once earlier in $PATH, they likely already have enough access to do damage without this vector.

it wouldn't hurt to add a simple check like [[ "$ONCE_BIN" = /* ]], to ensure it's an absolute path, but it's not a real security concern.

Comment on lines +135 to 136
sg docker -c "${ONCE_BIN} ${install_flag}" </dev/tty
;;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ONCE_BIN will either be the output of command -v once (which returns a clean path) or /usr/local/bin/once. unless user intentionally modifies where once is installed to a path with spaces and run this script again, this isn't really an issue

@baggiiiie
Copy link
Copy Markdown
Contributor Author

hey @kevinmcconnell thanks for starting a review,

imo, the reviews from copilot are too defensive and paranoid for this context, and adds unnecessary complexity to the script.
i don't think there's a need to address them, let me know what you think, thanks!

@kevinmcconnell
Copy link
Copy Markdown
Collaborator

@baggiiiie yes, agreed. Sometimes it flags things that are genuinely useful, but I don’t think this is one of those times :)

I think using the absolute path, as you have here, is the right fix. Will get it merged soon. Thanks for the contribution!

@kevinmcconnell kevinmcconnell merged commit 6443a35 into basecamp:main Mar 23, 2026
4 checks passed
@baggiiiie baggiiiie deleted the yc/fix/install branch March 23, 2026 14:45
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.

installing backend service shows "sudo: once: command not found"

3 participants