Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mise install fails to install missing npm:... package #2174

Closed
xavdid opened this issue May 23, 2024 · 6 comments · Fixed by #2532
Closed

mise install fails to install missing npm:... package #2174

xavdid opened this issue May 23, 2024 · 6 comments · Fixed by #2532
Labels
bug Something isn't working

Comments

@xavdid
Copy link
Contributor

xavdid commented May 23, 2024

Describe the bug

When the active configuration file lists an npm package that isn't installed, mise install fails with an error:

Error:
   0: failed to execute command: npm install -g tldr@3.4.0 --prefix /Users/david/.local/share/mise/installs/npm-tldr/3.4.0
   1: No such file or directory (os error 2)

Location:
   src/cmd.rs:242

Version:
   2024.5.21 macos-arm64 (2024-05-23)

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

To Reproduce

  1. In an empty directory, create the following config:
[tools]
"npm:tldr" = "latest"

[settings]
# needed for npm packages
experimental = true
  1. run mise install

Expected behavior

The npm package tldr is installed and the tldr command works.

mise doctor output

version: 2024.5.21 macos-arm64 (2024-05-23)
activated: yes
shims_on_path: no

build_info: 
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS
  Built: Thu, 23 May 2024 03:16:31 +0000
  Rust Version: rustc 1.78.0 (9b00956e5 2024-04-29) (Homebrew)
  Profile: release

shell: 
  /bin/zsh
  zsh 5.9 (x86_64-apple-darwin22.0)

dirs: 
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/Library/Caches/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files: 
  ~/.config/mise/config.toml
  ~/Desktop/tt/mise.toml

backends: 
  cargo
  core
  go
  npm
  pipx
  ubi

plugins: 
  bun     (core)
  deno    (core)
  elixir  https://github.com/mise-plugins/mise-elixir.git#7b06439
  erlang  (core)
  go      (core)
  java    (core)
  node    (core)
  python  (core)
  ruby    (core)
  zig     (core)

toolset: 
  npm:tldr@3.4.0        (missing)
  python@3.12.3         
  node@20.13.1          
  go@1.22.3             
  elixir@1.16.3-otp-26  
  npm:trash-cli@5.0.0   
  npm:epub-wordcount@2.1.2  
  npm:will-it-play@1.0.1  

env_vars: 
  MISE_SHELL=zsh

settings: 
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_tools = []
  experimental = true
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_default_packages_file = "/Users/david/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = false
  yes = false
  ci = false
  debug = false
  trace = false
  log_level = "info"
  python_venv_auto_create = false

  [status]
  missing_tools = "always"
  show_env = false
  show_tools = false

No warnings found
No problems found

Additional context

I thought this was related to #2154, but I see that was fixed (and released) and I can still reproduce.

Also weirdly, the command that's listed as failing (npm install -g tldr@3.4.0 --prefix /Users/david/.local/share/mise/installs/npm-tldr/3.4.0) works if run directly. I've confirmed the /Users/david/.local/share/mise/installs/npm-tldr directory exists, but is empty.

@xavdid xavdid added the bug Something isn't working label May 23, 2024
@nuomi1
Copy link

nuomi1 commented May 26, 2024

Same as me.

@risu729
Copy link

risu729 commented Jun 2, 2024

The same issue occurred for me with other backends, at least with cargo and ubi.

@bellini666
Copy link
Contributor

Also experiencing this with some specific npm libs

From this list https://github.com/bellini666/dotfiles/blob/master/mise/config.toml#L44, I'm experiencing issues with:

  • "npm:eslint_d"
  • "npm:@astrojs/language-server"
  • "npm:@biomejs/biome"

@FelisNivalis
Copy link

I have the same issue. And after looking into it, mise adds to PATH only the packages you pass as parameters, so if you do mise install npm:xxx npm:yyy, only the bin path to /mise/path/to/xxx and /mise/path/to/yyy will be included, but not /mise/path/to/npm. So you will see the error if you don't have a system version of npm.

A workaround is to add the mise shims dir in your PATH, or do mise install npm npm:xxx npm:yyy every time (even if you already installed and used npm with mise).

It would be nice to also improve the error message here, as it's misleading that people would interpret the error message as if the path is not found, but it actually says npm is not found!

@xavdid
Copy link
Contributor Author

xavdid commented Aug 31, 2024

@xavdid
Copy link
Contributor Author

xavdid commented Sep 1, 2024

Ok, I had some time for this today.

I think ultimately it comes down to the the ctx.ts.list_paths() not correctly including the deps (in this case, node):

.prepend_path(ctx.ts.list_paths())?

Adding .envs(self.dependency_env()?) fixes the issue, but given that it affects so many of the experimental backends, there's probably a more central way to do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants