Brew: Installing the patchelf bottle shouldn't require patchelf

Created on 27 Apr 2020  路  9Comments  路  Source: Homebrew/brew

  • [x] ran brew update and can still reproduce the problem?
  • [x] ran brew doctor, fixed all issues and can still reproduce the problem?
  • [x] ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

Install gcc on a Debian distribution without having the debian package build-essential already installed. This is useful to bootstrap Linuxbrew if you don't have the root privilege.

The genesis of this issue comes from a disscussion with @sjackman in this pull request.

What happened (include command output)

Trying to install gcc with brew install gcc ends with the message:

Install Clang or run `brew install gcc`.
Command output

==> Installing dependencies for gcc: patchelf, gmp, mpfr, libmpc, zlib, binutils and [email protected]
==> Installing gcc dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.10.x86_64_linux.bottle.tar.gz
Already downloaded: /home/linuxbrew/.cache/Homebrew/downloads/405227c46362964d2bc2e9ff6428fe082dff4dbd3a4b0b29453743f71923304b--patchelf-0.10.x86_64_linux.bottle.tar.gz
==> Pouring patchelf-0.10.x86_64_linux.bottle.tar.gz
Error: patchelf must be installed: brew install patchelf
Warning: Bottle installation failed: building from source.
Error: The following formula
  patchelf
cannot be installed as binary package and must be built from source.
Install Clang or run `brew install gcc`.

  
## What you expected to happen The `gcc` formulas should be installed when typing `brew install gcc`. ## Step-by-step reproduction instructions (by running `brew` commands) You can reproduce this problem from scratch with the following commands:
docker run -it debian

apt update && apt install -y curl file git locales sudo
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen en_US.UTF-8
useradd -m -s /bin/bash linuxbrew
sudo -i -u linuxbrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
brew install gcc
## Output of `brew config` and `brew doctor` commands
brew config
HOMEBREW_VERSION: 2.2.13
ORIGIN: https://github.com/Homebrew/brew
HEAD: 3d9cf83fec45a75af61551f53d25383abe009d31
Last commit: 2 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/linuxbrew-core
Core tap HEAD: fe7a38cffecb8336badfc8421de8ea4ec15fa7f2
Core tap last commit: 8 hours ago
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_MAKE_JOBS: 2
CPU: dual-core 64-bit broadwell
Homebrew Ruby: 2.6.3 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: N/A
Git: 2.20.1 => /usr/bin/git
Curl: 7.64.0 => /usr/bin/curl
Kernel: Linux 4.19.76-linuxkit x86_64 GNU/Linux
OS: Unknown
Host glibc: 2.28
/usr/bin/gcc: N/A
glibc: N/A
gcc: N/A
xorg: N/A
brew doctor
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`.
bug gsoc-outreachy outdated

All 9 comments

The problem comes from: https://github.com/Homebrew/brew/blob/3247f26a3416284cabfe0dcc28cbe05e466f622a/Library/Homebrew/os/linux/elf.rb#L129-L137

From the same configuration, as in the initial issue, if I install the Debian package binutils which provides /usr/bin/readelf, I can then directly install patchelf from Homebrew.

The questions are now: does the patchelf formula really need readelf or patchelf to be installed, and if this is not the case, can we implement a shortcurt ?

No, patchelf does not require readelf to install the patchelf bottle. @VonUniGE Are you interested in working on a fix to this issue? I'm happy to answer questions if so. Feel free to open a work-in-progress PR and tag me if you run into questions.

Yes, I'm interested in working on this issue. I've started to setup a development environment using IntelliJ IDEA, but it's not so easy to combine bash and ruby in debug mode.

Do you have some tips or documentation on how to setup a good development environment ?

@VonUniGE have u started working on this ? because im also working along the same lines

@rmNULL I've just look around and set up things. So you can go ahead with a PR.

Can you expose the way you think to proceed ?

@VonUniGE this issue will be covered as a part of replacing readelf and patchelf with ruby .
There is a plan to replace all usages of readelf and patchelf in homebrew linux with patchelf.rb and readelf.rb.

Ideally in future both (patchelf and readelf) will not be required as part of linuxbrew installation.

@VonUniGE did a temporary "quick fix", you can close the issue if you think the problem is solved.
Thanks for bug reporting :)

It works well. Using the same settings as above, I obtain now (after switching Homebrew branch from stable to master):

linuxbrew@8aba8f81baa4:~/.linuxbrew/Homebrew$ brew install gcc
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.10.x86_64_linux.bottle.1.tar.gz
Already downloaded: /home/linuxbrew/.cache/Homebrew/downloads/e56448ff76aebde792833538923b85710783699dd73f0d566c434efba43ebea6--patchelf-0.10.x86_64_linux.bottle.1.tar.gz
==> Downloading https://linuxbrew.bintray.com/bottles/gcc-5.5.0_7.x86_64_linux.bottle.tar.gz
Already downloaded: /home/linuxbrew/.cache/Homebrew/downloads/b91d14d1e15ddd20f9b3114d36aa006c86f2ecf8aa07e5c328ab950e9b4c40f8--gcc-5.5.0_7.x86_64_linux.bottle.tar.gz
==> Installing dependencies for gcc: patchelf
==> Installing gcc dependency: patchelf
==> Pouring patchelf-0.10.x86_64_linux.bottle.1.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/patchelf/0.10: 8 files, 921.5KB
==> Installing gcc
==> Pouring gcc-5.5.0_7.x86_64_linux.bottle.tar.gz
==> Creating the GCC specs file: /home/linuxbrew/.linuxbrew/Cellar/gcc/5.5.0_7/lib/gcc/x86_64-unknown-linux-gnu/5.5.0/specs
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/gcc/5.5.0_7: 1,342 files, 174.8MB
linuxbrew@8aba8f81baa4:~/.linuxbrew/Homebrew$ gcc --version
gcc (Homebrew GCC 5.5.0_7) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thank you very much @rmNULL !

Fixed by PR https://github.com/Homebrew/brew/pull/7575. Thank you, @rmnull! 馃弲

Was this page helpful?
0 / 5 - 0 ratings