jdx / mise

dev tools, env vars, task runner

Home Page:https://mise.jdx.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm backend failing to install any packages with "No such file or directory (os error 2)"

bellini666 opened this issue · comments

Some recent update to mise broke this.

I didn't notice which version because for already installed packages it was working fine. But when trying to install a new one by adding it to .mise.toml or mise use 'npm:foobar' it will fail like this:

[DEBUG] Toolset: node@latest
[DEBUG] $ npm view pyright dist-tags --json
Error:
   0: No such file or directory (os error 2)

Location:
   src/forge/npm.rs:47

Version:
   2024.5.9 macos-arm64 (2024-05-13)

Note: tried to run the same command by hand and it worked fine:

❯ npm view pyright dist-tags --json
{
  "latest": "1.1.362"
}

Also I know that there's a new version, but it is not on brew yet. Either way I tried installing it from brew with --head option, but the problem persisted

that error isn't informative but it means "npm" isn't found. Is node installed via mise? There are lots of tests around this and I just ran it locally on the latest main and it works for me.

Yeah, node is installed. You can see my config file in https://github.com/bellini666/dotfiles/blob/master/mise/config.toml

I tried to uninstall and reinstall node as well to see if that would solve the issue. Tried to move node to go before the packages as well.

I share that config with both my mac and my debian machines, both are presenting the same issue

Here is the full output of the command (using the current HEAD):

❯ RUST_BACKTRACE=full mise use -g npm:pyright --verbose
[DEBUG] ARGS: /opt/homebrew/bin/mise use -g npm:pyright --verbose
[DEBUG] Config {
    Config Files: [
        "~/.config/mise/config.toml",
    ],
}
[DEBUG] Toolset: node@latest
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view graphql-language-service-cli dist-tags --json
[DEBUG] Toolset: node@latest
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view dockerfile-language-server-nodejs dist-tags --json
[DEBUG] $ npm view cloc dist-tags --json
[DEBUG] $ npm view @biomejs/biome dist-tags --json
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view ts-server dist-tags --json
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view @astrojs/language-server dist-tags --json
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view cspell dist-tags --json
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view eslint_d dist-tags --json
[WARN] failed to resolve version of npm:graphql-language-service-cli from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view markdownlint-cli dist-tags --json
[WARN] failed to resolve version of npm:dockerfile-language-server-nodejs from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view eslint dist-tags --json
[WARN] failed to resolve version of npm:@biomejs/biome from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view bash-language-server dist-tags --json
[WARN] failed to resolve version of npm:cspell from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:cloc from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view yaml-language-server dist-tags --json
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view typescript-language-server dist-tags --json
[WARN] failed to resolve version of npm:ts-server from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:@astrojs/language-server from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view typescript dist-tags --json
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view vscode-langservers-extracted dist-tags --json
[WARN] failed to resolve version of npm:eslint_d from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view fixjson dist-tags --json
[WARN] failed to resolve version of npm:typescript-language-server from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view graphql dist-tags --json
[WARN] failed to resolve version of npm:markdownlint-cli from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view opencollective dist-tags --json
[WARN] failed to resolve version of npm:fixjson from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view pnpm dist-tags --json
[WARN] failed to resolve version of npm:eslint from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view pyright dist-tags --json
[WARN] failed to resolve version of npm:bash-language-server from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view stylelint dist-tags --json
[WARN] failed to resolve version of npm:vscode-langservers-extracted from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view prettier dist-tags --json
[WARN] failed to resolve version of npm:yaml-language-server from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view tree-sitter-cli dist-tags --json
[WARN] failed to resolve version of npm:typescript from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view patch-package dist-tags --json
[WARN] failed to resolve version of npm:graphql from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:opencollective from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:pyright from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:pnpm from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:prettier from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:stylelint from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:tree-sitter-cli from ~/.config/mise/config.toml: No such file or directory (os error 2)
[WARN] failed to resolve version of npm:patch-package from ~/.config/mise/config.toml: No such file or directory (os error 2)
[DEBUG] Toolset: 1password-cli@latest, actionlint@latest, argocd@latest, awscli@latest, bottom@latest, cheat@latest, delta@latest, doctl@latest, duf@latest, fd@latest, fzf@latest, github-cli@latest, helm@latest, kubectl@latest, kubectx@latest, kubeseal@latest, kustomize@latest, lazygit@latest, lua-language-server@latest, minikube@latest, pre-commit@latest, ripgrep@latest, shellcheck@latest, shfmt@latest, stylua@latest, yamlfmt@latest, npm:@astrojs/language-server@latest, npm:@biomejs/biome@latest, npm:bash-language-server@latest, npm:cloc@latest, npm:cspell@latest, npm:dockerfile-language-server-nodejs@latest, npm:eslint@latest, npm:eslint_d@latest, npm:fixjson@latest, npm:graphql@latest, npm:graphql-language-service-cli@latest, npm:markdownlint-cli@latest, npm:opencollective@latest, npm:patch-package@latest, npm:pnpm@latest, npm:prettier@latest, npm:pyright@latest, npm:stylelint@latest, npm:tree-sitter-cli@latest, npm:ts-server@latest, npm:typescript@latest, npm:typescript-language-server@latest, npm:vscode-langservers-extracted@latest, npm:yaml-language-server@latest, pipx:basedpyright@latest, pipx:black@latest, pipx:codespell@latest, pipx:djlint@latest, pipx:flake8@latest, pipx:ipdb@latest, pipx:ipython@latest, pipx:isort@latest, pipx:mypy@latest, pipx:pdm@latest, pipx:pipx@latest, pipx:poetry@latest, pipx:ruff@latest, pipx:ruff-lsp@latest, pipx:tox@latest, pipx:yamlfix@latest, pipx:yamllint@latest, deno@latest, go@latest, node@latest, python@latest python@sub-0.1:latest python@sub-0.2:latest python@sub-0.3:latest, rust@latest
[DEBUG] Toolset: node@latest
[DEBUG] $ npm view pyright dist-tags --json
Error:
   0: No such file or directory (os error 2)

Location:
   src/forge/npm.rs:47

Version:
   2024.5.11 macos-arm64 (2024-05-13)

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 5 frames hidden ⋮
   6: once_cell::imp::OnceCell<T>::initialize::{{closure}}::h111d13dc5a0dd863
      at <unknown source file>:<unknown line>
   7: once_cell::imp::initialize_or_wait::haf3aa7a524c84eee
      at <unknown source file>:<unknown line>
   8: once_cell::imp::OnceCell<T>::initialize::hbe08db45be77d0a8
      at <unknown source file>:<unknown line>
   9: mise::forge::Forge::latest_version::h35672cbfbdd968ee
      at <unknown source file>:<unknown line>
  10: mise::toolset::tool_version::ToolVersion::resolve_version::hbe11431294b8c5ee
      at <unknown source file>:<unknown line>
  11: mise::toolset::tool_version_request::ToolVersionRequest::resolve::hb2cb1a382151ee2a
      at <unknown source file>:<unknown line>
  12: std::sys_common::backtrace::__rust_begin_short_backtrace::h0f41877c60abc27c
      at <unknown source file>:<unknown line>
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}::h1d0a5c412fdbb1bf
      at <unknown source file>:<unknown line>
  14: std::sys::pal::unix::thread::Thread::new::thread_start::he47ee5f2ef45b057
      at <unknown source file>:<unknown line>
  15: __pthread_joiner_wake<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.

@jdx could workaround that by doing export PATH=/Users/thiago/.local/share/mise/installs/node/22.1.0/bin:${PATH} and running mise install after

So the issue seems that the issue is happening when trying to use npm from mise itself

I think you need to define node before any npm tools

I think you need to define node before any npm tools

As I commented here I tried moving node to before, but it did not have any effect on this issue.

Also, the reason why I have it set to after is to make sure that I'll use the version from the defined npm:package instead of the one possibly installed with node itself.

I'm not really sure, it's working for me:

❯ cd (mktemp -d)
❯ mise -v
2024.5.9 macos-arm64 (2024-05-13)
❯ mise ls
Plugin  Version  Config Source Requested
❯ mise use npm:pyright
mise failed to execute command: npm install -g pyright@1.1.362 --prefix /Users/jdx/.local/share/mise/installs/npm-pyright/1.1.362
mise No such file or directory (os error 2)
mise Run with --verbose or MISE_VERBOSE=1 for more information
❯ mise use node
mise node@22.1.0 ✓ installed                                                                                          
mise /private/var/folders/03/nk908szn7b35qksv9m08v7mw0000gn/T/tmp.YW0h3TN24m/.mise.toml tools: node@22.1.0
❯ mise use npm:pyright
Reshimming mise latest...
mise npm:pyright@1.1.362 ✓ installed                                                                                  
mise /private/var/folders/03/nk908szn7b35qksv9m08v7mw0000gn/T/tmp.YW0h3TN24m/.mise.toml tools: npm:pyright@1.1.362
❯ cat .mise.toml
[tools]
node = "latest"
"npm:pyright" = "latest"

I tried your config too which worked—is your npm install messed up?

@jdx look at your output, the mise No such file or directory (os error 2) is there. It is the second log line after mise use npm:pyright

Also, try to mise cache clear and then mise upgrade "npm:pyright"

I have a logic in my script that upgrade my mise packages for me to run mise cache clear once per day, because I noticed that without that my npm packages would never upgrade to latest version

right, that's this issue: #2073, you should just have to run it twice

I tried your config too which worked—is your npm install messed up?

It is installed with mise. I even did an implode while trying to workaround this so it is a completely new installation from mise

But check my previous comment, probably you are not reproducing it because of cache... but I might be wrong

right, that's this issue: #2073, you should just have to run it twice

Screen.Recording.2024-05-13.at.16.01.53.mov

This video might help bringing some insight to the issue

also note that while testing this I moved node to the beginning of my tools section

ah I see, yeah this is a bug. If you run mise i node first that seems to fix it.

I am going to close this though, not because it isn't an issue, but because it's just a different problem resulting from the root cause in #2073

@jdx I'm still experiencing this issue, but I think I know what is going on

If you check my video, when I exported my node path using the latest version in ~/.local/share/mise/installs/node/latest/bin/ it still failed. But when I exported using ~/.local/share/mise/installs/node/22.1.0/bin/ (which is where the symlink resolves to) it works

So the issue is actually that it is failing to resolve symlinks it seems.

Let me know if I should open a new issue instead or if you need any more info from me

that doesn't make sense to me, does ~/.local/share/mise/installs/node/latest/bin/node -v work?

Ohhh, just noticed I'm not using the latest version there. That's my linux machine, on my mac (which installs mise using brew) it is solved

I have a script that will update mise there using mise self-update, I didn't notice it was failing like this:

❯ mise self-update
mise ReqwestError: error sending request for url (https://api.github.com/repos/jdx/mise/releases): error trying to connect: invalid URL, scheme is not http
mise error sending request for url (https://api.github.com/repos/jdx/mise/releases): error trying to connect: invalid URL, scheme is not http
mise error trying to connect: invalid URL, scheme is not http
mise invalid URL, scheme is not http
mise Run with --verbose or MISE_VERBOSE=1 for more information

So nvm this issue (although there's an issue on self-update probably)

obs. regarding the self-update issue, if there was an issue it is already solved. Installed the latest version manually and now self-update works correctly

So nvm this issue (although there's an issue on self-update probably)

there was, that was patched too. getting self_update and reqwest to be happy has been a real pain lately.

phew btw, you had me worried since I was sure I fixed this!

phew btw, you had me worried since I was sure I fixed this!

So sorry about that 😢

And yeah, it is fixed now. Thanks for being so fast btw

thanks for working with me to get these bugs ironed out! without that this would be a lot harder