Closed
Description
Expected Behavior
I want to put "lerna bootstrap" in the "postinstall" script so that people who don't realise that lerna has a boostrap step can just run "yarn" and have everything set up for them.
Current Behavior
It hangs for ever on "lerna bootstrap". If I remove the "postinstall" step and run yarn
and lerna bootstrap
as separate steps, they each complete in a couple of seconds.
Steps to Reproduce (for bugs)
- clone https://github.com/pugjs/pug
- open
package.json
- rename the "bootstrap" step to "postinstall"
- run
yarn
lerna.json
{
"lerna": "2.9.0",
"packages": ["packages/*"],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "independent",
"registry": "https://registry.npmjs.org/"
}
lerna-debug.log
after a few minutes, it was still running and no log had appeared
package.json
{
"name": "pug-monorepo",
"private": true,
"devDependencies": {
"coveralls": "^2.11.2",
"jest": "^18.1.0",
"lerna": "2.9.0",
"prettier": "^1.3.1"
},
"repository": {
"type": "git",
"url": "https://github.com/pugjs/pug.git"
},
"scripts": {
"postinstall": "lerna bootstrap",
"clean": "lerna clean",
"release": "lerna publish",
"pretest": "lerna run pretest",
"test": "jest",
"coverage": "jest --coverage",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
"watch": "jest --watch"
},
"jest": {
"testEnvironment": "node",
"snapshotSerializers": [
"./scripts/filename-serializer.js",
"./scripts/prettier-javascript-serializer.js"
]
},
"license": "MIT",
"workspaces": ["packages/*"]
}
Context
People have to know to run yarn bootstrap
after installing.
Your Environment
Executable | Version |
---|---|
lerna --version |
2.9.0 |
npm --version |
5.6.0 |
yarn --version |
1.3.2 |
node --version |
v8.9.4 |
OS | Version |
---|---|
macOS High Sierra | 10.13.3 |
Activity
evocateur commentedon Mar 6, 2018
lerna bootstrap
when you're using Yarn workspaces is literally redundant? Alllerna bootstrap --npm-client yarn --use-workspaces
(CLI equivalent of your lerna.json config) does is callyarn install
in the root. With apostinstall
that callslerna bootstrap
again, it's just going further down the infinitely recursive rabbit-hole.Should we throw an error when people try
lerna bootstrap --npm-client yarn --use-workspaces
, telling them "just use yarn"?ForbesLindesay commentedon Mar 7, 2018
Yes, that would be a big improvement. It would also be good to add something to the readme along with the bits on setting up yarn workspaces.
davidhouweling commentedon Mar 12, 2018
I just tried it but it doesn't look like it resolves sibling packages. This is evident when you do testing for example.
davidhouweling commentedon Mar 13, 2018
So after a bit more experimenting and searching other issues, I had to run the prepublish and prepare scripts of each package...
evocateur commentedon Mar 13, 2018
That sounds like a yarn workspaces problem, then. Lerna is literally doing nothing special when you run bootstrap with workspaces enabled.
davidhouweling commentedon Mar 13, 2018
@evocateur I think there is a difference of opinion there. From the yarn blog itself:
Based on this, I believe https://github.com/lerna/lerna/blob/master/commands/bootstrap/index.js#L90 should also execute https://github.com/lerna/lerna/blob/master/commands/bootstrap/index.js#L95-L104
evocateur commentedon Mar 13, 2018
Literally no context, example, etc etc etc. What "it" were you referring to?
#899 (written by one of the yarn maintainers) disagrees with you.
Bootstrap has nothing at all to do with publishing. Lifecycles like
prepublish
,prepare
, etc are all run by the npm client doing the publishing, notlerna
(we only run a syntheticversion
lifecycle). If you're usingyarn
to bootstrap and publish, that's onyarn
to fix their shit.npm
does perfectly fine withlerna publish
's responsibilities.If
lerna
is callingyarn
incorrectly, that's something we can fix. So far I have seen no evidence of this, however.davidhouweling commentedon Mar 14, 2018
Thanks for the response and I am sorry I was a bit vague with my first comment. "it' being using workspaces as directed by the blog post and lerna.
After a bit of digging on the yarn issues side, it at least is an issue on their end that is tracked as well: yarnpkg/yarn#3911
For now, the work around as mentioned is to use
lerna run prepublish && lerna run prepare
but yes, I agree that it does not require work on lerna side but at yarn side.Hopefully your comments and mine here for now will help with others who approach this as well.
stale commentedon Dec 27, 2018
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
build: remove lerna bootstrap postinstall
evocateur commentedon Jan 2, 2019
Closing as a duplicate of #1125
lock commentedon Apr 2, 2019
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.