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

Remove deep-freeze-node dependency: the project is no longer installable on mac arm #13631

Closed
Kwadz opened this issue Jan 17, 2021 · 53 comments · Fixed by brave/brave-core#10631

Comments

@Kwadz
Copy link

Kwadz commented Jan 17, 2021

I can't install the project. Steps to reproduce the issue:

git clone git@github.com:brave/brave-browser.git
cd brave-browser
npm install
cd src
rm -rf brave # otherwise error "directory already exists", BTW that should be mentioned in the doc
cd ..
npm run init

And I get:

    fatal: repository 'undefined' does not exist

It seems the function getNPMConfig relies on env vars that are obviously not present on my system. But there is no mention about it in the Brave installation procedure.

What's wrong here?

Just in case, I mention that I'm on macOS 10.14.6 (Mojave).

@Kwadz Kwadz added OS/Android Fixes related to Android browser functionality OS/Desktop labels Jan 17, 2021
@Aragar199
Copy link

I also encountered the same issue. Problem is that the path to the repository url is broken.

There is a string replacement that is making - into _ at https://github.com/brave/brave-browser/blob/master/lib/util.js#L5

So when brave-browser goes looking for brave-core in package.json, it can never find it because the key is changed to brave_core and it ends up undefined

You can change it to brave_core in https://github.com/brave/brave-browser/blob/master/package.json#L38

That fixes it there, but then it breaks in brave-core which has its own getNPMConfig that does not do the same string replacement to change -. So it scans for brave-core but never finds it because it is brave_core now.

You can then change at https://github.com/brave/brave-core/blob/master/build/commands/lib/config.js#L77
brave-core to brave_core so when it scans for the repo url it can find it because it is now brave_core in brave-browser/package.json.

Then change the repo url and branch name to point to the brave-core version that has this change:

Screen Shot 2021-01-19 at 8 45 30 AM

I was able to install using these steps, but it's a patch job and should probably have a real fix instead.

@Aragar199
Copy link

Aragar199 commented Feb 10, 2021

Fix is here https://github.com/brave/brave-browser/pull/14089/files, pending review. I didn't see anything else using that util.getNPMConfig and I was able to remove the string replacement and added a check if the src/brave folder already exists.

@bsclifton
Copy link
Member

bsclifton commented Feb 11, 2021

hmm - I'm not running into any problems here on Windows. If you're seeing this, my first guess would be that you don't have Node LTS installed (we may have problems if you use latest version of Node.js)

The folder is src/brave so there shouldn't be any problem with - or _

cc: @bridiver in case I missed something obvious

@ShivanKaul
Copy link
Collaborator

FWIW, I ran into the same issue on a Mac Pro 10.15.7 (+ the issue of an installation failing requiring me to go and explicitly rm -rf src/brave)

@bridiver
Copy link
Contributor

@Kwadz npm run init only tries to create src/brave if the src/brave/.git doesn't exist. If these are the only steps you have done

git clone git@github.com:brave/brave-browser.git
cd brave-browser
npm install

then src/brave would not exist

@Kwadz
Copy link
Author

Kwadz commented Feb 20, 2021

Thanks @bridiver, in that case I think this section of the documentation should be updated:

git clone git@github.com:brave/brave-browser.git
cd brave-browser
npm install

# this takes 30-45 minutes to run
# the Chromium source is downloaded which has a large history
npm run init

It does not even match with this section:

# root where project is cloned
cd ~/brave-browser/
git remote add bsclifton git@github.com:bsclifton/brave-browser.git
git fetch bsclifton
# root for the `brave-core` repo
cd src/brave
git remote add bsclifton git@github.com:bsclifton/brave-core.git
git fetch bsclifton

I think the process in the documentation should be consistent and unified.

this takes 30-45 minutes to run

Anyway, if this can be avoided it's beneficial for everyone.

@bridiver
Copy link
Contributor

bridiver commented Feb 20, 2021 via email

@bsclifton
Copy link
Member

bsclifton commented Feb 21, 2021

@Kwadz that part can look confusing, but it's correct. I believe I understand the disconnect

Basically, all you need to do is run npm run init and src/brave will be setup for you.

However- if you're actively making changes in a fork, you'll need to add YOUR remote to the src/brave repo. Only Brave employees have access to push to brave/brave-core - so you'll need to push to your fork if you're hoping to submit a pull request. I hope that makes sense. If you're not needing to submit a PR, you can skip the Making changes section

By default, when running npm run init it'll check out the branch specified in package.json (which will be master on origin). You can then check a new branch - or if you already have a branch, you can run the steps under Keeping your fork up to sync (which is a bad title, whoops) to bring your fork up to date

There may be some work you need to do if your fork's branch diverges significantly from upstream (origin) or if you have patches. In those cases you may need to edit the package.json specifically to have it point at your fork instead of brave-core (so that it uses your fork for init). Please let me know if that doesn't make sense

@bridiver
Copy link
Contributor

@bsclifton I reopened because there is still an outstanding issue with the npm config

@bridiver
Copy link
Contributor

@Aragar199 I'm not able to reproduce the issue. Can you provide info on node, npm and OS version. #14089 breaks the install for me.

@Kwadz
Copy link
Author

Kwadz commented Feb 21, 2021

I think the documentation should be clarified.

However- if you're actively making changes in a fork, you'll need to add YOUR remote to the src/brave repo. Only Brave employees have access to push to brave/brave-core - so you'll need to push to your fork if you're hoping to submit a pull request. I hope that makes sense. If you're not needing to submit a PR, you can skip the Making changes section

You seem to tell the section Clone and initialize the repo is for Brave employees and the section Making change for contributors.

If there is a different procedure for Brave employees and a for contributors, that should be mentioned.

Basically, all you need to do is run npm run init and src/brave will be setup for you.

This npm run init is not even mentioned in the section Making change. I think all the steps of the procedure should be mentioned in this section, or at least with a link to the proper section to build the project.

My two cents about the doc:

For example in the section Clone and initialize the repo, "Clone and initialize the repo" for what? It's not clear that part is not for contributing, may be we should mention something not to confuse with this section.

Also, the section Making change does not mention anything about npm run init. So, it's not complete and the reader think we should go to Clone and initialize the repo to continue the setup.

I'd also update in Making change:

Once you've cloned the repo to your computer, you're ready to start making edits!

to

Once you've cloned your fork to your computer, you're ready to start making edits!

Hope my new eyes can help to clarify the doc and therefore make it easier for new contributors.

@Aragar199
Copy link

Aragar199 commented Feb 22, 2021

@bridiver Thanks for following up on this. Before I submitted the PR to fix, I checked it on my Windows laptop as well and saw the same issue with the repo url showing up unidentified. However, I just checked the master branch on Mac and Windows and can no longer reproduce. I don't have anything to follow up on if @Kwadz is also no longer seeing an issue.

@bsclifton
Copy link
Member

bsclifton commented Feb 22, 2021

@Kwadz there's only a different procedure (RE: branches) if you make edits to the code and would like to push those upstream. Everyone has read access to the repo, but creating branches on the remote and pushing to the remote is limited to employees. Thanks for the feedback though - definitely nice to have a fresh perspective on this 😄

@bridiver
Copy link
Contributor

bridiver commented Feb 22, 2021 via email

@Kwadz
Copy link
Author

Kwadz commented Feb 22, 2021

creating branches on the remote and pushing to the remote is limited to employees.

@bsclifton, you already explained it, thanks but this is not the point. The problem, IMHO, is the contributor guide is not clear in addition to be incomplete. I guess you didn't see what I wanted to point out. I think it's important for a project installation not to be difficult for new contributors. Anyway, I can create a specific issue about this, not to pollute this one with too much extrapolation 🙂

@Aragar199, about the Clone and initialize the repo section, I tested again the following:

$ git clone git@github.com:brave/brave-browser.git
Cloning into 'brave-browser'...
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 33841 (delta 10), reused 15 (delta 7), pack-reused 33818
Receiving objects: 100% (33841/33841), 15.34 MiB | 1001.00 KiB/s, done.
Resolving deltas: 100% (23393/23393), done.
$ cd brave-browser
$ npm install

added 28 packages, and audited 28 packages in 3s

found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 7.0.15 -> 7.5.4
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.5.4
npm notice Run npm install -g npm@7.5.4 to update!
npm notice
$ cd src
$ rm -rf brave # otherwise error "directory already exists", BTW that should be mentioned in the doc
$ cd ..
$ npm run init

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

Performing initial checkout of brave-core
Cloning brave-core [undefined] into /Users/myuser/Code/test/brave-browser/src/brave...
------------------------------------------------------------------------------------------------------------------------------------------------------
/Users/myuser/Code/test/brave-browser/src/brave
> git clone  .

fatal: repository 'undefined' does not exist

npm ERR! code 1
npm ERR! path /Users/myuser/Code/test/brave-browser
npm ERR! command failed
npm ERR! command sh -c node ./scripts/init.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2021-02-22T10_43_01_075Z-debug.log

I also tested with exactly the steps from the doc (without removing the brave dir):

$ git clone git@github.com:brave/brave-browser.git
Cloning into 'brave-browser'...
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 33841 (delta 10), reused 15 (delta 7), pack-reused 33818
Receiving objects: 100% (33841/33841), 15.34 MiB | 765.00 KiB/s, done.
Resolving deltas: 100% (23393/23393), done.
$ cd brave-browser
$ npm install

added 28 packages, and audited 28 packages in 2s

found 0 vulnerabilities
$ npm run init

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

Performing initial checkout of brave-core
Cloning brave-core [undefined] into /Users/myuser/Code/test/brave-browser/src/brave...
------------------------------------------------------------------------------------------------------------------------------------------------------
/Users/myuser/Code/test/brave-browser/src/brave
> git clone  .

fatal: repository 'undefined' does not exist

npm ERR! code 1
npm ERR! path /Users/myuser/Code/test/brave-browser
npm ERR! command failed
npm ERR! command sh -c node ./scripts/init.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2021-02-22T11_50_06_743Z-debug.log

@Aragar199
Copy link

Thank you for confirming @Kwadz I just checked and was able to reproduce again. Realized that it was skipping trying to clone in to the folder since it checks if the .git file is already present in src/brave. I changed the name of the folder to a random one brave23 so that it would try to clone in to a new directory and got the error again:

$ npm run init

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

Performing initial checkout of brave-core
Cloning brave-core [undefined] into /Users/myuser/brave-browser/src/brave23...
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/Users/myuser/brave-browser/src/brave23
> git clone  .

fatal: repository 'undefined' does not exist

npm ERR! code 1
npm ERR! path /Users/myuser/brave-browser
npm ERR! command failed
npm ERR! command sh -c node ./scripts/init.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2021-02-22T20_32_47_994Z-debug.log

@Aragar199
Copy link

@bridiver -
macOS Catalina Version 10.15.7
node v15.8.0
npm 7.5.0

@bsclifton
Copy link
Member

bsclifton commented Feb 22, 2021

@Aragar199 you're going to want to install the LTS version of Node.js, which should be 14.x
LTS requirement captured here:
https://github.com/brave/brave-browser/wiki/macOS-Development-Environment

@Aragar199
Copy link

Yep, that's it! I installed node 12 and it works fine. Still throws an error if the directory src/brave/ already exists due to a failed installation but it's much more verbose so I'm inclined to just nuke my PR and call it. My bad, @bsclifton, you mentioned this near the beginning of this thread!

@bridiver
Copy link
Contributor

bridiver commented Feb 22, 2021

@bsclifton the problem is likely the npm version because I believe that is what converts the config to env vars, but presumably downgrading to node 14 will also take care of npm. There must be a change in the format when they are converted to env vars

@Aragar199
Copy link

node v12.20.2
npm 6.14.11

@bridiver
Copy link
Contributor

yep, npm 6.x should work correctly because that is what I have locally

@Kwadz
Copy link
Author

Kwadz commented Feb 22, 2021

Tested with node v14.15.5 here (latest LTS), and it works. @bsclifton was right from the beginning and I also missed it 🤦‍♂️

Thank you guys!

@CatsMeow492
Copy link

CatsMeow492 commented Oct 13, 2021 via email

@himansh-gjr
Copy link

Hey I have followed the same instruction that @CatsMeow492 gave, but I am getting this error.

Screenshot 2021-10-18 at 9 11 13 PM

I am using macbook air M1 ( macOS version 11.5.2)

@bridiver
Copy link
Contributor

bridiver commented Oct 18, 2021

@himansh-gjr brew might not have arm builds for everything. I suggest trying nvm. Otherwise you can download it from nodejs.org or I think brew has an option to build locally instead of downloading a prebuilt version.

@himansh-gjr
Copy link

@CatsMeow492 @bridiver yes I have tried this with nvm with the required version of both npm and node

Screenshot 2021-10-20 at 1 34 06 AM

But getting this error

Screenshot 2021-10-20 at 12 23
18 AM

The process I did setup the project

forked and cloned the project

git clone <myForkURL>
cd brave-browser
npm install

installed the required version of node and npm via nvm

nvm install 12
npm install npm@6.14.11 -g

Next

npm run init

and here comes the error !

@bridiver
Copy link
Contributor

cc @petemill ^^

@petemill
Copy link
Member

@petemill
Copy link
Member

That package seems abandoned - we only seem to be using it in a couple tests where we can now use a different pattern. @himansh-gjr as a quick fix you could remove the deep-freeze-node entry from src/brave/package.json and re-run npm install. The only thing that will not work is some unit tests.

@petemill petemill self-assigned this Oct 20, 2021
@petemill petemill changed the title The project is no longer installable Remove deep-freeze-node dependency: the project is no longer installable on mac arm Oct 20, 2021
@bridiver
Copy link
Contributor

also @himansh-gjr just fyi we don't yet have official support for building on arm yet (arm builds are currently done on x64 just like for other platforms), but it sounds like @petemill may have it working soon.

@himansh-gjr
Copy link

thanks @petemill but I think that quick fix does't seems to work
still getting an error but this time a different one
Screenshot 2021-10-22 at 6 41 18 AM

My log file
Screenshot 2021-10-22 at 6 41 03 AM

@bridiver
Copy link
Contributor

bridiver commented Oct 22, 2021 via email

@himansh-gjr
Copy link

I re-run npm run init after removing deep-freeze-node

@himansh-gjr
Copy link

himansh-gjr commented Oct 28, 2021

I did everything from scratch again by forking both the repos brave-core and brave-browser
Did the required changes in my forked brave-core that is to remove deep-freeze-node and all the changes @petemill did in this PR
although that resolves this previous error

Hey I have followed the same instruction that @CatsMeow492 gave, but I am getting this error.

Screenshot 2021-10-18 at 9 11 13 PM

I am using macbook air M1 ( macOS version 11.5.2)

But then I still got this error, just not able to understand why this error occurred , is there any kind of pre- installation that I am missing ??

thanks @petemill but I think that quick fix does't seems to work still getting an error but this time a different one Screenshot 2021-10-22 at 6 41 18 AM

My log file Screenshot 2021-10-22 at 6 41 03 AM

@bridiver
Copy link
Contributor

bridiver commented Nov 1, 2021

@himansh-gjr see brave/brave-core#10795
That patch is pulled from upstream master (not in the current chromium version) so this is still an upstream issue

@mihaiplesa
Copy link
Contributor

@himansh-gjr how is it looking now?

@MaazBinMusa
Copy link

@Aragar199 @bsclifton I still got the issue

Windows 10 Education
Node v16.13.0 (LTS)
Npm 8.1.3

I removed the replace - with _ line in utils and have starting the init.

@bsclifton
Copy link
Member

For folks running into this issue with newer NPM - I created an issue and am tracking here (subscribe for updates):
#19398

@mohanamisra
Copy link

@Kwadz npm run init only tries to create src/brave if the src/brave/.git doesn't exist. If these are the only steps you have done

git clone git@github.com:brave/brave-browser.git
cd brave-browser
npm install

then src/brave would not exist

In that case, what is the correct way to go about trying to set up the project locally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment