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

brew link fails with multiple HEAD installations #11741

Closed
1 of 2 tasks
vitorgalvao opened this issue Jul 19, 2021 · 6 comments · Fixed by #11824
Closed
1 of 2 tasks

brew link fails with multiple HEAD installations #11741

vitorgalvao opened this issue Jul 19, 2021 · 6 comments · Fixed by #11824
Assignees
Labels
bug Reproducible Homebrew/brew bug outdated PR was locked due to age

Comments

@vitorgalvao
Copy link
Member

vitorgalvao commented Jul 19, 2021

brew config output

HOMEBREW_VERSION: 3.2.2-76-g12d272a
ORIGIN: https://github.com/Homebrew/brew
HEAD: 12d272abe8b091cb079372ab7db8a0eab30384de
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 48b3156e29e9082dab02ed2070621052271f716b
Core tap last commit: 19 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0.5 build 1205
Git: 2.32.0 => /opt/homebrew/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.4-arm64
CLT: 12.5.0.22.9
Xcode: 12.5.1
Rosetta 2: false

brew doctor output

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /Users/vitor/.pyenv/shims/python3.9-config
  /Users/vitor/.pyenv/shims/python-config
  /Users/vitor/.pyenv/shims/python3-config

  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.

What were you trying to do (and why)?

brew link on a recently installed HEAD formula.

What happened (include all command output)?

Error: undefined method `rack' for nil:NilClass
/opt/homebrew/Library/Homebrew/cmd/link.rb:61:in `block in link'
/opt/homebrew/Library/Homebrew/cmd/link.rb:60:in `each'
/opt/homebrew/Library/Homebrew/cmd/link.rb:60:in `link'
/opt/homebrew/Library/Homebrew/brew.rb:122:in `<main>'

What did you expect to happen?

For either brew link to work on the most recent HEAD (cleanup removed the right one, so link should be able to know it too) or for an explanatory error message to show.

Step-by-step reproduction instructions (by running brew commands)

The following will create a mock directory structure (which works like the real thing for this purpose), followed by the command which produces the error:

mkdir -p "$(brew --Cellar)/show-rack-error/HEAD-"{1111111,2222222}
brew link show-rack-error

The directory structure will be:

show-rack-error
    ├── HEAD-1111111
    └── HEAD-2222222
@vitorgalvao vitorgalvao added the bug Reproducible Homebrew/brew bug label Jul 19, 2021
@carlocab
Copy link
Member

CC @cnnrmnn

@cnnrmnn
Copy link
Contributor

cnnrmnn commented Jul 19, 2021

Thanks for tagging me @carlocab. Been busy lately, but I'll take a look at this when I have some time.

@Rylan12
Copy link
Member

Rylan12 commented Jul 19, 2021

You need to run brew link --HEAD show-rack-error.

The error message should still be fixed, though. Probably just an error message if kegs.compact is empty saying "no stable kegs found for FOO".

Or, maybe CLI::NamedArgs.to_latest_kegs needs to be updated to complain if the keg can't be found like CLI::NamedArgs.to_formulae

@vitorgalvao
Copy link
Member Author

vitorgalvao commented Jul 19, 2021

You need to run brew link --HEAD show-rack-error.

That does work, though it’s a bit weird because brew link show-rack-error works if there’s a single HEAD installation. Having to add --HEAD because there are two isn’t intuitive.

Note I’m not in personal need of a workaround, as I’m (now) using brew cleanup to get rid of the old one. The issue is to prevent future bug reports.

@Rylan12
Copy link
Member

Rylan12 commented Jul 19, 2021

Ah, I bet to_latest_kegs returns the head keg if it's the only one. So the command as is currently designed (I think) is:

  • brew link links the latest keg which means if there's only one it will link that and if there are multiple, it will default to the latest stable
  • brew link --HEAD links the latest head keg

So, if there are multiple head kegs and you do brew link, it sees multiple kegs so it doesn't just auto-link (like it would with one head keg) and then doesn't see any stable versions so returns nil.

(This is all speculation I haven't tested)

Assuming that's correct, I think to_latest_kegs should be updated to return the latest head keg if there are no stable kegs available.

@cnnrmnn cnnrmnn self-assigned this Jul 19, 2021
@cnnrmnn
Copy link
Contributor

cnnrmnn commented Aug 4, 2021

So, if there are multiple head kegs and you do brew link, it sees multiple kegs so it doesn't just auto-link (like it would with one head keg) and then doesn't see any stable versions so returns nil.

Did some testing and your suspicions are correct.

Assuming that's correct, I think to_latest_kegs should be updated to return the latest head keg if there are no stable kegs available.

Agreed, working on a fix now.

@github-actions github-actions bot added the outdated PR was locked due to age label Sep 8, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/brew bug outdated PR was locked due to age
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants