-
Notifications
You must be signed in to change notification settings - Fork 752
Description
Python not found on macOS when using pyenv (Unity launched from Dock/Spotlight)
Summary
On macOS, when Unity Editor is launched from the Dock or Spotlight (not from a terminal), MCP for Unity reports that Python is not found—even when Python is installed and available in the shell (e.g. via pyenv). This happens because GUI applications on macOS do not inherit the interactive shell's PATH (e.g. from .zshrc), and the augmented PATH used by the macOS platform detector does not include common Python manager locations like ~/.pyenv/shims.
Environment
- OS: macOS
- Python setup: pyenv (Python 3.10+ in
~/.pyenv/shims) - How Unity is launched: Dock, Spotlight, or Unity Hub (not from terminal)
- MCP for Unity version: 9.4.7 (and likely earlier)
Root cause
In Editor/Dependencies/PlatformDetectors/MacOSPlatformDetector.cs, GetPathAdditions() builds the list of paths prepended when resolving python3/uv. It currently includes:
/opt/homebrew/bin/usr/local/bin/usr/bin/bin~/.local/bin
It does not include ~/.pyenv/shims, which is where pyenv puts its Python shims. When Unity is started by the system (Dock/Spotlight), its process PATH is the minimal one from launchd, so pyenv’s path is never seen unless we add it to the augmented path.
Proposed fix
Add ~/.pyenv/shims to the augmented path in MacOSPlatformDetector.GetPathAdditions() so that Python (and optionally uv if installed via pip in that environment) is found when the editor is not started from a shell.
File: Editor/Dependencies/PlatformDetectors/MacOSPlatformDetector.cs
Change: In GetPathAdditions(), add the pyenv shims directory at the beginning of the array (so it is preferred when present):
private string[] GetPathAdditions()
{
var homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
return new[]
{
Path.Combine(homeDir, ".pyenv", "shims"), // pyenv: Python/uv when Unity is launched from Dock/Spotlight
"/opt/homebrew/bin",
"/usr/local/bin",
"/usr/bin",
"/bin",
Path.Combine(homeDir, ".local", "bin")
};
}No new dependencies; Path.Combine and Environment.SpecialFolder.UserProfile are already in use. If the user does not use pyenv, the ~/.pyenv/shims directory typically does not exist, and the resolver will continue with the next paths.
Workaround (without code change)
Launch Unity (or Unity Hub) from a terminal so it inherits the shell’s PATH:
export PATH="$HOME/.pyenv/shims:$PATH"
open -a "Unity Hub"Thank you for maintaining MCP for Unity.