Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
zipsign.pub binary
crates/mise-shim/native-shim-marker binary
src/gpg_testdata/node_v20.11.0_SHASUMS256.txt text eol=lf
src/system/remote_testdata/* text eol=lf
vendor/aqua-registry/** linguist-vendored
Expand Down
1 change: 1 addition & 0 deletions crates/mise-shim/native-shim-marker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mise generated native shim v1
2 changes: 2 additions & 0 deletions crates/mise-shim/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use std::path::Path;
use std::process::{Command, ExitCode};

const MISE_SHIM_PATH_ENV: &str = "__MISE_SHIM_PATH";
#[used]
static NATIVE_SHIM_MARKER: [u8; 30] = *include_bytes!("../native-shim-marker");

fn paths_eq(a: &Path, b: &Path) -> bool {
let lexical_eq = |a: &Path, b: &Path| {
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/reshim.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Note that this creates shims for _all_ installed tools, not just the ones that a
currently active in mise.toml.

## Flags
- **`-f --force`** — Removes all shims before reshimming
- **`-f --force`** — Rebuilds all mise-owned shims
- **`--system`** — Rebuild the system shim farm
- **`-h --help`** — Print help

Expand Down
7 changes: 6 additions & 1 deletion docs/dev-tools/shims.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ Note that `mise` already runs a reshim anytime a tool is installed/updated/remov
`mise reshim` only creates/removes the shims. Some users sometimes use it as a
"fix it" button, but it is only necessary if `~/.local/share/mise/shims` doesn't contain something it should.

Do not add additional executable in the `mise` directory, `mise` will delete them with the next reshim.
For `mise reshim`, the configured shim directory may be a shared executable directory such as
`~/.local/bin` or `/usr/local/bin`: reshim only replaces or removes entries it recognizes as mise
shims, and leaves a same-named unmanaged file in place. Other mise features still identify shim
directories as whole `PATH` entries, however, so a shared directory is not yet supported with
`mise activate`, hook-env, or internal dependency lookups. Use a dedicated `shims_dir` if you use
those features.

## Command wrappers

Expand Down
5 changes: 5 additions & 0 deletions docs/directories.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ does not work for some reason.

The setting is global-only, expands `~`, and must resolve to an absolute path.

`mise reshim` can publish into a shared executable directory such as `~/.local/bin` or
`/usr/local/bin`; it only replaces or removes entries it recognizes as mise shims. Other mise
features still filter shim directories as whole `PATH` entries, so use a dedicated directory when
using `mise activate`, hook-env, or internal dependency lookups.

## System installs and shims

System installs default to `/usr/local/share/mise/installs` and system shims
Expand Down
18 changes: 18 additions & 0 deletions e2e/cli/test_shims
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,21 @@ assert \

mise uninstall -a dummy
assert_fail "which dummy"

# A shared executable directory keeps a same-named unmanaged command without
# reporting a shim state that reshim can never repair.
shared_bin="$HOME/.local/bin"
mkdir -p "$shared_bin"
printf '%s\n' '#!/bin/sh' 'echo unmanaged-dummy' >"$shared_bin/dummy"
chmod +x "$shared_bin/dummy"
export MISE_SHIMS_DIR="$shared_bin"
export PATH="$shared_bin:$PATH"

mise i dummy@latest
mise reshim
assert "dummy" "unmanaged-dummy"
assert_not_contains "mise doctor" "shims are missing"

# Force remains conservative in a shared directory.
mise reshim --force
assert "dummy" "unmanaged-dummy"
2 changes: 1 addition & 1 deletion man/man1/mise.1
Original file line number Diff line number Diff line change
Expand Up @@ -4158,7 +4158,7 @@ currently active in mise.toml.
.PP
.TP
\fB\-f, \-\-force\fR
Removes all shims before reshimming
Rebuilds all mise\-owned shims
.TP
\fB\-\-system\fR
Rebuild the system shim farm
Expand Down
2 changes: 1 addition & 1 deletion mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -3070,7 +3070,7 @@ Note that this creates shims for _all_ installed tools, not just the ones that a
currently active in mise.toml.
"""#
after_long_help "\u{1b}[1m\u{1b}[4mExamples:\u{1b}[22m\u{1b}[24m\n\n $ \u{1b}[1mmise reshim\u{1b}[22m\n $ \u{1b}[1m~/.local/share/mise/shims/node -v\u{1b}[22m\n v20.0.0\n"
flag "-f --force" help="Removes all shims before reshimming"
flag "-f --force" help="Rebuilds all mise-owned shims"
flag --system help="Rebuild the system shim farm"
flag "-h --help" help="Print help" action=help builtin=#true
arg "[TOOL]" required=#false hide=#true
Expand Down
3 changes: 3 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,9 @@ description = "Directory containing user shims."
docs = """
The user shim farm. Lazy tools declared in user config publish their bootstrap shims here.
The directory must be absolute after `~` expansion.
`mise reshim` may publish into a shared executable directory such as `~/.local/bin`; it only
replaces or removes entries it recognizes as mise shims. Other mise features filter this directory
as one PATH entry, so use a dedicated directory with activation and internal dependency lookups.
"""
env = "MISE_SHIMS_DIR"
global_only = true
Expand Down
2 changes: 1 addition & 1 deletion src/cli/reshim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) struct Reshim {
#[usage(hide = true)]
pub version: Option<String>,

/// Removes all shims before reshimming
/// Rebuilds all mise-owned shims
Comment thread
jdx marked this conversation as resolved.
Resolved
#[usage(long, short)]
pub force: bool,

Expand Down
Loading
Loading