From 11e549a8baa8dbcd5bdd4c70a14161a44e2d5602 Mon Sep 17 00:00:00 2001 From: Timo Hubois <46505685+timohubois@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:06:55 +0200 Subject: [PATCH] Isolate npx wrapper runtime from project PATH (#5341) * Don't use the names here since they break the all-themes setup in omarchy-nvim * Pin Omarchy npx wrappers to matching node+npx binaries * Fix npx wrappers when mise node is missing * Pin npx wrappers to matching mise node runtime * Isolate npx wrapper runtime from project PATH * Clarify npx wrapper bin resolution --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-npx-install | 29 ++++++++++++++++++++++++++++- migrations/1776348723.sh | 3 +++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 migrations/1776348723.sh diff --git a/bin/omarchy-npx-install b/bin/omarchy-npx-install index 2ec926d9..e64b9660 100755 --- a/bin/omarchy-npx-install +++ b/bin/omarchy-npx-install @@ -18,7 +18,34 @@ mkdir -p "$HOME/.local/bin" cat > "$HOME/.local/bin/$command" </dev/null + node_root="\$(mise where node@latest)" +fi + +node_bin="\$node_root/bin/node" +npx_bin="\$node_root/bin/npx" + +# Resolve the package bin inside npx, then run it with node@latest without leaking node@latest into PATH. +# Some wrappers are aliases, e.g. playwright-cli wraps the playwright bin. +package_bin_path=\$("\$node_bin" "\$npx_bin" --yes --package "\$package" -- which "\$package" 2>/dev/null) + +if [[ -n \$package_bin_path ]]; then + exec "\$node_bin" "\$package_bin_path" "\$@" +fi + +# Scoped packages like @openai/codex expose an unscoped bin like codex. +package_bin_path=\$("\$node_bin" "\$npx_bin" --yes --package "\$package" -- which "\$command" 2>/dev/null) + +if [[ -n \$package_bin_path ]]; then + exec "\$node_bin" "\$package_bin_path" "\$@" +fi + +echo "Could not resolve npm bin for \$package / \$command" >&2 +exit 127 EOF chmod +x "$HOME/.local/bin/$command" diff --git a/migrations/1776348723.sh b/migrations/1776348723.sh new file mode 100644 index 00000000..8900c9c3 --- /dev/null +++ b/migrations/1776348723.sh @@ -0,0 +1,3 @@ +echo "Pin npx wrappers to the matching mise node runtime" + +source "$OMARCHY_PATH/install/packaging/npx.sh"