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

Can't clone and initialize brave-browser repo with NPM >= 8 #19993

Closed
mariospr opened this issue Dec 8, 2021 · 1 comment · Fixed by #19994
Closed

Can't clone and initialize brave-browser repo with NPM >= 8 #19993

mariospr opened this issue Dec 8, 2021 · 1 comment · Fixed by #19994

Comments

@mariospr
Copy link
Contributor

mariospr commented Dec 8, 2021

Description

If you have NPM version 8 or greater, chances are that you'll hit an error like this when trying to initialize the repository for the first time, following the instructions from the wiki:

mario@hostname:~ $ git clone git@github.com:brave/brave-browser.git
Cloning into 'brave-browser'...
remote: Enumerating objects: 43226, done.
remote: Counting objects: 100% (48/48), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 43226 (delta 32), reused 31 (delta 17), pack-reused 43178
Receiving objects: 100% (43226/43226), 16.51 MiB | 5.52 MiB/s, done.
Resolving deltas: 100% (29950/29950), done.

mario@hostname:~ $ cd brave-browser
npm install

added 28 packages, and audited 29 packages in 2s

7 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

mario@hostname:~/brave-browser [git:master]$ npm run init

> brave@1.35.17 init
> node ./scripts/init.js

Performing initial checkout of brave-core
Cloning brave-core [undefined] into /home/mario/brave-browser/src/brave...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/mario/brave-browser/src/brave
> git clone  .

fatal: repository 'undefined' does not exist

I've done some investigation and, after finding a couple of bugs related to that, it seems that this intented behaviour from NPM >=6, as explained in RFC 21: https://github.com/npm/rfcs/blob/main/implemented/0021-reduce-lifecycle-script-environment.md

Turns out also that this is not yet an issue on NPM 7 because npm_package_config_* environment variables are still available for transitional purposes, but in NPM 8 (or at least from 8.1.0, the one I have) those variables are no longer availables, causing the error above.

Steps to Reproduce

  1. Ensure you have NPM >= 8 installed
  2. Try to initialize the brave-browser repo for the first time as explained in the wiki.

Actual result:

The npm run init process fails as described above.

Expected result:

The npm run init process succeeds and brave-browser, chromium and brave-core repositories are properly set up.

Reproduces how often:

Always

@mariospr
Copy link
Contributor Author

mariospr commented Dec 8, 2021

For the sake of completeness, this is what you should see when running npm run init instead of the failure above:

mario@hostname:~ $ npm run init

> brave@1.35.17 init
> node ./scripts/init.js

Performing initial checkout of brave-core
Cloning brave-core [master] into /home/mario/brave-browser/src/brave...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/mario/brave-browser/src/brave
> git clone https://github.com/brave/brave-core.git .
[...]

mariospr added a commit that referenced this issue Dec 8, 2021
From NPM >=6 and as explained in RFC 21[1], npm is removing the
npm_config_* and npm_package_* environment variables from the
context of lifecycle scripts and so, while some of them such
as the npm_package_config_* ones will still work on NPM 7, we
need to adapt to this change or it won't be able to setup the
repository from NPM 8 on.

This change does a small change to make sure that we work on
every possible situation, relying on those environment variables
if still using NPM <= 7, or simply reading the package.json file
as a dictionary when using NPM >= 8.

[1] https://github.com/npm/rfcs/blob/main/implemented/0021-reduce-lifecycle-script-environment.md

Resolves #19993
mariospr added a commit that referenced this issue Dec 8, 2021
From NPM >=6 and as explained in RFC 21[1], npm is removing the
npm_config_* and npm_package_* environment variables from the
context of lifecycle scripts and so, while some of them such
as the npm_package_config_* ones will still work on NPM 7, we
need to adapt to this change or it won't be able to setup the
repository from NPM 8 on.

This change does a small change to make sure that we work on
every possible situation, relying on those environment variables
if still using NPM <= 7, or simply reading the package.json file
as a dictionary when using NPM >= 8.

[1] https://github.com/npm/rfcs/blob/main/implemented/0021-reduce-lifecycle-script-environment.md

Resolves #19993
mariospr added a commit that referenced this issue Dec 9, 2021
Fix npm run init to work when using NPM >= 8
@mariospr mariospr added this to the 1.35.x - Nightly milestone Dec 12, 2021
mariospr added a commit that referenced this issue Jan 11, 2022
Fix npm run init to work when using NPM >= 8
kjozwiak added a commit that referenced this issue Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants