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

(gatsby-cli): gatsby new => Command failed with ENOENT: yarnpkg #27338

Closed
KuSh opened this issue Oct 8, 2020 · 8 comments · Fixed by #27346
Closed

(gatsby-cli): gatsby new => Command failed with ENOENT: yarnpkg #27338

KuSh opened this issue Oct 8, 2020 · 8 comments · Fixed by #27346
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby

Comments

@KuSh
Copy link
Contributor

KuSh commented Oct 8, 2020

Summary

While following the tutorial I got an error because yarn is necessary but isn't listed as needing to be installed

$ nvm current 
v14.13.0
$ node --version
v14.13.0
$ npm --version
6.14.8
$ npm install -g gatsby-cli
Success!

Welcome to the Gatsby CLI! Please visit https://www.gatsbyjs.org/docs/gatsby-cli/ for more information.

+ gatsby-cli@2.12.105
$ gatsby --version
Gatsby CLI version: 2.12.105
$ gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world
info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-hello-world.git
Cloning into 'hello-world'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 16 (delta 0), reused 9 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), 389.79 KiB | 1.21 MiB/s, done.
success Created starter directory layout
info Installing packages...

 ERROR 

Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT



  Error: Command failed with ENOENT: yarnpkg
  spawn yarnpkg ENOENT
  
  - child_process.js:268 Process.ChildProcess._handle.onexit
    internal/child_process.js:268:19
  
  - child_process.js:464 onErrorNT
    internal/child_process.js:464:16
  
  - task_queues.js:80 processTicksAndRejections
    internal/process/task_queues.js:80:21

Motivation

This doesn't help being reassured at using gatsby if the basically first step of getting to know it ends up in errors ...

Steps to resolve this issue

After installing yarn with npm install -i yarn problem is solved

Draft the doc

I don't know where the information should be placed but perhaps modifying the Set default Node.js version chapter to include the yarn installation could do it.
Let me know if that's OK and I'll make a PR

Regards,
Nicolas

@KuSh KuSh added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label Oct 8, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 8, 2020
@LekoArts LekoArts added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: documentation An issue or pull request for improving or updating Gatsby's documentation labels Oct 8, 2020
@LekoArts LekoArts changed the title Tutorial should describe installation of needed dependency yarn (gatsby-cli): gatsby new => Command failed with ENOENT: yarnpkg Oct 8, 2020
@LekoArts
Copy link
Contributor

LekoArts commented Oct 8, 2020

yarn is not necessary for the tutorial. gatsby new only tries to use yarn when our checks tell us that you have yarn globally installed.

Please run gatsby info --clipboard and share it here. And provide a minimal reproduction.

Thanks!

@KuSh
Copy link
Contributor Author

KuSh commented Oct 8, 2020

Here you are :

$ gatsby info --clipboard

  System:
    OS: Linux 5.8 Debian GNU/Linux bullseye/sid
    CPU: (4) x64 Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
    Shell: 5.0.18 - /bin/bash
  Binaries:
    Node: 14.13.0 - ~/.nvm/versions/node/v14.13.0/bin/node
    npm: 6.14.8 - ~/.nvm/versions/node/v14.13.0/bin/npm
  Browsers:
    Firefox: 81.0
  npmGlobalPackages:
    gatsby-cli: 2.12.105

I don't know what I can provide in addition to what I provided in initial message for a minimal reproduction. What you pointed me at asks me to create a new Gatsby site with gatsby-cli ... my bug report says I can't even go there :)
If you have anything particular in mind just let me know !

Regards,
Nicolas

@KuSh
Copy link
Contributor Author

KuSh commented Oct 8, 2020

Ok after digging in cli sources, it seems I kept a ~/.config/gatsby/config.json file from a past installation / usage

{
	"telemetry": {
		"enabled": false,
		"machineId": "a4d009c2-1b77-4173-b49c-abb798fd6551"
	},
	"cli": {
		"packageManager": "yarn"
	}
}

And gatsby-cli do trust that config file even if packageManager isn't available anymore.
After removing it, gatsby-cli is working as expected again !

Perhaps hardening cli by testing if packageManager bin really exists before using it and log a warning otherwise could be a good idea. What do you think ?

Regards,
Nicolas

@laurieontech
Copy link
Contributor

Thanks for the updated information! Having an outdated config file would definitely explain a piece of this. However, we do check for your local version of yarnpkg (to prevent conflicts with hadoop yarn) and somehow you were able to pass that check as well.

I know you've installed yarn now, so it might not be possible, but I'd be curious what the result of yarnpkg --version was prior to that.

@KuSh
Copy link
Contributor Author

KuSh commented Oct 8, 2020

I was using the latest package from yarn deb repository (https://dl.yarnpkg.com/debian/ stable main) which seems to be v 1.22.5 ATM.
I removed yarn + node from nodesource.com deb repository to switch to nvm this week and didn't reinstalled yarn after that

Dunno if that helps

@KuSh
Copy link
Contributor Author

KuSh commented Oct 8, 2020

For the record. If I set cli.packageManager to yarn in my ~/.config/gatsby/config.json I can reproduce.
I'll try to make a PR to fix the problem if I can find what is causing that 👍

@laurieontech
Copy link
Contributor

Thanks @KuSh! I think there may have been a false positive when we checked for yarn. I've opened a PR, #27343

@KuSh
Copy link
Contributor Author

KuSh commented Oct 8, 2020

Thanks @laurieontech , I did test your fix, it doesn't work. I think I found the bug and the fix just let me 5 sec to test and push a PR ^^

laurieontech pushed a commit that referenced this issue Oct 8, 2020
Fixes #27338

Steps to reproduce :

1. Uninstall yarn
2. Verify that PackageManager is setted to 'yarn' in config.json
3. Run gatsby-cli new

It failed with

```

 ERROR

Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT

  Error: Command failed with ENOENT: yarnpkg
  spawn yarnpkg ENOENT

  - child_process.js:268 Process.ChildProcess._handle.onexit
    internal/child_process.js:268:19

  - child_process.js:464 onErrorNT
    internal/child_process.js:464:16

  - task_queues.js:80 processTicksAndRejections
    internal/process/task_queues.js:80:21
```
gatsbybot pushed a commit to gatsbyjs/gatsby-starter-default that referenced this issue Oct 8, 2020
Fixes gatsbyjs/gatsby#27338

Steps to reproduce :

1. Uninstall yarn
2. Verify that PackageManager is setted to 'yarn' in config.json
3. Run gatsby-cli new

It failed with

```

 ERROR

Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT

  Error: Command failed with ENOENT: yarnpkg
  spawn yarnpkg ENOENT

  - child_process.js:268 Process.ChildProcess._handle.onexit
    internal/child_process.js:268:19

  - child_process.js:464 onErrorNT
    internal/child_process.js:464:16

  - task_queues.js:80 processTicksAndRejections
    internal/process/task_queues.js:80:21
```
gatsbybot pushed a commit to gatsbyjs/gatsby-starter-notes-theme that referenced this issue Oct 8, 2020
Fixes gatsbyjs/gatsby#27338

Steps to reproduce :

1. Uninstall yarn
2. Verify that PackageManager is setted to 'yarn' in config.json
3. Run gatsby-cli new

It failed with

```

 ERROR

Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT

  Error: Command failed with ENOENT: yarnpkg
  spawn yarnpkg ENOENT

  - child_process.js:268 Process.ChildProcess._handle.onexit
    internal/child_process.js:268:19

  - child_process.js:464 onErrorNT
    internal/child_process.js:464:16

  - task_queues.js:80 processTicksAndRejections
    internal/process/task_queues.js:80:21
```
gatsbybot pushed a commit to gatsbyjs/gatsby-starter-hello-world that referenced this issue Oct 8, 2020
Fixes gatsbyjs/gatsby#27338

Steps to reproduce :

1. Uninstall yarn
2. Verify that PackageManager is setted to 'yarn' in config.json
3. Run gatsby-cli new

It failed with

```

 ERROR

Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT

  Error: Command failed with ENOENT: yarnpkg
  spawn yarnpkg ENOENT

  - child_process.js:268 Process.ChildProcess._handle.onexit
    internal/child_process.js:268:19

  - child_process.js:464 onErrorNT
    internal/child_process.js:464:16

  - task_queues.js:80 processTicksAndRejections
    internal/process/task_queues.js:80:21
```
fumierkm added a commit to fumierkm/gatsbyjs that referenced this issue Nov 27, 2021
Fixes gatsbyjs/gatsby#27338

Steps to reproduce :

1. Uninstall yarn
2. Verify that PackageManager is setted to 'yarn' in config.json
3. Run gatsby-cli new

It failed with

```

 ERROR

Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT

  Error: Command failed with ENOENT: yarnpkg
  spawn yarnpkg ENOENT

  - child_process.js:268 Process.ChildProcess._handle.onexit
    internal/child_process.js:268:19

  - child_process.js:464 onErrorNT
    internal/child_process.js:464:16

  - task_queues.js:80 processTicksAndRejections
    internal/process/task_queues.js:80:21
```
goldenjake pushed a commit to goldenjake/gatsby-starter-default that referenced this issue May 19, 2022
Fixes gatsbyjs/gatsby#27338

Steps to reproduce :

1. Uninstall yarn
2. Verify that PackageManager is setted to 'yarn' in config.json
3. Run gatsby-cli new

It failed with

```

 ERROR

Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT

  Error: Command failed with ENOENT: yarnpkg
  spawn yarnpkg ENOENT

  - child_process.js:268 Process.ChildProcess._handle.onexit
    internal/child_process.js:268:19

  - child_process.js:464 onErrorNT
    internal/child_process.js:464:16

  - task_queues.js:80 processTicksAndRejections
    internal/process/task_queues.js:80:21
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
3 participants