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

Adding a script to package.json called "install" creates an infinite loop #1227

Closed
mnpenner opened this issue Oct 19, 2016 · 3 comments
Closed

Comments

@mnpenner
Copy link

Do you want to request a feature or report a bug?

Bug

If the current behavior is a bug, please provide the steps to reproduce.

Add this to your package.json:

  "scripts": {
    "install": "yarn install --ignore-optional",
  },

Run

yarn install

What is the current behavior?

> yarn install
yarn install v0.16.0
success Already up-to-date.
$ yarn install --ignore-optional
yarn install v0.16.0
success Already up-to-date.
$ yarn install --ignore-optional
yarn install v0.16.0
success Already up-to-date.
$ yarn install --ignore-optional
yarn install v0.16.0
success Already up-to-date.
$ yarn install --ignore-optional
Terminate batch job (Y/N)?
yarn install v0.16.0
Terminate batch job (Y/N)?
^C

What is the expected behavior?

No infinite loop. Perhaps copy what Composer does: emits this warning:

A script named install would override a Composer command and has been skipped

And then carries on with the built-in command.

Please mention your node.js, yarn and operating system version.

Node: v6.3.1
Yarn: 0.16.0
OS: Win10 Anniversary

@jamiebuilds
Copy link
Contributor

Moving to #1374

@sebmck
Copy link
Contributor

sebmck commented Oct 24, 2016

Honestly this seems like intentional behaviour, I don't think we should do anything explicitly to detect a yarn install command since we don't know the location of the original binary and any detection will be sloppy. install is a valid lifecycle script hook and we're executing it correctly, there's nothing being ignored.

@mnpenner
Copy link
Author

mnpenner commented Oct 25, 2016

@kittens I was really confused by your response until I googled "npm lifecycle scripts" and came across this.

I actually didn't know that install was a special thing that was supposed to run after yarn/npm install -- I thought it was just a regular script. I didn't know it would be triggered automatically after a yarn install; I just wanted to run it manually via yarn run install.

In that case, this does make perfect sense. Sorry @wyze and @thejameskyle -- thank you for taking my issue report seriously, but I think @kittens is actually right here. This was due to my own misunderstanding. I don't think you need to try to detect this situation.

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Oct 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants