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

script run failed in all conditions #304

Open
CengsBlanky opened this issue Nov 1, 2024 · 13 comments · Fixed by #313
Open

script run failed in all conditions #304

CengsBlanky opened this issue Nov 1, 2024 · 13 comments · Fixed by #313
Labels
question Further information is requested

Comments

@CengsBlanky
Copy link

CengsBlanky commented Nov 1, 2024

script can not run properly, I'm running kulala in a windows powershell, with nodejs installed(v22.11.0), NVIM v0.10.2, and here is my config:

  {
    'mistweaverco/kulala.nvim',
    ft = { "http" },
    opts = {},
    config = function ()
      local kulala = require("kulala")
      kulala.setup({
        debug = true,
        default_env = "green",
        additional_curl_options = { "--insecure", "-A", "Mozilla/5.0" },
        icons = {
          inlay = {
            loading = "",
            done = "",
            error = "",
          },
        },
        winbar = true,
        default_winbar_panes = { "body", "headers", "headers_body", "script_output" },
        default_view = "headers_body",
      })
    end
  },

everything work just fine before few weeks ago, and here is the error message after run kulala request:

Javascript base files not found. Installing dependencies...
D:/DevTools/neovim/share/nvim/runtime/lua/vim/_system.lua:244: ENOENT: no such file or directory
stack traceback:
^I[C]: in function 'error'
^ID:/DevTools/neovim/share/nvim/runtime/lua/vim/_system.lua:244: in function 'spawn'
^ID:/DevTools/neovim/share/nvim/runtime/lua/vim/_system.lua:335: in function 'system'
^I...im/lua/kulala/parser/scripts/engines/javascript/init.lua:26: in function 'install'
^I...im/lua/kulala/parser/scripts/engines/javascript/init.lua:119: in function 'run'
^I...Local/nvim-data/lazy/kulala.nvim/lua/kulala/cmd/init.lua:130: in function <...Local/nvim-data/lazy/kulala.nvim/lua/kulala/cmd/init.lua:103>

here is the simple request I test:

# @getJsonPlaceHolder
GET https://jsonplaceholder.typicode.com/posts/2

> {%
  client.log(response.body.json)
%}
@gorillamoe
Copy link
Member

Seems as if npm can't be found from within Neovim.

Does :!npm -v work?

@gorillamoe gorillamoe added the question Further information is requested label Nov 1, 2024
@CengsBlanky
Copy link
Author

Seems as if npm can't be found from within Neovim.

Does :!npm -v work?

Yes, the output is 10.9.0

@CengsBlanky
Copy link
Author

I recently found out that this could be npm install problem. I checked the source code which install JavaScript engine. and it failed. It's there a way to install JavaScript engine manually?

@gorillamoe
Copy link
Member

It can be done manually, but is quite difficult. I'd rather fix it for windows, but I have no working windows setup with neovim at the moment.

I started setting it up yesterday, but it got late and I'm not finished yet.

@CengsBlanky
Copy link
Author

It can be done manually, but is quite difficult. I'd rather fix it for windows, but I have no working windows setup with neovim at the moment.

I started setting it up yesterday, but it got late and I'm not finished yet.

Great! By the way, this could be windows permission limitation while executing out commands, and here is my .npmrc config:

prefix=D:\npm_lib
strict-ssl=false
https-proxy=[my company proxy address]

Hope it helps

@gorillamoe
Copy link
Member

Ah, maybe the proxy is blocking the installation? Can you cd into the kulala install dir and then lua/kulala/parser/scripts/engines/javascript/lib and run npm ci there and see if it fails?

@CengsBlanky
Copy link
Author

Ah, maybe the proxy is blocking the installation? Can you cd into the kulala install dir and then lua/kulala/parser/scripts/engines/javascript/lib and run npm ci there and see if it fails?

Here is output, it seems nothing goes wrong:

npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead

added 282 packages, and audited 283 packages in 5s

120 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

@Grueslayer
Copy link
Contributor

Grueslayer commented Nov 7, 2024

@gorillamoe @CengsBlanky Hi, as written in a different issue: This is a NeoVIM bug in the implementation of vim.system. As long not fixed we need to use vim.fn.system if possible or make path to npm (which must be npm.cmd for windows) configurable.

neovim/neovim#31107

@gorillamoe
Copy link
Member

gorillamoe commented Nov 7, 2024

@gorillamoe @CengsBlanky Hi, as written in a different issue: This is a NeoVIM bug in the implementation of vim.system. As long not fixed we need to use vim.fn.system if possible or make path to npm (which must be npm.cmd for windows) configurable.

neovim/neovim#31107

TIL about the subtile differences between vim.system and vim.fn.system 😲

Thanks for the help @Grueslayer

@CengsBlanky
Copy link
Author

@gorillamoe @CengsBlanky Hi, as written in a different issue: This is a NeoVIM bug in the implementation of vim.system. As long not fixed we need to use vim.fn.system if possible or make path to npm (which must be npm.cmd for windows) configurable.

neovim/neovim#31107

That's reasonable, so replace vim.system with vim.fn.system should fix the problem~~~

@gorillamoe
Copy link
Member

@gorillamoe @CengsBlanky Hi, as written in a different issue: This is a NeoVIM bug in the implementation of vim.system. As long not fixed we need to use vim.fn.system if possible or make path to npm (which must be npm.cmd for windows) configurable.
neovim/neovim#31107

That's reasonable, so replace vim.system with vim.fn.system should fix the problem~~~

Yes, I'll prepare a PR in the at around 1730 CEST+0100

gorillamoe added a commit that referenced this issue Nov 7, 2024
This is a workaround for a bug/weird behaviour in neovim:
neovim/neovim#31107

Once this has been merged:
neovim/neovim#31109

We can revert this workaround.

Fixes #304
@CengsBlanky
Copy link
Author

CengsBlanky commented Nov 8, 2024

Problem solved, but it takes a little effort

After upgrade to version 4.4.1, run script got error message:

Javascript base files not found. Installing dependencies...
npm install fail with code 4294963238

And I checked nodejs log file under C:\Users\[username]\AppData\Local\npm-cache\_logs, and found the cause:

14 verbose stack Error: Could not read package.json: Error: ENOENT: no such file or directory, open 'D:\kulalala\package.json'

Since my kulala http files is under D:\kulalala, and to install JavaScript engine, I need change directory to C:\Users\[username]\AppData\Local\Temp\nvim\kulala\scripts\build where package.json located, create a http file, send request with post-script, invoke engine install, and finally it works

I guess install with --prefix takes no effects

@gorillamoe
Copy link
Member

I guess install with --prefix takes no effects

probably either due to your .npmrc or due to a newer version of npm/node.

I'm using v20 with linux (without a .npmrc with a defined prefix) and it works.

Have to investigate a little bit further.

@gorillamoe gorillamoe reopened this Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants