Skip to content

Comments

fix: resolve PATH and health check issues for macOS GUI environment#36

Open
JoyaWang wants to merge 1 commit intomtymek:mainfrom
JoyaWang:fix/macos-path-and-health-check
Open

fix: resolve PATH and health check issues for macOS GUI environment#36
JoyaWang wants to merge 1 commit intomtymek:mainfrom
JoyaWang:fix/macos-path-and-health-check

Conversation

@JoyaWang
Copy link

Summary

  • Fix exit code 127 on macOS: Obsidian (Electron) inherits a minimal PATH (/usr/bin:/bin:/usr/sbin:/sbin) that doesn't include Homebrew, nvm, bun, etc. Since the opencode script uses #!/usr/bin/env node, spawning it fails because node is not found. This PR builds an enhanced PATH by reusing the search directories from ExecutableResolver.
  • Fix health check URL: checkServerHealth() was hitting /{base64path}/global/health which is caught by the SPA router and returns HTML (not the health JSON). Changed to use /global/health directly and validate data.healthy === true.
  • Fix btoa() crash with non-Latin1 paths (fixes Bug: InvalidCharacterError in getUrl when using non-Latin1 characters (e.g., Chinese) #28): Replace btoa() with Buffer.from().toString("base64") to support Chinese/Unicode characters in project paths.
  • Increase default startup timeout from 15s to 120s: First boot can take 30-60s for DB migration and plugin installation.

Closes #28, closes #29

Test plan

  • macOS: Open Obsidian, click the OpenCode icon in the ribbon — server should start successfully
  • Verify the server health check works by checking Obsidian dev console for [OpenCode] logs
  • Test with a vault path containing Chinese characters (e.g. ~/笔记/) — should not crash
  • Test with opencode installed via Homebrew (/opt/homebrew/bin/opencode)
  • Test with opencode installed via nvm/bun global install

🤖 Generated with Claude Code

macOS GUI apps (Obsidian/Electron) inherit a minimal PATH
(/usr/bin:/bin:/usr/sbin:/sbin) that doesn't include Homebrew, nvm,
bun, etc. Since the opencode script uses `#!/usr/bin/env node`,
spawning it from Obsidian fails with exit code 127 (node not found).

Changes:
- Build enhanced PATH for child processes by reusing the search
  directories already defined in ExecutableResolver
- Fix health check URL to use /global/health (without base64 project
  path prefix which hits the SPA catch-all and returns HTML)
- Validate health response JSON (check data.healthy === true)
- Replace btoa() with Buffer.from().toString("base64") to support
  non-Latin1 characters in project paths (fixes mtymek#28)
- Increase default startupTimeout from 15s to 120s since first boot
  may need 30-60s for DB migration and plugin installation

Closes mtymek#28, closes mtymek#29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mtymek
Copy link
Owner

mtymek commented Feb 23, 2026

@JoyaWang Thanks for submitting this. Can you please submit a separate PRs for PATH and health check URL?

I fixed #28 elsewhere, same for the timeout issue

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.

Env vars? Bug: InvalidCharacterError in getUrl when using non-Latin1 characters (e.g., Chinese)

2 participants