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

Ship homebrew config out of the box #252

Closed
castrojo opened this issue Jun 1, 2023 · 13 comments · Fixed by #346
Closed

Ship homebrew config out of the box #252

castrojo opened this issue Jun 1, 2023 · 13 comments · Fixed by #346
Assignees
Labels
dx Developer Experience Image specific help wanted Keep Bluefin alive, dive in!

Comments

@castrojo
Copy link
Member

castrojo commented Jun 1, 2023

I'd like to ship a working homebrew config for -dx so people who know homebrew can just use it. Installing it works and I was able to install some small tools but we may need to adjust the prefix, when running homebrew doctor.

Warning: Your Homebrew's prefix is not /home/linuxbrew/.linuxbrew.

Detailed instructions: https://docs.brew.sh/Homebrew-on-Linux

@castrojo castrojo added the help wanted Keep Bluefin alive, dive in! label Jun 1, 2023
@castrojo castrojo changed the title Add a homebrew shortcut for just Ship homebrew config out of the box Jun 7, 2023
@castrojo
Copy link
Member Author

castrojo commented Jun 7, 2023

All the deps you need are on the -dx image now(ish).

@marcoceppi
Copy link
Contributor

Some notes for this. An upstream change is needed for homebrew in the bin/brew script. It finds where homebrew is installed by checking where the current bin/brew script is running - that's typically a symlink to /home/linuxbrew/.linuxbrew/Homebrew/bin/brew (where the file is in /home/linuxbrew/.linuxbrew/bin/brew. Since /home on silverblue (and by extension almost all ublue images) is symlinked to /var/home it resolves the HOMEBREW_CELLAR, HOMEBREW_PREFIX, etc to /var/home/linuxbrew/.linuxbrew which homebrew detects is not /home/linuxbrew/.linuxbrew (though, it reality it is) and causes homebrew to re-compile all formulas instead of pouring from the pre-compiled bottles. To get around this, there are a few strategic areas in the bin/brew where checking if we're on linux and that /home is a symlink to the HOMEBREW_REPOSITORY path it's calculated to swap to that expected default path. If a patch for upstream can't be accepted we may need to ship our own bin/brew shim in a place that takes precendence over the one from homebrew in path, with ours short-circuiting what bin/brew does and then sources the Hombrew/brew.sh which is the actual command runner

@castrojo castrojo added the dx Developer Experience Image specific label Jun 23, 2023
@osalbahr
Copy link

osalbahr commented Jun 30, 2023

Related discussion at Homebrew: brew on symlinked home #1282

@osalbahr
Copy link

osalbahr commented Jul 2, 2023

I’ll see what I can do. Can I be added as an assignee?

@osalbahr
Copy link

osalbahr commented Jul 3, 2023

All the deps you need are on the -dx image now(ish).

What are “deps” here?

@castrojo
Copy link
Member Author

castrojo commented Jul 3, 2023

@osalbahr
Copy link

osalbahr commented Jul 4, 2023

https://github.com/ublue-os/bluefin/pull/261/files

Oh, are you adding the packages in groupinstall 'Development Tools' and procps-ng curl file git? That would be nice because then all packages that Homebrew thinks should be installed from source should theoretically all successfully do so (well, if gcc works #<insert-issue-tracker>). But I don't think we need anything past what's already in Fedora to get brew to work for end user operations (brew install <> pulls bottles aka precompiled binaries).

So far it doesn't seem that a bin/brew shim would suffice but I'd need to dig deeper into how brew install <> works. I think we should convince brew install <> that it is installing in /home/linuxbrew/.linuxbrew (because it actually is).

What are your thoughts on just mounting /home and have it be the same as /var/home (just like in a distrobox but in the host tpp)? I don't know why /home is a symlink in Silverblue from the first place tbh.

@osalbahr
Copy link

osalbahr commented Jul 5, 2023

FYI see Homebrew/install#786 for a related discussion.

@osalbahr
Copy link

osalbahr commented Jul 8, 2023

Hello, me and @rohanssrao wrote a patch in osalbahr/brew#3. Would appreciate testing before I PR to Homebrew.

I also added https://github.com/orgs/Homebrew/discussions/1282#discussioncomment-6389408.

@rohanssrao
Copy link
Contributor

As far as we can tell, brew developer on is only needed now because it prevents brew from reverting the sed command by resetting the working directory to mirror master. If the script patch gets merged to Homebrew master, the developer command won't be needed.
In summary, the required change is the removal of two characters (-P) from bin/brew.

@osalbahr
Copy link

Hello, I believe this issue has been fixed upstream:

To test the fix, you can run cd $(brew --repo) && git checkout master && brew update (as per https://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request). I think only running brew developer on might also be sufficient.

@osalbahr
Copy link

@marcoceppi @castrojo I believe the patch is now in the upstream as part of Homebrew/brew@4.0.28...4.1.0, so this issue can now be closed as resolved:

Feature: support symlinked /home by @osalbahr in Homebrew/brew#15656

https://github.com/Homebrew/brew/releases/tag/4.1.0

The default Linux installation location (/home/linuxbrew/.linuxbrew) works as expected on Fedora Silverblue and other configurations where /home is symlinked elsewhere.

https://brew.sh/2023/07/20/homebrew-4.1.0/


Special thx to @rohanssrao for helping out with testing and keeping my sanity with seemingly inconsistent results.

@castrojo castrojo linked a pull request Jul 27, 2023 that will close this issue
@castrojo
Copy link
Member Author

Sorry for the noise but I just wanted to let you all know that I love this feature so much, thanks for implementing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dx Developer Experience Image specific help wanted Keep Bluefin alive, dive in!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants