Skip to content

fix: remove sudo requirement from install flow#880

Open
fireddd wants to merge 6 commits intoComposioHQ:mainfrom
fireddd:fix/no-sudo-install
Open

fix: remove sudo requirement from install flow#880
fireddd wants to merge 6 commits intoComposioHQ:mainfrom
fireddd:fix/no-sudo-install

Conversation

@fireddd
Copy link
Copy Markdown

@fireddd fireddd commented Apr 2, 2026

Summary

  • setup.sh: Replace sudo npm link fallback with automatic user-local npm prefix configuration (~/.npm-global). When the system npm prefix is not user-writable, the script now auto-configures a user-local prefix and persists the PATH entry to the shell profile.
  • README.md: Replace sudo suggestion with npm prefix fix instructions and npx alternative.
  • SETUP.md: Remove sudo as an install option entirely, reorder to put the recommended no-sudo path first.

Closes #878

Test plan

  • Run scripts/setup.sh on a fresh macOS/Linux system where npm global prefix is system-owned — verify it auto-configures ~/.npm-global without prompting for sudo
  • Verify ao command works after setup on both macOS and Linux
  • Verify npx @composio/ao start works without any global install
  • Verify setup.sh is idempotent (running twice doesn't duplicate PATH entries in shell profile)

🤖 Generated with Claude Code

fireddd and others added 3 commits April 3, 2026 01:11
- setup.sh: replace sudo npm link fallback with automatic user-local
  npm prefix configuration (~/.npm-global) when system prefix is not
  writable. Persists PATH to shell profile.
- README.md: replace sudo suggestion with npm prefix fix and npx option
- SETUP.md: remove sudo as option, reorder to put recommended no-sudo
  path first

Closes ComposioHQ#878

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The in-script `export PATH` only affected the script's subprocess,
not the user's shell. Replace with an explicit message to reload
the shell after npm prefix reconfiguration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of printing a manual reload instruction, use exec $SHELL -l
to transparently restart the user's shell with the updated PATH.
This ensures 'ao' is immediately available after setup without
requiring the user to manually source their profile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- setup.sh: guard exec $SHELL -l behind interactive check so CI and
  parent scripts are not replaced with a login shell
- setup.sh: add error handling if mkdir or npm config set fails, with
  manual fallback instructions
- README.md: remove sudo mention from EACCES guidance
- SETUP.md: remove sudo mention from EACCES guidance

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All three scripts that call npm link (setup.sh, ao-update.sh,
ao-doctor.sh) now source a single ensure-npm-prefix.sh helper.
This eliminates the sudo npm link fallback from all paths and
ensures consistent behavior across install, update, and doctor.

The shared script:
- Detects if npm prefix is user-writable
- Auto-configures ~/.npm-global if not
- Persists PATH to shell profile (idempotent)
- Exports NEEDS_SHELL_RELOAD for callers that want to exec $SHELL
- Fails with manual instructions if mkdir/npm-config fails

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- ensure-npm-prefix.sh: use return 1 instead of exit 1 so sourcing
  scripts (ao-doctor) aren't killed on failure
- setup.sh: use $SHELL_RC instead of hardcoded ~/.zshrc in non-interactive
  reload message so bash users get the correct path
- ao-update.sh: notify user when npm prefix was reconfigured during update

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fireddd
Copy link
Copy Markdown
Author

fireddd commented Apr 2, 2026

Test Plan Results

All tests passing on fix/no-sudo-install branch (commit 93cff02):

Test Result Details
Auto-configures ~/.npm-global when prefix is system-owned ✅ PASS Detects non-writable prefix, creates ~/.npm-global, sets NEEDS_SHELL_RELOAD=true, appends PATH to shell profile
ao command works after setup ✅ PASS ao --version returns 0.1.0
npx @composio/ao start works without global install ✅ PASS Fetches @composio/ao@0.2.2 from npm and runs successfully
setup.sh is idempotent (no duplicate PATH entries) ✅ PASS Second run detects existing npm-global/bin in .zshrc via grep guard and skips append
ao-update.sh checks NEEDS_SHELL_RELOAD ✅ PASS After prefix reconfiguration, prints reload notice with correct $SHELL_RC path

Review comment resolution

  • ao-update.sh silently ignores NEEDS_SHELL_RELOADResolved in 93cff02. Lines 130-132 now check the variable and notify the user with the correct shell profile path.
  • ensure-npm-prefix.sh exit 1 kills ao-doctorResolved in 93cff02. Changed to return 1 since the file is sourced.
  • Hardcoded ~/.zshrc in non-interactive messageResolved in 93cff02. Now uses ${SHELL_RC:-~/.zshrc}.

🤖 Generated with Claude Code

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


if [ "${NEEDS_SHELL_RELOAD:-}" = true ] && [ "$INTERACTIVE" = true ]; then
echo "Restarting shell to pick up new PATH..."
exec "$SHELL" -l
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shell restart without PATH persistence breaks ao availability

Medium Severity

When NEEDS_SHELL_RELOAD is true and INTERACTIVE is true, exec "$SHELL" -l fires unconditionally — even when SHELL_RC is empty because neither ~/.zshrc nor ~/.bashrc exists. On a fresh macOS (where zsh is default but ~/.zshrc hasn't been created yet), the PATH entry for ~/.npm-global/bin is never persisted to any profile. The exec replaces the current process (which had the correct PATH via in-process export) with a login shell that lacks it, making ao unavailable right after "Setup complete!" is printed. The guard at line 169 needs an additional check that SHELL_RC is non-empty before calling exec.

Additional Locations (1)
Fix in Cursor Fix in Web

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.

AO installation should not require sudo access

1 participant