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

Install from API misses arch-specific dependencies #14535

Closed
3 tasks done
gromgit opened this issue Feb 7, 2023 · 4 comments · Fixed by #14621
Closed
3 tasks done

Install from API misses arch-specific dependencies #14535

gromgit opened this issue Feb 7, 2023 · 4 comments · Fixed by #14621
Labels
bug Reproducible Homebrew/brew bug install from api Relates to API installs outdated PR was locked due to age

Comments

@gromgit
Copy link
Contributor

gromgit commented Feb 7, 2023

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: 3.6.20-296-g2bb5cda
ORIGIN: https://github.com/Homebrew/brew
HEAD: 2bb5cdaaa92cbfa8c665a77f41cc7070f21a60b9
Last commit: 4 hours ago
Core tap origin: https://github.com/Homebrew/homebrew-core
Core tap HEAD: bcc0f7b5de81b165e33957291bd92ab46232dd89
Core tap last commit: 61 minutes ago
Core tap branch: master
Core tap JSON: 07 Feb 04:21 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_BOOTSNAP: set
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY_INSTALL_TIMES: set
HOMEBREW_EDITOR: vim
HOMEBREW_EVAL_ALL: set
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_GITHUB_PACKAGES_TOKEN: set
HOMEBREW_GITHUB_PACKAGES_USER: gromgit
HOMEBREW_GIT_EMAIL: [email protected]
HOMEBREW_GIT_NAME: Adrian Ho
HOMEBREW_MAKE_JOBS: 8
HOMEBREW_NO_AUTO_UPDATE: set
HOMEBREW_TEMP: /opt/homebrew/tmp
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 14.0.0 build 1400
Git: 2.39.1 => /opt/homebrew/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.6.1-arm64
CLT: 14.1.0.0.1.1666437224
Xcode: 14.1
Rosetta 2: false

What were you trying to do (and why)?

I was investigating #14531, but found another API install problem instead. The cocoapods formula contains the following dependencies:

  depends_on "pkg-config" => :build
  uses_from_macos "libffi", since: :catalina
  uses_from_macos "ruby", since: :catalina

  on_arm do
    depends_on "ruby"
  end

This seems to be correctly indicated in the API JSON:

$ jq -c '.[]|select(.name=="cocoapods")|.build_dependencies,.uses_from_macos,.variations.arm64_monterey' ~/Library/Caches/Homebrew/api/formula.json
["pkg-config"]
["libffi","ruby"]
{"dependencies":["ruby"]}

However, brew info without HOMEBREW_NO_INSTALL_FROM_API set doesn't list that dependency, and brew install with the same doesn't install it either.

What happened (include all command output)?

$ brew info --formula cocoapods
==> cocoapods: stable 1.11.3 (bottled)
Dependency manager for Cocoa projects
https://cocoapods.org/
/opt/homebrew/Cellar/cocoapods/1.11.3_1 (13,476 files, 27.9MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-02-07 at 11:53:48
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/cocoapods.rb
License: MIT
==> Dependencies
Build: pkg-config ✔
==> Analytics
install: 97,361 (30 days), 209,986 (90 days), 726,696 (365 days)
install-on-request: 97,353 (30 days), 209,884 (90 days), 724,294 (365 days)
build-error: 34 (30 days)

$ HOMEBREW_NO_INSTALL_FROM_API=1 brew info --formula cocoapods
==> cocoapods: stable 1.11.3 (bottled)
Dependency manager for Cocoa projects
https://cocoapods.org/
/opt/homebrew/Cellar/cocoapods/1.11.3_1 (13,476 files, 27.9MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-02-07 at 11:53:48
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/cocoapods.rb
License: MIT
==> Dependencies
Build: pkg-config ✔
Required: ruby ✘
==> Analytics
install: 97,361 (30 days), 209,986 (90 days), 726,696 (365 days)
install-on-request: 97,353 (30 days), 209,884 (90 days), 724,294 (365 days)
build-error: 34 (30 days)

Note the extra ruby dependency with HOMEBREW_NO_INSTALL_FROM_API set.

$ brew ls ruby
Error: No such keg: /opt/homebrew/Cellar/ruby

$ brew install --formula cocoapods
==> Fetching cocoapods
==> Downloading https://ghcr.io/v2/homebrew/core/cocoapods/manifests/1.11.3_1-1
Already downloaded: /Users/aho/Library/Caches/Homebrew/downloads/37d01c4861dfd4fb2ee665333db56c3652606c9c61ab9500929f9b29bfd1f467--cocoapods-1.11.3_1-1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/cocoapods/blobs/sha256:9717ff53b4af5304811ad8a5a80586cf13f8e02155813f526f26b0093e53261c
Already downloaded: /Users/aho/Library/Caches/Homebrew/downloads/af25efb4149b25aa31e64f66d15808ca00a8223e1a1e1cdc7af75bad2f3e095f--cocoapods--1.11.3_1.arm64_monterey.bottle.1.tar.gz
==> Pouring cocoapods--1.11.3_1.arm64_monterey.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/cocoapods/1.11.3_1: 13,476 files, 27.9MB
==> Running `brew cleanup cocoapods`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Installation times
cocoapods                 5.306 s

$ brew test cocoapods
Error: cocoapods is missing test dependencies: ruby

$ brew rm --formula cocoapods
Uninstalling /opt/homebrew/Cellar/cocoapods/1.11.3_1... (13,476 files, 27.9MB)

$ HOMEBREW_NO_INSTALL_FROM_API=1 brew install --formula cocoapods
==> Fetching dependencies for cocoapods: ruby
==> Fetching ruby
==> Downloading https://ghcr.io/v2/homebrew/core/ruby/manifests/3.2.0
Already downloaded: /Users/aho/Library/Caches/Homebrew/downloads/c360900acacef49e831b0f640b0e175180c181ef83afbcd24d4d6609fbf146fe--ruby-3.2.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/ruby/blobs/sha256:4617eb7c595c406df74c98c8b26ca209ed14b2b3f70a434037204d15e6330858
Already downloaded: /Users/aho/Library/Caches/Homebrew/downloads/03e74094afebf0c7189c2fc589555543e2f9f5244c78e6f9427b3f2978e3ded7--ruby--3.2.0.arm64_monterey.bottle.tar.gz
==> Fetching cocoapods
==> Downloading https://ghcr.io/v2/homebrew/core/cocoapods/manifests/1.11.3_1-1
Already downloaded: /Users/aho/Library/Caches/Homebrew/downloads/37d01c4861dfd4fb2ee665333db56c3652606c9c61ab9500929f9b29bfd1f467--cocoapods-1.11.3_1-1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/cocoapods/blobs/sha256:9717ff53b4af5304811ad8a5a80586cf13f8e02155813f526f26b0093e53261c
Already downloaded: /Users/aho/Library/Caches/Homebrew/downloads/af25efb4149b25aa31e64f66d15808ca00a8223e1a1e1cdc7af75bad2f3e095f--cocoapods--1.11.3_1.arm64_monterey.bottle.1.tar.gz
==> Installing dependencies for cocoapods: ruby
==> Installing cocoapods dependency: ruby
==> Pouring ruby--3.2.0.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/ruby/3.2.0: 16,574 files, 46.8MB
==> Installing cocoapods
==> Pouring cocoapods--1.11.3_1.arm64_monterey.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/cocoapods/1.11.3_1: 13,476 files, 27.9MB
==> Running `brew cleanup cocoapods`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Installation times
ruby                      7.187 s
cocoapods                14.638 s

$ brew test cocoapods
==> Testing cocoapods
==> /opt/homebrew/Cellar/cocoapods/1.11.3_1/bin/pod list

What did you expect to happen?

Install from API should have installed ruby as a dependency, as the JSON states.

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

brew rm --ignore-dependencies ruby # if installed
brew install --formula cocoapods
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --formula cocoapods
@gromgit gromgit added the bug Reproducible Homebrew/brew bug label Feb 7, 2023
@carlocab carlocab added the install from api Relates to API installs label Feb 7, 2023
@Rylan12
Copy link
Member

Rylan12 commented Feb 7, 2023

This is because of the uses_from_macos "ruby", since: :catalina. The API loader sees that ruby is a uses_from_macos dep and so it doesn't re-add it as a dependency. Putting the uses_from_macos line into an on_intel block should do the trick. This is also probably the solution that makes the formula make the most sense, since otherwise we're relying on an override situation afaik

If this is a common pattern (i.e. saying uses_from_macos and also a dependency that is intended to override that), we could maybe modify the dependencies API item to skip uses_from_macos deps, but I'll need to look into that more before we commit to it.

@Bo98
Copy link
Member

Bo98 commented Feb 10, 2023

I don't think Cocoapods needs that dependency anymore tbh, though I'll need to check.

If we can't fix this before 4.0.0, we'll need to sort it out in homebrew-core as this is very popular formula that we can't really be breaking.

@carlocab
Copy link
Member

This is because of the uses_from_macos "ruby", since: :catalina. The API loader sees that ruby is a uses_from_macos dep and so it doesn't re-add it as a dependency. Putting the uses_from_macos line into an on_intel block should do the trick. This is also probably the solution that makes the formula make the most sense, since otherwise we're relying on an override situation afaik

If this is a common pattern (i.e. saying uses_from_macos and also a dependency that is intended to override that), we could maybe modify the dependencies API item to skip uses_from_macos deps, but I'll need to look into that more before we commit to it.

If we can't/won't/shouldn't modify the dependencies API, then we need an audit to catch these cases since this is way too easy to miss on a review.

@MikeMcQuaid
Copy link
Member

If we can't fix this before 4.0.0, we'll need to sort it out in homebrew-core as this is very popular formula that we can't really be breaking.

We can't fix this for 4.0.0.

If we can't/won't/shouldn't modify the dependencies API, then we need an audit to catch these cases since this is way too easy to miss on a review.

👍🏻 on an audit.

For now we should implement the workaround @Rylan12 suggests.

@github-actions github-actions bot added the outdated PR was locked due to age label Mar 18, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/brew bug install from api Relates to API installs outdated PR was locked due to age
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants