Skip to content

Conversation

humanwritten
Copy link

Problem

When opcode is launched from /Applications folder on macOS, it receives a minimal PATH environment that doesn't include NVM directories. This causes Claude commands to fail with "env: node: No such file or directory" for users with npm-local Claude installations that depend on Node.js from NVM.

Root Cause

The existing code had an unused _std_cmd variable in commands/claude.rs that was creating an enhanced PATH but never using it. Additionally, NVM path detection only worked when Claude itself was installed in an NVM directory, not when Claude was elsewhere but needed Node.js from NVM.

Solution

This PR provides a minimal, targeted fix:

  1. Fixed unused variable: Removed underscore from _std_cmd so the enhanced PATH is actually used
  2. Added NVM detection: Added an else clause in claude_binary.rs to detect and add NVM Node.js paths even when Claude isn't installed via NVM
  3. Targeted override: Added a conditional override that ONLY applies when Claude is NOT in NVM but needs Node.js from NVM

Changes

  • src-tauri/src/claude_binary.rs: Added else clause for NVM detection when Claude needs Node but isn't in NVM
  • src-tauri/src/commands/claude.rs: Fixed unused _std_cmd and added targeted PATH override

Testing

  • Built and tested DMG on macOS with Claude installed via npm-local
  • Verified the fix works when opcode is launched from /Applications
  • The fix only triggers for the specific edge case (Claude not in NVM but needing Node from NVM)
  • Note: Tested and confirmed working on macOS where the edge case was occurring. Not tested on other environments or operating systems.

Impact

  • Zero impact on other installation types - the override only happens when Claude is NOT in an NVM directory but the enhanced PATH contains NVM paths
  • No changes to existing logic flow - all existing code runs first, our fix applies last only when needed
  • Platform-safe: NVM path detection only adds paths if they exist

Fixes the issue where npm-local Claude installations fail when opcode is launched from /Applications due to missing Node.js in PATH.

Problem: When opcode is launched from /Applications on macOS, Claude commands fail
with 'env: node: No such file or directory' for npm-local Claude installations
that depend on Node.js from NVM.

Root cause: GUI-launched apps receive minimal PATH that lacks NVM directories,
and existing code only added NVM paths when Claude itself was in NVM.

Solution:
- Added NVM detection in claude_binary.rs for when Claude needs Node from NVM
- Fixed unused _std_cmd variable in commands/claude.rs to actually use enhanced PATH
- Added targeted override that only applies when Claude is NOT in NVM but needs it

This is a minimal, targeted fix with zero impact on other installation types.

Tested and confirmed working on macOS where the edge case was occurring.
Not tested on other environments or operating systems.
@humanwritten
Copy link
Author

Have written about the process of this contribution here: https://humanwritten.ai/os1/

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.

1 participant