Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
40.14k stars 9.41k forks source link

Plus symbol in formula name prevents building from source #15235

Closed rizopus closed 1 year ago

rizopus commented 1 year ago

brew doctor output

Your system is ready to brew.

Verification

brew config output

HOMEBREW_VERSION: 4.0.13
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9b60fcf7ac3f82fa589a64091376d0663262f8c6
Last commit: 2 days ago
Core tap JSON: 14 Apr 22:18 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 12
HOMEBREW_NO_ENV_HINTS: set
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: dodeca-core 64-bit arm_blizzard_avalanche
Clang: 14.0.3 build 1403
Git: 2.40.0 => /opt/homebrew/bin/git
Curl: 7.87.0 => /usr/bin/curl
macOS: 13.3.1-arm64
CLT: 14.3.0.0.1.1679647830
Xcode: 14.3
Rosetta 2: false

What were you trying to do (and why)?

Reinstall gtk+3 with debug symbols

What happened (include all command output)?

> brew reinstall --debug-symbols -s 'gtk+3'
Warning: building from source is not supported!
You're on your own. Failures are expected so don't create any issues, please!
==> Fetching dependencies for gtk+3: docbook, docbook-xsl and gobject-introspection
==> Fetching docbook
==> Downloading https://ghcr.io/v2/homebrew/core/docbook/manifests/5.1_1
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/f535f42662e0d894361c489a448ac2f5462b01ecb12c3c54876cb43570da5558--docbook-5.1_1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/docbook/blobs/sha256:dcab543bb0e0ae56e0aa106b61f77a111d52aa002c0418aae93f9fe6ac3cb332
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/e90f601ac20f941724103a824af06bf7f3ca2f3dcad7d817b7b68435089f3f4c--docbook--5.1_1.arm64_ventura.bottle.tar.gz
==> Fetching docbook-xsl
==> Downloading https://ghcr.io/v2/homebrew/core/docbook-xsl/manifests/1.79.2_1
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/33e485cb2c174d07962c3477b301084016b8cb7c2e6ea2ada01f4f0ea6ab1763--docbook-xsl-1.79.2_1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/docbook-xsl/blobs/sha256:b4b44849aed92229742c0b4b981a111cdadbe94a7457ef29426bf8888638557c
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/b3f02952873ede284200e265315fc0a81219f359980d0b2d81346f3927fe8617--docbook-xsl--1.79.2_1.arm64_ventura.bottle.tar.gz
==> Fetching gobject-introspection
==> Downloading https://ghcr.io/v2/homebrew/core/gobject-introspection/manifests/1.76.1
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/ed1053640a3b12f793e7a427cdccb6cbecc3ce778a95413fdaef63f82ec0fec6--gobject-introspection-1.76.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/gobject-introspection/blobs/sha256:0893c5b8d8dc89d1649c6d72c2d2a29fbe9412a5348a5e1fb28ebc284d46332e
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/1a77fa07252b0eef9a2810dcda9f3f9710a1421d8b080d9ffa723ae57020798c--gobject-introspection--1.76.1.arm64_ventura.bottle.tar.gz
==> Fetching gtk+3
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/42ae55f66cc402996f023dedccb60be1e4245456/Formula/gtk+3.rb
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/75356d7a2744bdcfe6c8d8ed4ef809e000930815bab78145e809682225a77e83--gtk 3.rb
Error: No available formula with the name "gtk 3". Did you mean gtk+3, gtkmm3, gtk4 or gtk+?
In formula file: /Users/user/Library/Caches/Homebrew/downloads/75356d7a2744bdcfe6c8d8ed4ef809e000930815bab78145e809682225a77e83--gtk 3.rb
Expected to find class Gtk3, but only found: Gtkx3.

What did you expect to happen?

I expected successful build but it turned out that any formula with "+" in its name cannot be built from source

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

> brew install 'gtk+3'
> brew reinstall --debug-symbols -s 'gtk+3'

another example:
> brew install -s crf++
apainintheneck commented 1 year ago

Would it be possible for you to to try those commands again with the --debug flag? That might show some more helpful information.

I tried reinstalling the bonnie++ package locally and that worked as expected so I'm wondering if this might possibly be API related somehow (just a wild guess).

Either way from the output it seems to be failing somewhere in the fetch stage for some reason. We know this because it never reached the Reinstalling <formula_name>... part of the messaging.

https://github.com/Homebrew/brew/blob/ad3d207172639396b8585899c43be97d08f58709/Library/Homebrew/reinstall.rb#L60-L62

The fetch code inside the installer fetches the formula source (the JSON formula representation doesn't contain the info necessary to build from source) and then reloads the formula using it. It seems to fail to load the formula the second time.

https://github.com/Homebrew/brew/blob/ad3d207172639396b8585899c43be97d08f58709/Library/Homebrew/formula_installer.rb#L1200-L1204

rizopus commented 1 year ago

To sync with you I tried to install bonnie++ package.

  1. First try of clean install with -s flag

    ❯ brew install -s --debug bonnie++
    ==> Downloading https://formulae.brew.sh/api/formula.jws.json
    /usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --user-agent Homebrew/4.0.13\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.3.1\)\ curl/7.87.0 --header Accept-Language:\ en --fail --progress-bar --location --remote-time --output /Users/user/Library/Caches/Homebrew/api/formula.jws.json --time-cond /Users/user/Library/Caches/Homebrew/api/formula.jws.json --compressed --speed-limit 100 --speed-time 5 --progress-bar https://formulae.brew.sh/api/formula.jws.json
    ##O#-#                                                                        
    /opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading bonnie++ from API
    ==> Fetching bonnie++
    /usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.13\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.3.1\)\ curl/7.87.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://raw.githubusercontent.com/Homebrew/homebrew-core/9c4b39858369e1c02b618d1af5a75d3e943073be/Formula/bonnie\+\+.rb
    /usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.13\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.3.1\)\ curl/7.87.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head --request GET https://raw.githubusercontent.com/Homebrew/homebrew-core/9c4b39858369e1c02b618d1af5a75d3e943073be/Formula/bonnie\+\+.rb
    ==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/9c4b39858369e1c02b618d1af5a75d3e943073be/Formula/bonnie++.rb
    /usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.13\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.3.1\)\ curl/7.87.0 --header Accept-Language:\ en --retry 3 --location --head https://raw.githubusercontent.com/Homebrew/homebrew-core/9c4b39858369e1c02b618d1af5a75d3e943073be/Formula/bonnie\+\+.rb
    /usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.13\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.3.1\)\ curl/7.87.0 --header Accept-Language:\ en --fail --progress-bar --retry 3 --location --remote-time --output /Users/user/Library/Caches/Homebrew/downloads/ffa98d77d1999b1a3f1788a7ff969a1aa18592a5b9eaf7cffd4232eb59cc1e81--bonnie\ \ .rb.incomplete https://raw.githubusercontent.com/Homebrew/homebrew-core/9c4b39858369e1c02b618d1af5a75d3e943073be/Formula/bonnie\+\+.rb
    ######################################################################## 100.0%
    /opt/homebrew/Library/Homebrew/brew.rb (Formulary::FromPathLoader): loading /Users/user/Library/Caches/Homebrew/downloads/ffa98d77d1999b1a3f1788a7ff969a1aa18592a5b9eaf7cffd4232eb59cc1e81--bonnie  .rb
    Error: No available formula with the name "bonnie  ". Did you mean bonnie++?
    In formula file: /Users/user/Library/Caches/Homebrew/downloads/ffa98d77d1999b1a3f1788a7ff969a1aa18592a5b9eaf7cffd4232eb59cc1e81--bonnie  .rb
    Expected to find class Bonnie  , but only found: Bonniexx.
  2. Install as usual

    ❯ brew install bonnie++   
    ==> Fetching bonnie++
    ==> Downloading https://ghcr.io/v2/homebrew/core/bonniexx/manifests/2.00a
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/bonniexx/blobs/sha256:bb48f4977b6fffe6260f6adf6a20b15d0e33ef6f0f70a3d5fe36f3d1cd708c3c
    ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:bb48f4977b6fffe6260f6adf6a20b15d0e33ef6f0f70a3d5fe36f3d1cd708c3c?se=2023-04-16T07%3A50%3A00Z&sig=Ck6NutNm3CgZFhHTGQzJsnbhv3Ug4gPUmUTuqhhSQsA%3D&sp=r&spr=https&s
    ######################################################################## 100.0%
    ==> Pouring bonnie++--2.00a.arm64_ventura.bottle.tar.gz
    🍺  /opt/homebrew/Cellar/bonnie++/2.00a: 19 files, 309.4KB
    ==> Running `brew cleanup bonnie++`...
  3. Reinstall with -s

    ❯ brew reinstall -s --debug bonnie++ 
    /opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading bonnie++ from API
    Warning: building from source is not supported!
    You're on your own. Failures are expected so don't create any issues, please!
    ==> Fetching bonnie++
    ==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/9c4b39858369e1c02b618d1af5a75d3e943073be/Formula/bonnie++.rb
    /usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.13\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.3.1\)\ curl/7.87.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://raw.githubusercontent.com/Homebrew/homebrew-core/9c4b39858369e1c02b618d1af5a75d3e943073be/Formula/bonnie\+\+.rb
    /usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.13\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.3.1\)\ curl/7.87.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head --request GET https://raw.githubusercontent.com/Homebrew/homebrew-core/9c4b39858369e1c02b618d1af5a75d3e943073be/Formula/bonnie\+\+.rb
    Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/ffa98d77d1999b1a3f1788a7ff969a1aa18592a5b9eaf7cffd4232eb59cc1e81--bonnie  .rb
    /opt/homebrew/Library/Homebrew/brew.rb (Formulary::FromPathLoader): loading /Users/user/Library/Caches/Homebrew/downloads/ffa98d77d1999b1a3f1788a7ff969a1aa18592a5b9eaf7cffd4232eb59cc1e81--bonnie  .rb
    Error: No available formula with the name "bonnie  ". Did you mean bonnie++?
    In formula file: /Users/user/Library/Caches/Homebrew/downloads/ffa98d77d1999b1a3f1788a7ff969a1aa18592a5b9eaf7cffd4232eb59cc1e81--bonnie  .rb
    Expected to find class Bonnie  , but only found: Bonniexx.
    /opt/homebrew/Library/Homebrew/formulary.rb:113:in `const_get'
    /opt/homebrew/Library/Homebrew/formulary.rb:113:in `load_formula'
    /opt/homebrew/Library/Homebrew/formulary.rb:127:in `load_formula_from_path'
    /opt/homebrew/Library/Homebrew/formulary.rb:414:in `load_file'
    /opt/homebrew/Library/Homebrew/formulary.rb:404:in `klass'
    /opt/homebrew/Library/Homebrew/formulary.rb:399:in `get_formula'
    /opt/homebrew/Library/Homebrew/formulary.rb:670:in `factory'
    /opt/homebrew/Library/Homebrew/formula_installer.rb:1200:in `fetch'
    /opt/homebrew/Library/Homebrew/reinstall.rb:60:in `reinstall_formula'
    /opt/homebrew/Library/Homebrew/cmd/reinstall.rb:120:in `block in reinstall'
    /opt/homebrew/Library/Homebrew/cmd/reinstall.rb:114:in `each'
    /opt/homebrew/Library/Homebrew/cmd/reinstall.rb:114:in `reinstall'
    /opt/homebrew/Library/Homebrew/brew.rb:94:in `<main>'
carlocab commented 1 year ago

Why are you building these formulae from source? Does it work if you do

export HOMEBREW_NO_INSTALL_FROM_API=1
brew update

before attempting a source install?

rizopus commented 1 year ago

@carlocab I needed debug symbols for some package. Using HOMEBREW_NO_INSTALL_FROM_API=1 works

What is different when using HOMEBREW_NO_INSTALL_FROM_API=1 and not? Formulary.load_formula(name, path, ...) gets name="bonnie++" in the first case, and name="bonnie " in the last. That name will lately be used to derive class name to lookup in formula: class_name = class_s(name).

name, in turn, is somehow derived from a path. The formula path is ../Formula/bonnie++.rb in the first case and ../Formula/bonnie .rb in the second.

MikeMcQuaid commented 1 year ago

@Bo98 Can you pick this up please as you pushed for installing from source using the API? Thanks.

issyl0 commented 1 year ago

In download_strategy.rb, parse_basename, line 352:

uri_path: "/Homebrew/homebrew-core/9fa25e536710603c675fe187c564cbaac45fb7d5/Formula/bonnie++.rb", decode_form_component: /Homebrew/homebrew-core/9fa25e536710603c675fe187c564cbaac45fb7d5/Formula/bonnie  .rb

Because https://ruby-doc.org/stdlib-2.6.10/libdoc/uri/rdoc/URI.html#method-c-decode_www_form_component.

Bo98 commented 1 year ago

This is fixed for 4.0.15.