mason.nvim
mason.nvim copied to clipboard
Automatically install npm
I've searched open issues for similar requests
- [X] Yes
I've recently downloaded the latest plugin version of mason.nvim
- [X] Yes
Problem description
When installing packages that need to be installed with npm, the host has to have npm installed.
I don't, as I don't work with that ecosystem.
Expected behavior
I'd like mason to be able to install it's own version of npm to use for this, so I don't have to pollute my host with npm.
Affected packages
All npm packages
Mason output
Failed (1)
◍ pyright
▼ Displaying full log
spawn: npm failed with exit code - and signal -. npm is not executable
Installation log
[INFO Thu 04 May 2023 10:48:57 AM CEST] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:166: Executing installer for Package(name=pyright) {}
[ERROR Thu 04 May 2023 10:48:57 AM CEST] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:200: Installation failed for Package(name=pyright) error=spawn: npm failed with exit code - and signal -. npm is not executable
Neovim version (>= 0.7)
NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
Operating system/version
Linux steve 6.2.13-zen-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Wed, 26 Apr 2023 20:49:44 +0000 x86_64 GNU/Linux
Healthcheck
==============================================================================
mason: require("mason.health").check()
mason.nvim ~
- OK mason.nvim version v1.0.1
- OK neovim version >= 0.7.0
mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2023-05-04-earthy-earth` is installed.
mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send`
- WARNING wget: not available
- ADVICE:
- spawn: wget failed with exit code - and signal -. wget is not executable
- OK curl: `curl 8.0.1 (x86_64-pc-linux-gnu) libcurl/8.0.1 OpenSSL/3.0.8 zlib/1.2.13 brotli/1.0.9 zstd/1.5.5 libidn2/2.3.4 libpsl/0.21.2 (+libidn2/2.3.4) libssh2/1.10.0 nghttp2/1.52.0`
- OK gzip: `gzip 1.12`
- OK tar: `tar (GNU tar) 1.34`
- OK bash: `GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)`
- OK sh: `Ok`
mason.nvim [Languages] ~
- WARNING Ruby: not available
- ADVICE:
- spawn: ruby failed with exit code - and signal -. ruby is not executable
- WARNING Composer: not available
- ADVICE:
- spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING PHP: not available
- ADVICE:
- spawn: php failed with exit code - and signal -. php is not executable
- WARNING npm: not available
- ADVICE:
- spawn: npm failed with exit code - and signal -. npm is not executable
- WARNING RubyGem: not available
- ADVICE:
- spawn: gem failed with exit code - and signal -. gem is not executable
- OK Go: `go version go1.20.4 linux/amd64`
- OK cargo: `cargo 1.69.0`
- WARNING julia: not available
- ADVICE:
- spawn: julia failed with exit code - and signal -. julia is not executable
- OK python3: `Python 3.11.3`
- OK node: `v19.9.0`
- OK luarocks: `/usr/bin/luarocks 3.9.2`
- OK java: `Picked up _JAVA_OPTIONS: -Djava.util.prefs.userRoot=/home/cwr/.config/java`
- OK javac: `Ok`
- OK pip3: `pip 23.1.2 from /usr/lib/python3.11/site-packages/pip (python 3.11)`
mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 67. Remaining: 4933. Limit: 5000. Reset: Thu 04 May 2023 11:22:51 AM CEST.
Screenshots
No response
same problem
would be cool to see this feature implemented, it takes 1h30m to emerge it on gentoo machine the nodejs has gone so big over the time
i also have a similar issue where mason cant find the binary for node even though i have it installed through nvm and i have explicitly set it in the nvim path
Same issue here. I don't want to install npm just to download a language server
I've been wanting to tackle the management of runtimes/compilers more holistically, but I guess it wouldn't hurt adding a node package in the core registry, which would provide the node, npm, npx, and corepack executables.
I myself would rather go for the approach of detecting when npm isn't available, and not requesting mason to install packages that need it.
Please make this configurable. In my setup, I'd rather not have mason manage an npm install.
I ran into this problem yesterday. After probing around the core registry, Mason's config and the log, I've concluded that I needed to have the necessary tools installed on my machine.
I ended up getting around this issue by having a bash script that pretends to be the runtime tool (e.g. npm) and execute the command inside a container (node:20 for this example) instead.
I ended up getting around this issue by having a bash script that pretends to be the runtime tool (e.g. npm) and execute the command inside a container (node:20 for this example) instead.
Interesting, I've never thought about leveraging docker (opt-in) for hooking into external tooling
Interesting, I've never thought about leveraging docker (opt-in) for hooking into external tooling
Unfortunately, my journey wasn't as fruitful as I thought. Beyond installation, Mason stores the code on the host machine, which means when it comes to running the LSP server, it needs the necessary runtime engines as well.
Looking at nvim-lspconfig, there have been discussions on running the server inside a container by modifying the cmd. Going down this route is bypassing Mason altogether, from what I can see.
That said, my experience with neovim (and lua) is non-existent (a couple of days). I don't know enough about this area to offer any directions.
Just chiming in that I ran into the same error message while working with Ubuntu on WSL.
Same issue here. I don't wanna install npm in my notebook only for LSP...
I met the same issue.
Saying same thing doesn't add any value to this issue, author is already aware of it.
Same here, don't want to install npm :raised_hand_with_fingers_splayed: (I complain but I still install it... But I'd rather not. And thanks for your amazing work ;) )
Interesting, I've never thought about leveraging docker (opt-in) for hooking into external tooling
If you decide to do so, you must rely on unprivileged containers, which require the Linux kernel to be compiled with CONFIG_USER_NS (which is widely used nowadays but is very controversial because of the many security vulnerabilities found in it in past). Don't rely on privileged containers as it would obviously be a security risk, I'm pretty sure you don't sudo nvim every time you have to edit something casually :-)
Pyright is written in Typescript, so its natural installation tool is npm, but being a python tool its users are much more likely to have pip installed on their computer than npm.
There's actually already a community-maintained pypi package for Pyright which does exactly what the title above says: installing automatically npm.
I tried it with Mason and I confirm it was able to install pyright successfully.
@williamboman , would you welcome a PR that updates the registry in such a way? I think this would make the user experience of python developers smoother. The change is visible here: https://github.com/sv3ndk/mason-registry/blob/1e88de38fa008fa81270b675135983f6101a2245/packages/pyright/package.yaml#L13
That comment might be better as an issue on it's own.
@sv3ndk The pypi package won't be considered for addition to the core registry because:
- it's not an official source
- the way it's implemented is somewhat problematic imo. it's just a CLI wrapper around the Node package that installs Node & npm, installs the pyright npm package and then executes it as a subprocess, which introduces its own set of issues
I understand the convenience it provides for Python devs who don't touch Node and don't have it installed. I'd like to solve these external dependencies through mason.nvim so that you can manage runtimes as well (i.e. you'd be able to install Node through Mason). This would have to be done in a way that doesn't interfere with how people generally use Neovim with external runtime managers.
Ok, makes sense, thanks for the detailed feed-back
@williamboman Are there any updates on this?
I use a Manjaro distro, and two different Windows from Monday to Friday. Everything runs nice on Linux, but in Windows I am unable to install those ones
installation failed for package(name=html-lsp) error=spawn: npm.cmd failed with exit code - and signal -. npm.cmd is not executable
installation failed for package(name=vim-language-server) error=spawn: npm.cmd failed with exit code - and signal -. npm.cmd is not executable
installation failed for package(name=css-lsp) error=spawn: npm.cmd failed with exit code - and signal -. npm.cmd is not executable
installation failed for package(name=json-lsp) error=spawn: npm.cmd failed with exit code - and signal -. npm.cmd is not executable
installation failed for package(name=yaml-language-server) error=spawn: npm.cmd failed with exit code - and signal -. npm.cmd is not executable
installation failed for package(name=typescript-language-server) error=spawn: npm.cmd failed with exit code - and signal -. npm.cmd is not executable
installation failed for package(name=eslint-lsp) error=spawn: npm.cmd failed with exit code - and signal -. npm.cmd is not executable
installation failed for Package(name=sqlls) error=spawn: npm.cmd failed with exit code - and signal -. npm.cmd is not executable
As the others said, I don't want to have any kind of node related tech on any of my machines, (ye, I know that there's JS related lsp's, but from time to time I do code reviews) so I assume that if on Linux downloads and installs all the LSP correctly, it could be another way to deal with these failures that I am facing on Windows.
Maybe I miss something from the docs (or some other issue) where explains how could I use cargo, wget, curl or whatever but npm?
Thanks
I'm so frustrated right now, not because of this amazing library but with my OS. I have installed npm and go in my machine and I'm still having the same error:
[ERROR Thu 08 Feb 2024 12:16:49 PM -03] ...a/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:249: Installation failed for Package(name=gopls) error=spawn: go failed with exit code - and signal -. go is not executable
[ERROR Thu 08 Feb 2024 12:43:42 PM -03] ...a/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:249: Installation failed for Package(name=typescript-language-server) error=spawn: npm failed with exit code - and signal -. npm is not executable
I also tried with ThePrimeagen repo and I got the same error, to give you some information I want to tell you that I have installed neovim with flatpak in Pop-OS. I will try to install neovim globally and not inside a container and let you know.
UPDATE
Alright, after two days of frustration, my (skill issues) problem was fixed by installing the pre-built archives of nvim to /otc/nvim/ and also installing npm using nvm. A little bit of background, flatpak are containerized applications, that's good for many apps but no for nvim, it cannot access to outside applications (that's the whole point of containerized applications, right?).
Steps to fix my problem:
- Uninstall
nvimflatpak app.
flatpak uninstall io.neovim.nvim
- Follow nvim installation instruction from Pre-built archives.
- Install
nvmfrom here. - Install
npmusingnvm:
nvm install --lts
- Done :)
Also, I will also love not using npm to use this library. Thanks.
Perhaps this could be "fixed" by adding an optional callback to the Mason API somewhere that triggers when a utility fails to install (or when the required libraries are not present).
This would allow other people, potentially a different package, to define the failure case, a few of which could be:
- Install (and manage) that package manager (what this issue is requesting)
- Error out (current behavior)
- Do nothing but log the discrepancy. (what I'd like)
Perhaps this could be "fixed" by adding an optional callback to the Mason API somewhere that triggers when a utility fails to install (or when the required libraries are not present).
This would allow other people, potentially a different package, to define the failure case, a few of which could be:
* Install (and manage) that package manager (what this issue is requesting) * Error out (current behavior) * Do nothing but log the discrepancy. (what I'd like)
Also, I feel the idea complete if in the user configuration could live a little property to determine which managers to use (or to avoid completely), so it could be avoiding the error handling in case of failure and go straight to the user known managers, and, in any case, fallback to such callback
Same issue here. I don't want to install
npmjust to download a language server
so what are you doing to get lsp?
In my case, I'm simply not using lsp in those situations.
i also have a similar issue where mason cant find the binary for node even though i have it installed through nvm and i have explicitly set it in the nvim path
Did you ever figure this out. I am using asdf and on the command line which npm and npm work fine, but mason is still not able to find it when it is trying to install these lsps.
Same issue here. I don't want to install
npmjust to download a language serverso what are you doing to get lsp?
I stopped using Mason and started using my system's package manager instead. https://archlinux.org/packages/extra/any/bash-language-server/ . Super easy to just yay bash-language-server then add it to my configuration in lspconfig.lua
@sahinf how did u add it to lspconfig.lua?
@sahinf how did u add it to lspconfig.lua?
Probably the same as any other. I also feel like we're getting off-topic