Skip to content

Fix for "env: node: No such file or directory" in macOS #69

Closed
NerdSnipe wants to merge 2 commits into
winfunc:mainfrom
NerdSnipe:main
Closed

Fix for "env: node: No such file or directory" in macOS #69
NerdSnipe wants to merge 2 commits into
winfunc:mainfrom
NerdSnipe:main

Conversation

@NerdSnipe
Copy link
Copy Markdown

Fix for "env: node: No such file or directory" in macOS

Problem

When building on macOS you may encounter the error:

env: node: No such file or directory

This happens because macOS app bundles have a very restricted PATH environment variable that doesn't include common locations where Node.js is installed (like /opt/homebrew/bin for Homebrew on Apple Silicon Macs).

Root Cause

  • macOS app bundles run with a minimal PATH (typically just /usr/bin:/bin:/usr/sbin:/sbin)
  • Node.js installed via Homebrew goes to /opt/homebrew/bin (Apple Silicon) or /usr/local/bin (Intel)
  • Scripts with shebangs like #!/usr/bin/env node fail because env can't find node in the restricted PATH

Solution

Add PATH enhancement at the beginning of the app's main() function in src-tauri/src/main.rs:

# Fix for "env: node: No such file or directory" in macOS 

## Problem

When building on macOS you may encounter the error:

```
env: node: No such file or directory
```

This happens because macOS app bundles have a very restricted `PATH` environment variable that doesn't include common locations where Node.js is installed (like `/opt/homebrew/bin` for Homebrew on Apple Silicon Macs).

## Root Cause

- macOS app bundles run with a minimal `PATH` (typically just `/usr/bin:/bin:/usr/sbin:/sbin`)
- Node.js installed via Homebrew goes to `/opt/homebrew/bin` (Apple Silicon) or `/usr/local/bin` (Intel)
- Scripts with shebangs like `#!/usr/bin/env node` fail because `env` can't find `node` in the restricted PATH

## Solution

Add PATH enhancement at the beginning of the app's `main()` function in `src-tauri/src/main.rs`:
@NerdSnipe NerdSnipe changed the title Fix PATH for macOS app bundles to include common Node.js locations Fix for "env: node: No such file or directory" in macOS Jun 29, 2025
@advix13
Copy link
Copy Markdown

advix13 commented Jun 29, 2025

This fix does resolve the "env: node: No such file or directory" error, but it creates a new problem: I can only send one command/prompt successfully. After the first message executes properly, any follow-up commands get stuck in an infinite spinning loop and no more messages can be sent.

Resolves #65
Resolves #58
@movax01h
Copy link
Copy Markdown

same fix of this problem #61

@NerdSnipe
Copy link
Copy Markdown
Author

The most recent commit in this pull request resolves the #58 #61 #65 #71

@Qcasares
Copy link
Copy Markdown

Qcasares commented Jul 1, 2025

Here's what I popped in the first line of main() if that helps anyone: // Enhanced PATH for macOS to include common Node.js installation locations
#[cfg(target_os = "macos")]
{
use std::env;
let current_path = env::var("PATH").unwrap_or_default();
let enhanced_path = format!(
"{}:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin",
current_path
);
env::set_var("PATH", enhanced_path);
}

@cmer
Copy link
Copy Markdown

cmer commented Jul 2, 2025

Great start, but it doesn't support other paths from version managers such as asdf, mise, etc. Would it be possible to support those as well?

@shivanathd
Copy link
Copy Markdown

is this merged ?

@ahelme
Copy link
Copy Markdown

ahelme commented Jul 6, 2025

Will this commit break claudia if i apply it as a patch? Can team release this as an official patch pls

@shivanathd
Copy link
Copy Markdown

Need this team.. please..

@HuskyDanny
Copy link
Copy Markdown

Need this, please merge

@ch-o-min
Copy link
Copy Markdown

any changes?
スクリーンショット 2025-08-19 11 07 10

@NerdSnipe NerdSnipe closed this by deleting the head repository Apr 21, 2026
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.

10 participants