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

Setting g:node_host_prog in init.vim generates an error. #15308

Closed
gilbertfrancois opened this issue Aug 8, 2021 · 5 comments
Closed

Setting g:node_host_prog in init.vim generates an error. #15308

gilbertfrancois opened this issue Aug 8, 2021 · 5 comments
Labels
closed:invalid Issues that are closed as "invalid"

Comments

@gilbertfrancois
Copy link

Neovim Version

v0.5.0

Operating system/version:

Ubuntu 18.04

Terminal name/version:

terminal

TERM environment variable

xterm-256color

Installation

nvim.appimage from the release page

Steps to reproduce

Description

I work on different servers and don't want to mess with system wide installed Python and NodeJS distributions. Moreover, the NodeJS distribution, shipped with e.g. Ubuntu 18.04 is too old. That is why I have a NodeJS distribution and custom Python environment in the ${HOME}/.local/share/nvim/lib folder, for Neovim only. Then I specify in init.vim the node host program and Python host program with the options:

let g:python3_host_prog = join([$HOME, "/.local/share/nvim/lib/python/bin/python3"], "")
let g:node_host_prog = join([$HOME, "/.local/share/nvim/lib/node/bin/node"], "")

For python, this works excellent. However, for Node, it does not work. Node only works well if the node binary is in the path and the option g:node_host_prog is not set.

Workaround

Comment out the g:node_host_prog setting in init.vim and run nvim with:

PATH=${HOME}/.local/share/nvim/lib/node/bin:${PATH} nvim

PS: nvim 0.5.0 on macOS has the same problem.

Vim

No response

Expected behavior

Run :checkhealth in nvim with the node binary of choice in the path and not set the node_host_prog:

...
## Python 3 provider (optional)
   - INFO: pyenv: Path: /home/ubuntu/.pyenv/libexec/pyenv
   - INFO: pyenv: Root: /home/ubuntu/.pyenv
   - INFO: Using: g:python3_host_prog = "/home/ubuntu/.local/share/nvim/lib/python/bin/python3"
   - INFO: Executable: /home/ubuntu/.local/share/nvim/lib/python/bin/python3
   - INFO: Python version: 3.7.7
   - INFO: pynvim version: 0.4.3
   - OK: Latest pynvim is installed.
 
 ## Node.js provider (optional)
   - INFO: Node.js: v14.16.1
   - INFO: Nvim node.js host: /home/ubuntu/.local/share/nvim/lib/node-v14.16.1-linux-x64/lib/node_modules/neovim/bin/cli.js
   - OK: Latest "neovim" npm/yarn package is installed: 4.10.0
...

Actual behavior

Run :checkhealth in nvim with g:node_host_prog and g:python3_host_prog set to custom locations. Note that for NodeJS, nvim finds /usr/bin/node (v8.10.0) installed on the system, instead of the one set with g:node_host_prog (v14.16.1) option.

...
## Python 3 provider (optional)
   - INFO: pyenv: Path: /home/ubuntu/.pyenv/libexec/pyenv
   - INFO: pyenv: Root: /home/ubuntu/.pyenv
   - INFO: Using: g:python3_host_prog = "/home/ubuntu/.local/share/nvim/lib/python/bin/python3"
   - INFO: Executable: /home/ubuntu/.local/share/nvim/lib/python/bin/python3
   - INFO: Python version: 3.7.7
   - INFO: pynvim version: 0.4.3
   - OK: Latest pynvim is installed.

## Node.js provider (optional)
   - INFO: Node.js: v8.10.0
   - INFO: Nvim node.js host: /home/ubuntu/.local/share/nvim/lib/node/bin/node --prefix=/home/ubuntu/.local/share/nvim/lib/node
   - ERROR: Command error (job=10, exit code 1): `node '/home/ubuntu/.local/share/nvim/lib/node/bin/node --prefix=/home/ubuntu/.local/share/nvim/lib/node' --version` (in '/home/ubuntu/.dotfiles/nvim')
     stderr: module.js:549    throw err;    ^Error: Cannot find module '/home/ubuntu/.local/share/nvim/lib/node/bin/node --prefix=/home/ubuntu/.local/share/nvim/lib/node'    at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:188:16) at bootstrap_node.js:609:3 in/node --prefix=/home/ubuntu/.local/share/
   - ERROR: Failed to run: ['node', '/home/ubuntu/.local/share/nvim/lib/node/bin/node --prefix=/home/ubuntu/.local/share/nvim/lib/node', '--version']
     - ADVICE:
       - Report this issue with the output of:
       - ['node', '/home/ubuntu/.local/share/nvim/lib/node/bin/node --prefix=/home/ubuntu/.local/share/nvim/lib/node', '--version']
...
@gilbertfrancois gilbertfrancois added the bug issues reporting wrong behavior label Aug 8, 2021
@gilbertfrancois
Copy link
Author

gilbertfrancois commented Aug 8, 2021

When setting let g:node_host_prog = '/home/ubuntu/.local/share/nvim/lib/node/bin/node', in init.vim it looks like nvim is trying to run:

`node '/home/ubuntu/.local/share/nvim/lib/node/bin/node --prefix=/home/ubuntu/.local/share/nvim/lib/node' --version`

I guess the first token node should not be there.

@jdhao

This comment has been minimized.

@gpanders
Copy link
Member

gpanders commented Aug 9, 2021

g:node_host_prog is not a path to the node binary but to the neovim-node-host binary. :h g:node_host_prog makes this explicit:

						*g:node_host_prog*
Command to start the Node.js host. Setting this makes startup faster.

By default, Nvim searches for "neovim-node-host" using "npm root -g", which
can be slow. To avoid this, set g:node_host_prog to the host path: >
    let g:node_host_prog = '/usr/local/bin/neovim-node-host'

This is e.g. the path to the binary resulting from npm install -g neovim.

@gpanders gpanders closed this as completed Aug 9, 2021
@gpanders gpanders added closed:invalid Issues that are closed as "invalid" and removed bug issues reporting wrong behavior labels Aug 9, 2021
@chardskarth
Copy link

Incase someone gets here to try and set "node" to a fixed version instead of the one in $PATH.

Nope, this doesn't do it.

This just sets the path that neovim uses to start the node host but it's still gonna use node from your path.

Even if I do this (documentation was confusing, but this is the correct value to set g:node_host_prog)

vim.g.node_host_prog = vim.fn.expand("~") .. "/.nvm/versions/node/v20.13.0/lib/node_modules/neovim/bin/cli.js"

It won't do it

@justinmk
Copy link
Member

justinmk commented Aug 29, 2024

but it's still gonna use node from your path.

That's probably because cli.js does so.

This will be fixed as we migrate to "v2 remote plugins" (which don't need cli.js): #27949

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:invalid Issues that are closed as "invalid"
Projects
None yet
Development

No branches or pull requests

5 participants