Skip to content

fix(shell): escape exe path in activation scripts for paths with spaces#7315

Merged
jdx merged 2 commits intomainfrom
fix/activate-path-spaces
Dec 15, 2025
Merged

fix(shell): escape exe path in activation scripts for paths with spaces#7315
jdx merged 2 commits intomainfrom
fix/activate-path-spaces

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Dec 15, 2025

Summary

  • When the mise executable path contains spaces (e.g., C:\Users\Some User\...), the activation scripts would fail because the path was not properly quoted
  • Uses shell_escape::unix::escape() on the exe path for bash, zsh, fish, and elvish shells to ensure paths containing special characters are properly escaped
  • For elvish, wraps the escaped path with (external ...) which is the proper way to call external commands with paths that may contain spaces

Test plan

  • Unit tests pass
  • Lint checks pass
  • Manual testing with a path containing spaces

Fixes #4839

🤖 Generated with Claude Code


Note

Escapes the mise executable path across bash/zsh/fish/elvish activation scripts (using shell_escape) and updates elvish calls to use (external ...), with snapshots updated accordingly.

  • Shell Activation:
    • Escape exe path with shell_escape::unix::escape in bash, zsh, fish, and elvish.
    • Update command invocations to use escaped exe; elvish wraps calls with (external ...).
  • Tests/Snapshots:
    • Refresh shell activation snapshots reflecting escaped paths and elvish external calls.
    • Update related snapshots in config/config_file, config, plugins, direnv, env_diff, and hash to match new outputs.

Written by Cursor Bugbot for commit 631fdbb. This will update automatically on new commits. Configure here.

When the mise executable path contains spaces (e.g., `C:\Users\Some User\...`),
the activation scripts would fail because the path was not properly quoted.

This change uses `shell_escape::unix::escape()` on the exe path for bash, zsh,
fish, and elvish shells. This ensures that paths containing special characters
(including spaces) are properly escaped with shell quoting.

For elvish, we also wrap the escaped path with `(external ...)` which is the
proper way to call external commands with paths that may contain spaces in
elvish.

Fixes #4839

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings December 15, 2025 13:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes shell activation script failures when the mise executable path contains spaces or special characters by properly escaping the path in shell scripts.

Key changes:

  • Adds shell_escape::unix::escape() function usage to escape executable paths for bash, zsh, fish, and elvish shells
  • Removes single quotes around escaped paths in bash activation scripts since the escaping function already handles proper quoting
  • Wraps elvish executable calls with (external ...) syntax to properly handle escaped paths in that shell

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/shell/bash.rs Added path escaping and removed single quotes around escaped exe path
src/shell/zsh.rs Added path escaping for executable path
src/shell/fish.rs Added path escaping for executable path
src/shell/elvish.rs Added path escaping and wrapped calls with (external ...) syntax
src/shell/snapshots/mise__shell__bash__tests__activate.snap Updated test snapshot reflecting removed quotes
src/shell/snapshots/mise__shell__elvish__tests__hook_init.snap Updated test snapshot with (external ...) wrapping and updated expression
Multiple snapshot files Removed snapshot_kind: text metadata lines
Comments suppressed due to low confidence (1)

src/shell/snapshots/mise__shell__bash__tests__activate.snap:1

  • Updated expression in elvish test snapshot from incorrect format to elvish.activate(opts). This appears to be a correction of the snapshot metadata rather than the test expression itself.
---

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jdx jdx enabled auto-merge (squash) December 15, 2025 13:36
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 15, 2025

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.7 x -- echo 20.7 ± 0.4 19.8 24.5 1.03 ± 0.03
mise x -- echo 20.2 ± 0.4 19.5 22.3 1.00

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.7 env 20.4 ± 0.4 19.6 24.2 1.03 ± 0.04
mise env 19.8 ± 0.7 18.7 25.0 1.00

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.7 hook-env 20.3 ± 0.5 19.5 25.7 1.01 ± 0.04
mise hook-env 20.2 ± 0.6 18.8 22.2 1.00

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.7 ls 17.2 ± 0.4 16.4 18.5 1.00
mise ls 17.5 ± 0.5 16.6 19.3 1.02 ± 0.04

xtasks/test/perf

Command mise-2025.12.7 mise Variance
install (cached) 109ms 111ms -1%
ls (cached) 67ms 66ms +1%
bin-paths (cached) 72ms 73ms -1%
task-ls (cached) 445ms ✅ 280ms +58%

✅ Performance improvement: task-ls cached is 58%

@jdx jdx merged commit a357fa9 into main Dec 15, 2025
40 of 43 checks passed
@jdx jdx deleted the fix/activate-path-spaces branch December 15, 2025 14:27
jdx pushed a commit that referenced this pull request Dec 15, 2025
### 🚀 Features

- **(conda)** add dependency resolution for conda packages by @jdx in
[#7280](#7280)
- **(go)** add created_at support to ls-remote --json by @jdx in
[#7305](#7305)
- **(hook-env)** add hook_env.cache_ttl and hook_env.chpwd_only settings
for NFS optimization by @jdx in
[#7312](#7312)
- **(hooks)** add MISE_TOOL_NAME and MISE_TOOL_VERSION to
preinstall/postinstall hooks by @jdx in
[#7311](#7311)
- **(shell_alias)** add shell_alias support for cross-shell aliases by
@jdx in [#7316](#7316)
- **(tool)** add security field to mise tool --json by @jdx in
[#7303](#7303)
- add --before flag for date-based version filtering by @jdx in
[#7298](#7298)

### 🐛 Bug Fixes

- **(aqua)** support cosign v3 bundle verification by @jdx in
[#7314](#7314)
- **(config)** use correct config_root in tera context for hooks by @jdx
in [#7309](#7309)
- **(nu)** fix nushell deactivation script on Windows by @fu050409 in
[#7213](#7213)
- **(python)** apply uv_venv_create_args in auto-venv code path by @jdx
in [#7310](#7310)
- **(shell)** escape exe path in activation scripts for paths with
spaces by @jdx in [#7315](#7315)
- **(task)** parallelize exec_env loading to fix parallel task execution
by @jdx in [#7313](#7313)
- track downloads for python and java by @jdx in
[#7304](#7304)
- include full tool ID in download track by @jdx in
[#7320](#7320)

### 📚 Documentation

- Switch `postinstall` code to be shell-agnostic by @thejcannon in
[#7317](#7317)

### 🧪 Testing

- **(e2e)** disable debug mode by default for windows-e2e by @jdx in
[#7318](#7318)

### New Contributors

- @fu050409 made their first contribution in
[#7213](#7213)
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.

2 participants