question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lerna bootstrap fails due to concurrency (with npm)

See original GitHub issue

The latest RC version fails when running lerna bootstrap. I’m not sure when it was introduced, though, because only today builds started failing on Travis while RC3 was released 8 days ago. So, I may be actually running into two separate issues. Both turned to have the same solution, though, switching off concurrency.

The issue, at least now, can be reproduced in the following way:

p@m /workspace/test> git clone git@github.com:ckeditor/ckeditor5.git
Cloning into 'ckeditor5'...
remote: Counting objects: 6484, done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 6484 (delta 32), reused 0 (delta 0), pack-reused 6407
Receiving objects: 100% (6484/6484), 1.16 MiB | 336.00 KiB/s, done.
Resolving deltas: 100% (3672/3672), done.
p@m /workspace/test> cd ckeditor5/
(master cbe80fd) p@m /workspace/test/ckeditor5> lerna bootstrap
Lerna v2.0.0-rc.3
Bootstrapping 1 packages
Preinstalling packages
Installing external dependencies
Installing hoisted dependencies into root
Pruning hoisted dependencies
FileSystemUtilities.rename    ("./package.json", "./package.json.lerna_backup")
Error: ENOENT: no such file or directory, rename '/workspace/test/ckeditor5/package.json' -> '/workspace/test/ckeditor5/package.json.lerna_backup'
    at Error (native)
NpmUtilities.installInDir     (".", ["guppy-pre-commit@^0.4.0"], {})
Error: ENOENT: no such file or directory, rename '/workspace/test/ckeditor5/package.json' -> '/workspace/test/ckeditor5/package.json.lerna_backup'
    at Error (native)
Errored while running BootstrapCommand.execute
Error: ENOENT: no such file or directory, rename '/workspace/test/ckeditor5/package.json' -> '/workspace/test/ckeditor5/package.json.lerna_backup'
    at Error (native)

When I try with --concurrency=1 the issue doesn’t seem to appear:

(master cbe80fd) p@m /workspace/test/ckeditor5> lerna bootstrap --concurrency=1
Lerna v2.0.0-rc.3
Bootstrapping 1 packages
Preinstalling packages
Installing external dependencies
Installing hoisted dependencies into root
Pruning hoisted dependencies
Symlinking packages and binaries
Postinstalling packages
Prepublishing packages
Successfully bootstrapped 1 packages.

It also proved to help with a bit more complicated situation I had on Travis: https://travis-ci.org/ckeditor/ckeditor5/builds/226105896. It worked well after disabling concurrency: https://travis-ci.org/ckeditor/ckeditor5/builds/226101027.

I can see that similar issues were already reported: https://github.com/lerna/lerna/issues/397 and https://github.com/lerna/lerna/issues/616. However, this may be the first scenario in which the issue can be easily reproduced.

Your Environment

Executable Version
lerna --version 2.0.0-rc.3
npm --version 4.0.3
node --version 6.9.1
OS Version
macOS Sierra 10.12.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
Reinmarcommented, May 17, 2017

Unfortunately, I didn’t save it as I went straight to npm-debug.log (which is usually more helpful so Lerna could mention that to the user). In the console, as I recall, there was just an info about crashing processes.

I know that the npm log indicates that some JSON was missing/invalid, but I’ve seen the same error many times in the past. Usually, a second lerna bootstrap run would help with that. So, my assumption now, when I discovered that lerna bootstrap --concurrency=1 helps even more consistently is that:

  • one Lerna process starts installing package X,
  • a second process tries to install the same package at the same time,
  • there’s some mutex failure and the second process thinks that the package is already available in npm’s cache (/Users/me/.npm) but it isn’t or is temporarily invalid at that moment,
  • the second process crashes while trying to read this file.

And why does it work when running lerna bootstrap for the second time (even concurrently)? Because the cache is already hot and all JSONs are usually already unpacked there.

Anyhow reasonable?

3reactions
Brantroncommented, May 2, 2018

We finally have a reliable workaround!!!

install: travis_retry make ci-install

where the makefile does

ci-install:
	yarn;
	lerna bootstrap --mutex file:/tmp/.yarn-mutex --concurrency=1;

The key is travis_retry where it will attempt the installation 3 times. So far we have 100% success.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lerna bootstrap fails due to concurrency (with npm)
Lerna bootstrap fails due to concurrency (with npm )
Read more >
Troubleshooting | Lerna
If lerna bootstrap is failing because you have repositories on a private server make sure you are including that registry. Example: lerna bootstrap...
Read more >
@lerna/global-options - npm
--concurrency. How many threads to use when Lerna parallelizes the tasks (defaults to count of logical CPU cores).
Read more >
Create a monorepo with Lerna | by Damian Cyrus - Medium
The command lerna bootstrap installs all dependencies within all packages below the package folder. We will use the default behaviour and ...
Read more >
Untitled
The two primary commands in Lerna are `lerna bootstrap` and `lerna publish`. ... `npm install` all external dependencies of each package. 2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found