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

Transition from pkg-config to pkgconf not displayed in brew update/brew outdated/brew upgrade #18788

Open
3 tasks done
aphedges opened this issue Nov 19, 2024 · 4 comments
Open
3 tasks done
Labels
bug Reproducible Homebrew/brew bug

Comments

@aphedges
Copy link
Contributor

aphedges commented Nov 19, 2024

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: No developer tools installed.
Install Clang or run `brew install gcc`.

Verification

  • My "brew doctor output" above says Your system is ready to brew. and am still able to reproduce my issue.
    • I did not get the message, but it's unrelated to my issue.
  • I ran brew update twice and am still able to reproduce my issue.
    • I specifically needed to avoid updating to reproduce this 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.6
ORIGIN: https://github.com/Homebrew/brew
HEAD: cc0b5d6d05d1f3af5b2f53e9fbb1e7bfa0c332ab
Last commit: 2 days ago
Core tap HEAD: 5a7889f0a99d3ea24b9cc95062c2036111d15e5e
Core tap last commit: 62 minutes ago
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
HOMEBREW_NO_AUTO_UPDATE: set
HOMEBREW_NO_INSTALL_CLEANUP: set
HOMEBREW_NO_INSTALL_FROM_API: set
Homebrew Ruby: 3.3.6 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: 10-core 64-bit unknown_0x0_0x0
Clang: N/A
Git: 2.47.0 => /bin/git
Curl: 8.9.1 => /bin/curl
Kernel: Linux 6.10.11-linuxkit x86_64 GNU/Linux
OS: Fedora release 41 (Forty One)
Host glibc: 2.40
/usr/bin/gcc: N/A
/usr/bin/ruby: N/A
glibc: N/A
gcc@11: N/A
gcc: N/A
xorg: N/A

What were you trying to do (and why)?

I was running brew update and brew upgrade, which I do most days to keep my install up-to-date.

What happened (include all command output)?

When I updated my formulae last week, Homebrew did not properly express that it was replacing pkg-config with pkgconf:

# brew update
Updated 1 tap (homebrew/core).
==> New Formulae
beautysh         cbfmt            dotnet@8         fileql           kuzco            screenpipe
bibtex-tidy      cljfmt           energy           gplugin          neocmakelsp      sigsum-go
==> Deleted Installed Formulae
pkg-config ✘
==> Outdated Formulae
pkgconf

You have 1 outdated formula installed.
You can upgrade it with brew upgrade
or list it with brew outdated.
# brew outdated
pkgconf (0.29.2_3) < 2.3.0_1
# brew upgrade
==> Upgrading 1 outdated package:
pkg-config 2.3.0_1
==> Downloading https://ghcr.io/v2/homebrew/core/pkgconf/manifests/2.3.0_1
############################################################################################# 100.0%
==> Fetching pkgconf
==> Downloading https://ghcr.io/v2/homebrew/core/pkgconf/blobs/sha256:4fe98600d631d8d816217b96f905be
############################################################################################# 100.0%
==> Upgrading pkg-config
  -> 2.3.0_1
==> Pouring pkgconf--2.3.0_1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/pkgconf/2.3.0_1: 28 files, 489.0KB

What did you expect to happen?

I expected it to be clear that pkg-config was migrated to pkgconf, but the output brew update, brew outdated, and brew upgrade all provided different information, and none of it made clear what happened.

