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

NPM installation incorrect #1190

Closed
jtiee opened this issue May 27, 2023 · 5 comments
Closed

NPM installation incorrect #1190

jtiee opened this issue May 27, 2023 · 5 comments

Comments

@jtiee
Copy link

jtiee commented May 27, 2023

Thanks for your bug report!

Before submitting this issue, please make sure the same problem was
not already reported by someone else.

Please describe the bug you're facing. Consider pasting example
Taskfiles showing how to reproduce the problem.

  • Task version: 3.25.0
  • Operating System: macOS Ventura 13.3.1 (a), on Macbook M1 Pro
  • Node.js: v20.0.0
  • NPM: 9.6.4

Repro steps:

  1. Install task with NPM:

    $ npm i -g @go-task/cli
    
    added 2 packages in 3s
    
  2. Run task:

    $ task
    -bash: task: command not found
    
  3. Investigate the installation folder:

    $ cd /usr/local/lib/node_modules/\@go-task/cli/
    $ ls
    LICENSE
    README.md
    Unknown command: "bin"??To see a list of supported npm commands, run:?  npm help/
    bin/
    node_modules/
    package.json
    
  4. Where is the task binary?

    $ ls -l 'Unknown command: "bin"
    
    To see a list of supported npm commands, run:
      npm help'/
    total 11352
    -rwxr-xr-x  1 jtiee  wheel  5808642 27 May 11:51 task*
    
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label May 27, 2023
@sounisi5011
Copy link

@go-task/cli uses @go-task/go-npm to install binaries. Based on its installation logic, you should be able to find the location of the task binary by running the following command:

npm exec node -- -e '
const path=require("path");
console.log(
  process.env.npm_config_prefix
  ? path.join(process.env.npm_config_prefix, "bin")
  : path.join(process.env.npm_config_local_prefix, "node_modules", ".bin"),
);
'

@jtiee
Copy link
Author

jtiee commented May 29, 2023

The task executable doesn't make it into the bin folder. The bug that produces the folder named Unknown command... prevents that from happening.

@sounisi5011
Copy link

Since Node.js 18.16.0, I can't seem to run task binaries on Windows. sounisi5011/test-if-we-can-run-go-task-on-windows-on-github-workflow was created to research this. But coincidentally, I also found the bug you mentioned.

https://github.com/sounisi5011/test-if-we-can-run-go-task-on-windows-on-github-workflow/actions/runs/5112278768/jobs/9190139130

$ npm install '@go-task/cli@3.25.0'
npm ERR! code 1
npm ERR! path D:\a\test-if-we-can-run-go-task-on-windows-on-github-workflow\test-if-we-can-run-go-task-on-windows-on-github-workflow\node_modules\@go-task\cli
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c go-npm install
npm ERR! Downloading from URL: https://github.com/go-task/task/releases/download/v3.25.0/task_windows_amd64.zip
npm ERR! D:\a\test-if-we-can-run-go-task-on-windows-on-github-workflow\test-if-we-can-run-go-task-on-windows-on-github-workflow\node_modules\@go-task\go-npm\bin\index.js:2
...
npm ERR!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
npm ERR! 
npm ERR! Error: Illegal characters in path.
npm ERR!     at pathArg (D:\a\test-if-we-can-run-go-task-on-windows-on-github-workflow\test-if-we-can-run-go-task-on-windows-on-github-workflow\node_modules\@go-task\go-npm\bin\index.js:2:1989)
npm ERR!     at Function.mkdirpSync [as sync] (D:\a\test-if-we-can-run-go-task-on-windows-on-github-workflow\test-if-we-can-run-go-task-on-windows-on-github-workflow\node_modules\@go-task\go-npm\bin\index.js:2:5717)
npm ERR!     at D:\a\test-if-we-can-run-go-task-on-windows-on-github-workflow\test-if-we-can-run-go-task-on-windows-on-github-workflow\node_modules\@go-task\go-npm\bin\index.js:2:910301
npm ERR!     at ChildProcess.exithandler (node:child_process:411:7)
npm ERR!     at ChildProcess.emit (node:events:511:28)
npm ERR!     at maybeClose (node:internal/child_process:1098:[16](https://github.com/sounisi5011/test-if-we-can-run-go-task-on-windows-on-github-workflow/actions/runs/5112278768/jobs/9190139130#step:3:17))
npm ERR!     at ChildProcess._handle.onexit (node:internal/child_process:304:5) {
npm ERR!   path: 'D:\\a\\test-if-we-can-run-go-task-on-windows-on-github-workflow\\test-if-we-can-run-go-task-on-windows-on-github-workflow\\node_modules\\@go-task\\cli\\Unknown command: "bin"\n' +
npm ERR!     '\n' +
npm ERR!     'To see a list of supported npm commands, run:\n' +
npm ERR!     '  npm help',
npm ERR!   code: 'EINVAL'
npm ERR! }
npm ERR! 
npm ERR! Node.js v[20](https://github.com/sounisi5011/test-if-we-can-run-go-task-on-windows-on-github-workflow/actions/runs/5112278768/jobs/9190139130#step:3:21).0.0

This error does not seem to occur on Unix-like systems 1, but the same thing can happen. Once I find the cause, I will open an issue in go-task/go-npm.

Footnotes

  1. I was able to create a file with that name on my APFS file system. This is probably why the error did not occur.

@sounisi5011
Copy link

This problem is caused by a bug in npm.
npm does not set the correct exit code in Node.js 20.
see npm/cli#6399

This bug has been fixed in npm 9.6.7, and you can avoid this problem by running the following command in your environment.

npm install -g npm@9.6.7

On the other hand, this bug occurs in all versions from npm 7.19.0 to npm 9.6.6.
Since it is not practical to ask all users to update npm, I would like to open a pull request to work around this bug in go-task/go-npm as well.

If you cannot upgrade npm in your environment, please wait a little longer.

@andreynering
Copy link
Member

This bug is now fixed, but you'll have to wait for the next major version for it to work.

@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants