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

Bootstrap does not execute the dependencies' script since 3.9.0 #1855

Closed
Kivol opened this issue Jan 8, 2019 · 10 comments
Closed

Bootstrap does not execute the dependencies' script since 3.9.0 #1855

Kivol opened this issue Jan 8, 2019 · 10 comments

Comments

@Kivol
Copy link

Kivol commented Jan 8, 2019

Looks like lerna bootstrap command does not execute the dependencies' script since 3.9.0.

To reproduce, you may set a monorepo like:
[/package.json]

{
  "name": "root",
  "private": true,
  "devDependencies": {
    "lerna": "3.9.0"
  }
}

[/packages/package1/package.json]

{
	"name": "@test/package1",
	"dependencies": {
		"puppeteer": "1.11.0"
	}
}

...and npm i and npx lerna init.

Expected Behavior

The packages with install script (like puppeteer) has to execute it during installation. For example for puppeteer, it downloads chromium and saves it to the directory of /node_modules/puppeteer/.local-chromium, which is the sign that install script is executed.

Current Behavior

It doesn't seem to execute install script of each dependencies.

Steps to Reproduce (for bugs)

  1. Command npx lerna bootstrap in monorepo root, regardless of using --hoist or --no-ci.
lerna.json

{
  "packages": [
    "packages/*"
  ],
  "version": "0.0.0"
}

Your Environment

Executable Version
lerna --version 3.9.0
npm --version 6.1.0
yarn --version N/A
node --version 10.5.0
OS Version
Ubuntu 18.04
@jsnajdr
Copy link

jsnajdr commented Jan 8, 2019

We're experiencing a similar issue in https://github.com/automattic/wp-calypso -- the project uses node-sass, which downloads a binary into a vendor subdirectory in an install script. When running lerna bootstrap, the download is no longer performed and node-sass is in broken state.

@jsnajdr
Copy link

jsnajdr commented Jan 8, 2019

The problem seems to be the --ignore-scripts param for NPM added in this patch: 929ae22#diff-f132f0ed53f33747644da180a09d15baR96

That's OK for the packages managed by Lerna, because the this.runLifecycleInPackages calls will run the lifecycle scripts manually.

But it's not OK for the packages installed with this.installExternalDependencies. These are installed with the --ignore-scripts param, too, but nobody will run the lifecycles for them.

The issue is made much more difficult to work around by the fact that the buggy code is in the @lerna/bootstrap@3.9.0 package. Trying to run the older version:

npm lerna@3.8.5 bootstrap

doesn't work. lerna@3.8.5 has dependency @lerna/bootstrap: ^3.8.5, which still gets resolved to the 3.9.0 version of the package. I don't know how to downgrade to the older version.

@Zeetah
Copy link

Zeetah commented Jan 8, 2019

Can someone please address this as of this is breaking all versions of lerna hence they use caret in the dependencies to @lerna/bootstrap which will always install the latest version of @lerna/bootstrap.

@eemeli
Copy link

eemeli commented Jan 8, 2019

For me this is showing up as lerna bootstrap --hoist continuously calling itself.

Relevant parts of package.json:

{
    "scripts": {
        "prepare": "lerna bootstrap --hoist"
    },
    "devDependencies": {
        "lerna": "^3.6.0",
        "node-sass": "^4.9.2"
    }
}

Lerna's console prints from Jenkins build:

+ npm install

> node-sass@4.11.0 install /home/jenkins/workspace/build/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://mirror/sass/node-sass/download/v4.11.0/linux-x64-57_binding.node
Download complete
Binary saved to /home/jenkins/workspace/build/node_modules/node-sass/vendor/linux-x64-57/binding.node
Caching binary to /ciop/tools/nodejs/node-v8.9.1-linux-x64/lib/node_modules/npm/cache/node-sass/4.11.0/linux-x64-57_binding.node

> node-sass@4.11.0 postinstall /home/jenkins/workspace/build/node_modules/node-sass
> node scripts/build.js

Binary found at /home/jenkins/workspace/build/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine

> app@ prepare /home/jenkins/workspace/build
> lerna bootstrap --hoist

lerna notice cli v3.9.0
lerna info ci enabled
lerna info Bootstrapping 20 packages
lerna info Installing external dependencies
lerna info hoist Installing hoisted dependencies into root
lerna info hoist Pruning hoisted dependencies
lerna info hoist Finished pruning hoisted dependencies
lerna info hoist Finished bootstrapping root
lerna info Symlinking packages and binaries
lerna info lifecycle app@undefined~prepare: app@undefined

> app@undefined prepare /home/jenkins/workspace/build
> lerna bootstrap --hoist

lerna notice cli v3.9.0
...

A build from yesterday with the same node-sass version but lerna 3.8.5 succeeded.

@ollisal
Copy link

ollisal commented Jan 8, 2019

Well you can do this still, in your package.json:

  "devDependencies": {
    // ...
    "lerna": "3.8.5",
    "@lerna/bootstrap": "3.8.5"
    // ...
  }

i.e. just add a direct dependency to the still-working @lerna/bootstrap version, and it'll get installed by npm to a place where the main lerna package will use it, as it matches its ^ version requirement just fine.

@coutin
Copy link

coutin commented Jan 8, 2019

Well you can do this still, in your package.json:

  "devDependencies": {
    // ...
    "lerna": "3.8.5",
    "@lerna/bootstrap": "3.8.5"
    // ...
  }

i.e. just add a direct dependency to the still-working @lerna/bootstrap version, and it'll get installed by npm to a place where the main lerna package will use it, as it matches its ^ version requirement just fine.

This might work for you project, but this is actually breaking everything as soon as you have lerna installed globally (Docker image, locally, etc .. )

@evocateur
Copy link
Member

Yeah, sorry about that, everyone. I thought I was being clever. Reverting it now.

Narrator: He was not.

@evocateur
Copy link
Member

https://github.com/lerna/lerna/releases/tag/v3.9.1

@oprearocks
Copy link

Thank you for your work! Had a rough time yesterday debugging this but never thought about looking through Lerna's source.

@lock
Copy link

lock bot commented Apr 9, 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.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants