neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.15k stars 953 forks source link

Can't install any plugins if node is installed inside a folder with a space on Windows #4987

Closed nelsyeung closed 2 months ago

nelsyeung commented 2 months ago

Result from CocInfo

## versions

vim version: VIM - Vi IMproved 9.1 9010312
node version: v18.20.2
coc.nvim version: 0.0.82-'77ae2d43 2024-04-19 18:15:40 +0800'
coc.nvim directory: C:\Users\nelsy\vimfiles\pack\plugins\start\coc.nvim
term: undefined
platform: win32

## Log of coc.nvim

2024-04-20T12:15:48.719 INFO (pid:26160) [configurations] - Add folder configuration from cwd: C:\Users\nelsy\vimfiles\pack\plugins\start\coc.nvim\.vim\coc-settings.json
2024-04-20T12:15:49.266 INFO (pid:26160) [plugin] - coc.nvim initialized with node: v18.20.2 after 599
2024-04-20T12:15:49.276 INFO (pid:26160) [attach] - receive notification: highlight []
2024-04-20T12:15:49.474 INFO (pid:26160) [extension-installer] - Fetched info of coc-yaml {
  'dist.tarball': 'https://registry.npmjs.org/coc-yaml/-/coc-yaml-1.9.0.tgz',
  'engines.coc': '^0.0.80',
  version: '1.9.0',
  name: 'coc-yaml'
}
2024-04-20T12:15:49.625 INFO (pid:26160) [model-download] - Download completed: URL {
  href: 'https://registry.npmjs.org/coc-yaml/-/coc-yaml-1.9.0.tgz',
  origin: 'https://registry.npmjs.org',
  protocol: 'https:',
  username: '',
  password: '',
  host: 'registry.npmjs.org',
  hostname: 'registry.npmjs.org',
  port: '',
  pathname: '/coc-yaml/-/coc-yaml-1.9.0.tgz',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}
2024-04-20T12:15:49.631 INFO (pid:26160) [model-download] - Downloaded https://registry.npmjs.org/coc-yaml/-/coc-yaml-1.9.0.tgz => C:\Users\nelsy\AppData\Local\coc\extensions\node_modules\coc-yaml-0c09eda6-00eb-405f-94fe-0b61adff2f16
2024-04-20T12:15:49.763 ERROR (pid:26160) [extensions-index] - Error on install coc-yaml Error: C:\Program Files\nodejs\npm.CMD install exited with 1
    at ChildProcess.<anonymous> (C:\Users\nelsy\vimfiles\pack\plugins\start\coc.nvim\build\index.js:67452:22)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
2024-04-20T12:15:52.228 INFO (pid:26160) [attach] - receive notification: highlight []
2024-04-20T12:16:23.126 INFO (pid:26160) [attach] - receive notification: highlight []
2024-04-20T12:16:23.265 INFO (pid:26160) [attach] - receive notification: highlight []
2024-04-20T12:16:23.983 INFO (pid:26160) [attach] - receive notification: highlight []
2024-04-20T12:16:28.057 INFO (pid:26160) [attach] - receive notification: showInfo []

Describe the bug

Can't install any plugins with node is installed inside a folder with a space (e.g., C:\Program Files\nodejs\node.CMD

Reproduce the bug

We will close your issue when you don't provide minimal vimrc and we can't reproduce it

Extra info

According to https://stackoverflow.com/a/30893153/2687427 you cannot use the full path for child_process.spawn.

For now, I have hacked in "npm.CMD" instead of this.npm to allow this to work: https://github.com/neoclide/coc.nvim/blob/77ae2d43c16e69746a3e097d8d2f960a8d962593/src/extension/installer.ts#L239 src/extension/install.ts

fannheyward commented 2 months ago

Can you try this fix https://github.com/neoclide/coc.nvim/pull/4988 ?

nelsyeung commented 2 months ago

@fannheyward It works! Thanks :)