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

depends_on: build.head? seems evaluated in the opposite way #18575

Open
3 tasks done
AkihiroSuda opened this issue Oct 15, 2024 · 2 comments
Open
3 tasks done

depends_on: build.head? seems evaluated in the opposite way #18575

AkihiroSuda opened this issue Oct 15, 2024 · 2 comments

Comments

@AkihiroSuda
Copy link
Contributor

brew doctor output

Your system is ready to brew.

Verification

  • My "brew doctor output" above says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update twice and am still able to reproduce my issue.
  • This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.

brew config output

HOMEBREW_VERSION: 4.4.1-28-g4d4f3a2
ORIGIN: https://github.com/Homebrew/brew
HEAD: 4d4f3a2344df1616d4d953c54763d1315d9e6175
Last commit: 2 hours ago
Core tap HEAD: 65bf3b8f5917bf0c1d76fc5e8bc8f2b2e4a418f1
Core tap last commit: 6 hours ago
Core tap JSON: 15 Oct 11:27 UTC
Core cask tap HEAD: 1062885316f9c9a642a3706a20ca85a2b17ea546
Core cask tap last commit: 24 minutes ago
Core cask tap JSON: 15 Oct 11:27 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.3.5 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.5/bin/ruby
CPU: octa-core 64-bit icelake
Clang: 16.0.0 build 1600
Git: 2.47.0 => /usr/local/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.0.1-x86_64
CLT: 16.0.0.0.1.1724870825
Xcode: 16.

What were you trying to do (and why)?

I was trying to add the following change to https://github.com/Homebrew/homebrew-core/blob/65bf3b8f5917bf0c1d76fc5e8bc8f2b2e4a418f1/Formula/l/lima.rb

diff --git a/Formula/l/lima.rb b/Formula/l/lima.rb
index c4985057c5d..2d8d8e7daca 100644
--- a/Formula/l/lima.rb
+++ b/Formula/l/lima.rb
@@ -18,7 +18,7 @@ class Lima < Formula
   end
 
   depends_on "go" => :build
-  depends_on "qemu"
+  depends_on "qemu" if !build.head?
 
   def install
     if build.head?

Because the master branch of Lima no longer needs QEMU (on macOS hosts)

What happened (include all command output)?

The qemu dependency was being installed regardless to the if !build.head? condition.

$ brew install --build-from-source --HEAD --dry-run ./lima.rb
Error: Failed to load cask: ./lima.rb
Cask 'lima' is unreadable: wrong constant name #<Class:0x0000000132678c10>
Warning: Treating ./lima.rb as a formula.
==> Would install 1 formula:
lima
==> Would install 14 dependencies for lima:
capstone dtc python-packaging [email protected] glib jpeg-turbo libpng libslirp libssh lzo pixman snappy vde qe

However, these dependencies were not being installed after flipping if !build.head? to if build.head?.

What did you expect to happen?

depends_on FORMULA if !build.head? shouldn't be installed for --HEAD

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

- Fetch https://github.com/Homebrew/homebrew-core/blob/65bf3b8f5917bf0c1d76fc5e8bc8f2b2e4a418f1/Formula/l/lima.rb
- Change `depends_on "qemu"` to `depends_on "qemu" if !build.head?`
- Run `brew install --build-from-source --HEAD --dry-run ./lima.rb`
- Check the `Would install %d dependencies for lima` output
@AkihiroSuda AkihiroSuda added the bug Reproducible Homebrew/brew bug label Oct 15, 2024
@AkihiroSuda
Copy link
Contributor Author

@carlocab
Copy link
Member

Using build.head? or build.stable? outside of the install method doesn't work. If you want to scope something only to stable or head, use a stable do or head do block.

Incidentally:

$ brew install --build-from-source --HEAD --dry-run ./lima.rb

I recommend against passing paths to brew install. It maybe mostly works, but there are lots of subtle bugs.

@cho-m cho-m removed the bug Reproducible Homebrew/brew bug label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants