Skip to content

fix: install.sh venv detection, Windows path support, and install dir#7

Merged
infinitimeless merged 1 commit into
mainfrom
fix/install-script-venv-windows
Apr 10, 2026
Merged

fix: install.sh venv detection, Windows path support, and install dir#7
infinitimeless merged 1 commit into
mainfrom
fix/install-script-venv-windows

Conversation

@infinitimeless
Copy link
Copy Markdown
Owner

Problem

Reported by a user running the install script inside Pinokio on Windows with a pre-existing venv.

Three bugs were present:

  1. Install directory defaulted to $HOMEINSTALL_DIR="$HOME/lmstudio-mcp" caused the script to break out of the user's working directory and install in their Windows home folder instead of where Pinokio (or any other launcher) invoked the script from.

  2. No detection of an already-active venv — The script unconditionally created a new venv even if $VIRTUAL_ENV was already set (i.e. the user was already inside one). This broke Pinokio environments and any other tool that pre-activates a venv before running the script.

  3. Hardcoded bin/activate path breaks on Windows — On Windows (Git Bash / MSYS2), the activate script lives at Scripts/activate, not bin/activate. The generated start_lmstudio_mcp.sh had the same hardcoded path.

Fix

  • INSTALL_DIR now defaults to $(pwd) — install happens where the script is run from.
  • already_in_venv() checks $VIRTUAL_ENV and $CONDA_DEFAULT_ENV before creating anything.
  • find_existing_venv() searches common venv directory names (venv, .venv, env, etc.) before creating a new one.
  • get_activate_path() tries bin/activate, Scripts/activate, and scripts/activate in order — works on Linux, macOS, and Windows.
  • Generated start_lmstudio_mcp.sh and dev_setup.sh now use the detected path rather than the hardcoded venv/bin/activate.
  • Added a trap on ERR so failures print the line number instead of silently dying.

Testing

Verified the following scenarios are handled correctly:

  • Fresh install on Linux/macOS (creates venv/bin/activate)
  • Fresh install on Windows Git Bash (creates venv/Scripts/activate)
  • Running inside an existing venv — skips creation entirely
  • Running from a Pinokio-managed directory — installs in place, not $HOME
  • Existing venv present in directory — reuses it without recreating

- Default INSTALL_DIR to current working directory (pwd) instead of $HOME
- Skip venv creation if already inside an active venv ($VIRTUAL_ENV is set)
- Search for existing venv activate script before creating a new one
- Detect Windows (Git Bash/MSYS2) activate path (Scripts/ vs bin/)
- Fix hardcoded bin/activate in generated start_lmstudio_mcp.sh
- Add error trap for clearer failure messages

Fixes: install breaks out to $HOME when run from Pinokio or any
pre-configured venv environment on Windows.
@infinitimeless infinitimeless merged commit 08b3c85 into main Apr 10, 2026
1 check passed
@infinitimeless infinitimeless deleted the fix/install-script-venv-windows branch April 10, 2026 18:07
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