Linuxbrew / brew

:beer::penguin: The Homebrew package manager for Linux
https://linuxbrew.sh
BSD 2-Clause "Simplified" License
2.66k stars 237 forks source link

Unable to install bottled gcc formula using brew #894

Closed falzm closed 6 years ago

falzm commented 6 years ago

Actually my problem is why brew doctor is reporting a problem: see issue https://github.com/Linuxbrew/brew/issues/893

brew config
HOMEBREW_VERSION: 1.8.2
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: 0b0b6b77676d69f964fe0a078370f66670b1512a
Last commit: 2 weeks ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: 752f0a3f4640ef3962e0f9ceaf9f7e3cdf5fca96
Core tap last commit: 3 days ago
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CACHE: /var/services/homes/marc/.cache/Homebrew
CPU: single-core 64-bit unknown_0x6_0x5c
Homebrew Ruby: 2.3.7 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/bin/ruby
Clang: N/A
Git: 2.17.1 => /bin/git
Curl: 7.54.0 => /usr/bin/curl
Kernel: Linux 4.4.59+ x86_64 GNU/Linux
OS: N/A
Host glibc: N/A
/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 brew install gcc
  

What you were trying to do (and why)

Install gcc formula (or any other formula it depends on, such as patchelf) in order to install any formula from source later on.

What happened (include command output)

Command output
$ brew install gcc
==> Installing dependencies for gcc: patchelf, zlib, glibc, gmp, mpfr, libmpc and isl@0.18
==> Installing gcc dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.9_1.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/00/00c02e6c700f4427da40a82e2a5d88427cfb28a79b3ac69f441d69d837725
######################################################################## 100.0%
==> Pouring patchelf-0.9_1.x86_64_linux.bottle.tar.gz
Error: Please install either readelf (from binutils) or file.
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 brew install gcc
  

What you expected to happen

Successful formula installation.

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

brew install gcc
sjackman commented 6 years ago
Error: Please install either readelf (from binutils) or file.

You need either readelf or file to pour bottles. If you have neither, you won't be able to use Linuxbrew as is.

If you want to make this work, and are willing to put some extra effort in, you can start by manually downloading and extracting the bottle for binutils and putting the readelf executable somewhere in your PATH. See https://bintray.com/linuxbrew/bottles/binutils#files

falzm commented 6 years ago

Hi @sjackman, thank you for the tip: it helped, but now I get another error (Error: no implicit conversion of nil into String):

$ brew install gcc
==> Installing dependencies for gcc: zlib, glibc, gmp, mpfr, libmpc and isl@0.18
==> Installing gcc dependency: zlib
==> Downloading https://linuxbrew.bintray.com/bottles/zlib-1.2.11.x86_64_linux.bottle.tar.gz
Already downloaded: /var/services/homes/marc/.cache/Homebrew/downloads/e26d7f94e9190e27f35a0ca17586414d88d5bb82ae7927206a18556eab619109--zlib-1.2.11.x86_64_linux.bottle.tar.gz
==> Pouring zlib-1.2.11.x86_64_linux.bottle.tar.gz
Error: no implicit conversion of nil into String
Warning: Bottle installation failed: building from source.
Error: The following formula
  zlib
cannot be installed as binary package and must be built from source.
Install Clang or brew install gcc
Error: No such file or directory @ dir_s_mkdir - /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.11/.d20181126-22523-l8u4yp
Warning: Bottle installation failed: building from source.
Error: The following formula
  zlib
cannot be installed as binary package and must be built from source.
Install Clang or brew install gcc
sjackman commented 6 years ago

Hmm. Please report the output of brew install -dv zlib

falzm commented 6 years ago

Here you go:

$ brew install -dv zlib
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/zlib.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gcc.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/glibc.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/binutils.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/linux-headers.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gmp.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/m4.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libmpc.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/mpfr.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/isl@0.18.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/patchelf.rb
==> Downloading https://linuxbrew.bintray.com/bottles/zlib-1.2.11.x86_64_linux.bottle.tar.gz
/usr/bin/curl -q --show-error --user-agent Linuxbrew/1.8.3\ \(Linux\;\ x86_64\ 4.4.59\+\)\ curl/7.54.0 --location --silent --head https://linuxbrew.bintray.com/bottles/zlib-1.2.11.x86_64_linux.bottle.tar.gz
Already downloaded: /var/services/homes/marc/.cache/Homebrew/downloads/e26d7f94e9190e27f35a0ca17586414d88d5bb82ae7927206a18556eab619109--zlib-1.2.11.x86_64_linux.bottle.tar.gz
==> Verifying e26d7f94e9190e27f35a0ca17586414d88d5bb82ae7927206a18556eab619109--zlib-1.2.11.x86_64_linux.bottle.tar.gz checksum
==> Pouring zlib-1.2.11.x86_64_linux.bottle.tar.gz
tar xf /var/services/homes/marc/.cache/Homebrew/downloads/e26d7f94e9190e27f35a0ca17586414d88d5bb82ae7927206a18556eab619109--zlib-1.2.11.x86_64_linux.bottle.tar.gz -C /tmp/d20181126-12232-1za4gn
cp -pR /tmp/d20181126-12232-1za4gn/zlib/. /home/linuxbrew/.linuxbrew/Cellar/zlib
chmod -Rf +w /tmp/d20181126-12232-1za4gn
/home/linuxbrew/.linuxbrew/bin/patchelf --force-rpath --set-rpath /home/linuxbrew/.linuxbrew/lib /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.11/lib/libz.so.1.2.11
Error: no implicit conversion of nil into String
Warning: Bottle installation failed: building from source.
Error: The following formula
  zlib
cannot be installed as binary package and must be built from source.
Install Clang or brew install gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:305:in `rescue in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:292:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:329:in `install_formula'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:259:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:257:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:257:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:89:in `<main>'
Error: No such file or directory @ dir_s_mkdir - /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.11/.d20181126-12232-12q3sdb
Warning: Bottle installation failed: building from source.
Error: The following formula
  zlib
cannot be installed as binary package and must be built from source.
Install Clang or brew install gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:305:in `rescue in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:292:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:329:in `install_formula'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:259:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:257:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:257:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:89:in `<main>'
sjackman commented 6 years ago

Please report the output of…

HOMEBREW_STDERR=1 brew install -dv zlib
/home/linuxbrew/.linuxbrew/bin/patchelf --version
which -a file readelf
falzm commented 6 years ago
$ HOMEBREW_STDERR=1 brew install -dv zlib
Updating Homebrew...
brew: command not found: /usr/bin/ldd
brew: command not found: /usr/bin/ldd
brew: command not found: /usr/bin/ldd
brew: command not found: /usr/bin/ldd
brew: command not found: /usr/bin/ldd
brew: command not found: /usr/bin/ldd
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
llvm                  llvm@3.9              llvm@4                llvm@5                llvm@6

/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/zlib.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gcc.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/glibc.rb
brew: command not found: /usr/bin/ldd
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/binutils.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/linux-headers.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gmp.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/m4.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libmpc.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/mpfr.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/isl@0.18.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/patchelf.rb
==> Downloading https://linuxbrew.bintray.com/bottles/zlib-1.2.11.x86_64_linux.bottle.tar.gz
/usr/bin/curl -q --show-error --user-agent Linuxbrew/1.8.3\ \(Linux\;\ x86_64\ 4.4.59\+\)\ curl/7.54.0 --location --silent --head https://linuxbrew.bintray.com/bottles/zlib-1.2.11.x86_64_linux.bottle.tar.gz
Already downloaded: /var/services/homes/marc/.cache/Homebrew/downloads/e26d7f94e9190e27f35a0ca17586414d88d5bb82ae7927206a18556eab619109--zlib-1.2.11.x86_64_linux.bottle.tar.gz
==> Verifying e26d7f94e9190e27f35a0ca17586414d88d5bb82ae7927206a18556eab619109--zlib-1.2.11.x86_64_linux.bottle.tar.gz checksum
==> Pouring zlib-1.2.11.x86_64_linux.bottle.tar.gz
tar xf /var/services/homes/marc/.cache/Homebrew/downloads/e26d7f94e9190e27f35a0ca17586414d88d5bb82ae7927206a18556eab619109--zlib-1.2.11.x86_64_linux.bottle.tar.gz -C /tmp/d20181127-19667-v40i0u
cp -pR /tmp/d20181127-19667-v40i0u/zlib/. /home/linuxbrew/.linuxbrew/Cellar/zlib
chmod -Rf +w /tmp/d20181127-19667-v40i0u
/home/linuxbrew/.linuxbrew/bin/patchelf --force-rpath --set-rpath /home/linuxbrew/.linuxbrew/lib /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.11/lib/libz.so.1.2.11
Error: no implicit conversion of nil into String
Warning: Bottle installation failed: building from source.
Error: The following formula
  zlib
cannot be installed as binary package and must be built from source.
Install Clang or brew install gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:305:in `rescue in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:292:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:329:in `install_formula'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:259:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:257:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:257:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:89:in `<main>'
Error: No such file or directory @ dir_s_mkdir - /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.11/.d20181127-19667-1iyxb81
Warning: Bottle installation failed: building from source.
Error: The following formula
  zlib
cannot be installed as binary package and must be built from source.
Install Clang or brew install gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:305:in `rescue in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:292:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:329:in `install_formula'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:259:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:257:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:257:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:89:in `<main>'

$ /home/linuxbrew/.linuxbrew/bin/patchelf --version
patchelf 0.9

$ which -a file readelf
/sbin/readelf
/usr/sbin/readelf
sjackman commented 5 years ago
brew: command not found: /usr/bin/ldd

ldd is required by Linuxbrew. It is a shell script provided by glibc. Please report…

which -a ldd
head -n1 /usr/bin/ldd /bin/ldd
falzm commented 5 years ago

Good catch, my system indeed didn't feature this command: I've copied it from another server and put it at /usr/bin/ldd, and now everything works fine. Thank a lot!

sjackman commented 5 years ago

Glad to hear it, Marc!

falzm commented 5 years ago

@sjackman just out of curiosity, is there a reason why you recommend using /home/linuxbrew? I don't have much space dedicated to /home so I moved /home/linuxbrew to /volume1/linuxbrew and symlinked it to /home/linuxbrew (and changed the $PATH variable accordingly), but now I get the following error using the brew command:

$ brew doctor
Error: Failure while executing; `/volume1/linuxbrew/.linuxbrew/bin/patchelf --print-needed /volume1/linuxbrew/.linuxbrew/Cellar/patchelf/0.9_1/bin/patchelf` exited with 1. Here's the output:

(no output printed)

sjackman commented 5 years ago

Does /volume1/linuxbrew/.linuxbrew/bin/patchelf --version work?

sjackman commented 5 years ago

Does /home/linuxbrew/.linuxbrew/bin/patchelf --version work?

sjackman commented 5 years ago

Install Linuxbrew in /home/linuxbrew/.linuxbrew/ if possible so that you can use precompiled binary packages (known as bottles) for non-relocatable formula.

The precompiled binary bottles of non-relocatable bottles can only be used if you install in /home/linuxbrew/.linuxbrew, otherwise they have to be built from source. See the documentation below. On macOS the default installation directory is /usr/local. On Linux the default installation directory is /home/linuxbrew/.linuxbrew.

falzm commented 5 years ago

Looks like it:

$ /volume1/linuxbrew/.linuxbrew/bin/patchelf --version
patchelf 0.9
sjackman commented 5 years ago

A symlink may work, but isn't fully tested, and may break in some cases.

falzm commented 5 years ago

I'm not sure I understand this correctly:

Cellar (cellar)

Optionally contains the value of HOMEBREW_CELLAR in which the bottles were built. Most compiled software contains references to its compiled location so cannot be simply relocated anywhere on disk. If this value is :any or :any_skip_relocation this means that the bottle can be safely installed in any Cellar as it did not contain any references to its installation Cellar. This can be omitted if a bottle is compiled (as all default Homebrew ones are) for the default HOMEBREW_CELLAR of /usr/local/Cellar.

Does it mean that if I set HOMEBREW_CELLAR=":any" I can move /home/linuxbrew/.linuxbrew/Cellar/ elsewhere?

sjackman commented 5 years ago

No, it means for a given formula if cellar is :any that bottle can be installed regardless of where Linuxbrew is installed. See for example hello, which is relocatable. https://github.com/Linuxbrew/homebrew-core/blob/master/Formula/hello.rb#L8

falzm commented 5 years ago

Is that normal that the bottled patchelf binary is static?

$ ldd /home/linuxbrew/.linuxbrew/bin/patchelf
    not a dynamic executable

Compared to the one I have on another Linux server:

$ ldd /usr/bin/patchelf
    linux-vdso.so.1 (0x00007ffcc93fc000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9455159000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9454e58000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9454c42000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9454897000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9455464000)

That could explain the Error: Failure while executing; /volume1/linuxbrew/.linuxbrew/bin/patchelf --print-needed /volume1/linuxbrew/.linuxbrew/Cellar/patchelf/0.9_1/bin/patchelf exited with 1 error 🤔

sjackman commented 5 years ago

Yes, patchelf is statically linked, so that it can be used before glibc and gcc are installed. You can however ignore that error. It's odd though that you are seeing. I'm not able to reproduce that behaviour myself. Other than brew doctor failing, is it working?

falzm commented 5 years ago

Besides that fact that I'm space-constrained in /home and since I cannot move /home/linuxbrew elsewhere I'll probably run out of space soon and won't be able to use it anymore, everything else seems to work yes :)

sjackman commented 5 years ago

Hah. You can install Linuxbrew in any directory you like. See https://linuxbrew.sh/#alternative-installation