I was only able to figure out what happened from Homebrew/homebrew-core@0c35794, and I should not need to go into the commit history to figure out what version pkgconf upgraded from.

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

  1. Create a Dockerfile with the following contents:

    # Pin to latest Fedora image
    FROM fedora:41@sha256:9cfb3a7ad0a36a1e943409def613ec495571a5683c45addb5d608c2c29bb8248
    
    ENV HOMEBREW_NO_AUTO_UPDATE=1
    ENV HOMEBREW_NO_INSTALL_CLEANUP=1
    ENV HOMEBREW_NO_INSTALL_FROM_API=1
    ENV NONINTERACTIVE=1
    
    # Install Homebrew
    RUN dnf install -y git procps-ng
    RUN touch /.dockerenv
    RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/3c4f43009890527e22bc18cf21801e236ba87222/install.sh)"
    RUN echo >> ~/.bashrc
    RUN echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc
    
    # Suppress warning for smaller output
    RUN git config --global advice.detachedHead false
  2. Build and run the OCI image with the following commands:

    docker build --platform linux/amd64 --tag brew - <Dockerfile
    docker run --rm -it --platform linux/amd64 brew
  3. Run the following commands to reproduce the output provided above:

    # git -C "$(brew --repository)"/Library/Taps/homebrew/homebrew-core checkout 0c357945611d988fe65e46aeb092cbb6ca7492bd~1
    HEAD is now at 871be5cd76c Merge pull request #197395 from mise-en-dev/bump-mise-2024.11.7
    # brew install pkg-config
    ==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/manifests/0.29.2_3
    ############################################################################################# 100.0%
    ==> Fetching pkg-config
    ==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/blobs/sha256:3d9b8bf9b7b4bd08086be1104e3
    ############################################################################################# 100.0%
    ==> Pouring pkg-config--0.29.2_3.x86_64_linux.bottle.tar.gz
    🍺  /home/linuxbrew/.linuxbrew/Cellar/pkg-config/0.29.2_3: 12 files, 747KB
    # git -C "$(brew --repository)"/Library/Taps/homebrew/homebrew-core checkout 0c357945611d988fe65e46aeb092cbb6ca7492bd
    Previous HEAD position was 871be5cd76c Merge pull request #197395 from mise-en-dev/bump-mise-2024.11.7
    HEAD is now at 0c357945611 Merge pull request #194885 from Homebrew/pkgconf-symlink
    # brew outdated
    pkgconf (0.29.2_3) < 2.3.0_1
    # brew upgrade
    ==> Upgrading 1 outdated package:
    pkg-config 2.3.0_1
    ==> Downloading https://ghcr.io/v2/homebrew/core/pkgconf/manifests/2.3.0_1
    ############################################################################################# 100.0%
    ==> Fetching pkgconf
    ==> Downloading https://ghcr.io/v2/homebrew/core/pkgconf/blobs/sha256:4fe98600d631d8d816217b96f905be
    ############################################################################################# 100.0%
    ==> Upgrading pkg-config
      -> 2.3.0_1
    ==> Pouring pkgconf--2.3.0_1.x86_64_linux.bottle.tar.gz
    🍺  /home/linuxbrew/.linuxbrew/Cellar/pkgconf/2.3.0_1: 28 files, 489.0KB
@aphedges aphedges added the bug Reproducible Homebrew/brew bug label Nov 19, 2024
@Bo98
Copy link
Member

Bo98 commented Nov 19, 2024

The pkg-config transition was fairly atypical so does make sense why the brew update output perhaps doesn't expect it.

Usually what we do is add a rename. In this case we didn't and instead deleted pkg-config and re-added an alias pointing it to pkgconf, which is why brew update says it's been deleted because under the hood it has. One of the reasons we did it this way is because we want to support brew install pkg-config and $(brew --prefix)/opt/pkg-config indefinitely (without warnings) for backwards compatibility reasons given the high popularity of the formula.

Maybe one enhancement we could make here is to hide things from the "Deleted Installed Formulae" list if we detect it still exists as an alias. All the other output apart from that seems mostly correct.

@aphedges
Copy link
Contributor Author

It's good to have some more background! Thanks for explaining.

With regards to what I think should change, I think that what brew update displays is fine. However, I feel that brew upgrade should display what brew outdated does in this case:

# brew outdated
pkgconf (0.29.2_3) < 2.3.0_1
# brew upgrade
==> Upgrading 1 outdated package:
pkg-config 2.3.0_1
...
==> Upgrading pkg-config
  -> 2.3.0_1

It's a little confusing because pkg-config has no version 2.3.0_1 and is upgrading from nothing, so it seems like it has been spontaneously installed.

I would expect the output to look like the following, which would be more internally consistent:

# brew outdated
pkgconf (0.29.2_3) < 2.3.0_1
# brew upgrade
==> Upgrading 1 outdated package:
pkg-config 0.29.2_3 -> 2.3.0_1
...
==> Upgrading pkg-config
  0.29.2_3 -> 2.3.0_1

That way, it at least shows both the version before and after.

Something that I feel would be ideal is to show that a package replacement occurred:

# brew outdated
pkgconf (0.29.2_3) < 2.3.0_1
# brew upgrade
==> Upgrading 1 outdated package:
pkg-config 0.29.2_3 -> pkgconf 2.3.0_1
...
==> Upgrading pkg-config
  pkg-config 0.29.2_3 -> pkgconf 2.3.0_1

However, that would be a lot more complicated and possibly not worth the effort of implementing.

@Bo98
Copy link
Member

Bo98 commented Nov 19, 2024

Ah right didn't notice the broken ->. That makes sense yeah.

It looks at HOMEBREW_PREFIX/opt/#{name} (where name == pkgconf) for the old version but that won't exist yet prior to the upgrade and so fetching the old version fails. We have a Formula#any_installed_version which already has handling for this scenario so that's probably what we should use here.

@MikeMcQuaid
Copy link
Member

@cho-m Could you take a look? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible Homebrew/brew bug
Projects
None yet
Development

No branches or pull requests

3 participants