2 installations on 2 Linux distributions 2 different behaviors

I try to install linuxbrew on 2 Linux distributions:

  • one installation on travis (with gcc and git uninstalled)
  • another installation on a fresh arch linux (no git and gcc installed)

1st case on travis ci

The installation on travis works, you can see brew config on L419 (output below):

$ HOMEBREW_NO_ENV_FILTERING=1 brew config
HOMEBREW_VERSION: >=2.2.0 (shallow or no git repository)
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 5e63d0cef777242f4b238ff135ea27c08a88b807
Last commit: 5 hours ago
Core tap: N/A
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CACHE: /home/travis/VSCode-Anywhere/apps/vscode-anywhere/home/.cache/Homebrew
HOMEBREW_LOGS: /home/travis/VSCode-Anywhere/apps/vscode-anywhere/home/.cache/Homebrew/Logs
HOMEBREW_NO_ANALYTICS_THIS_RUN: 1
HOMEBREW_NO_ENV_FILTERING: 1
CPU: dual-core 64-bit skylake
Homebrew Ruby: 2.6.3 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: N/A
Git: 2.25.1 => /home/travis/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/git
Curl: 7.58.0 => /usr/bin/curl
Kernel: Linux 5.0.0-1031-gcp x86_64 GNU/Linux
OS: Ubuntu 18.04.4 LTS (bionic)
Host glibc: 2.27
/usr/bin/gcc: N/A
glibc: N/A
gcc: N/A
xorg: N/A

The installation continues and installs git with success on L449

2nd case on arch linux

I run the same script on a fresh arch Linux:

$ HOMEBREW_NO_ENV_FILTERING=1 brew config
HOMEBREW_VERSION: 2.2.10
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 48a1637b24a0c329905a981f4cff547c7fa47943
Last commit: 2 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/linuxbrew-core
Core tap HEAD: 758fc5db57acb5d42a5774f524db6905a22c46ae
Core tap last commit: 3 hours ago
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CACHE: /home/gigix/VSCode-Anywhere/apps/vscode-anywhere/home/.cache/Homebrew
HOMEBREW_LOGS: /home/gigix/VSCode-Anywhere/apps/vscode-anywhere/home/.cache/Homebrew/Logs
HOMEBREW_NO_ENV_FILTERING: 1
CPU: quad-core 64-bit skylake
Homebrew Ruby: 2.6.3 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: N/A
Git: 2.25.1 => /home/gigix/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/git
Curl: 7.69.1 => /usr/bin/curl
Kernel: Linux 5.5.10-arch1-1 x86_64 GNU/Linux
OS: Unknown
Host glibc: 2.31
/usr/bin/gcc: N/A
glibc: N/A
gcc: N/A
xorg: N/A
$ HOMEBREW_NO_ENV_FILTERING=1 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: python is symlinked to python3
This will confuse build scripts and in general lead to subtle breakage.

Warning: No developer tools installed.
Install Clang or run `brew install gcc`.
$ HOMEBREW_NO_ENV_FILTERING=1 brew install git
==> Installing dependencies for git: patchelf, m4, gmp, mpfr, libmpc, isl@0.18, zlib, gcc, ncurses, gettext, bzip2, pcre2, openssl@1.1, curl, libbsd and expat
==> Installing git dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.10.x86_64_linux.bottle.tar.gz
Already downloaded: /home/gigix/VSCode-Anywhere/apps/vscode-anywhere/home/.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`.

I don’t understand why brew wants absolutely to recompile patchelf.

Workaround:

$ nix-env -i patchelf
installing 'patchelf-0.9'
$ cd /home/linuxbrew/.linuxbrew/bin/
$ ln -s $(command -v patchelf) .
$ ls -l
total 4
lrwxrwxrwx 1 gigix gigix 44 23 mars  14:55 brew -> /home/linuxbrew/.linuxbrew/Homebrew/bin/brew
lrwxrwxrwx 1 gigix gigix 79 23 mars  20:03 patchelf -> /home/gigix/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/patchelf
$ $ brew install git
==> Installing dependencies for git: patchelf, m4, gmp, mpfr, libmpc, isl@0.18, zlib, gcc, ncurses, gettext, bzip2, pcre2, openssl@1.1, curl, libbsd and expat
==> Installing git dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.10.x86_64_linux.bottle.tar.gz
Already downloaded: /home/gigix/VSCode-Anywhere/apps/vscode-anywhere/home/.cache/Homebrew/downloads/405227c46362964d2bc2e9ff6428fe082dff4dbd3a4b0b29453743f71923304b--patchelf-0.10.x86_64_linux.bottle.tar.gz
==> Pouring patchelf-0.10.x86_64_linux.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /home/linuxbrew/.linuxbrew
Could not symlink bin/patchelf
Target /home/linuxbrew/.linuxbrew/bin/patchelf
already exists. You may want to remove it:
  rm '/home/linuxbrew/.linuxbrew/bin/patchelf'

To force the link and overwrite all conflicting files:
  brew link --overwrite patchelf

To list all files that would be deleted:
  brew link --overwrite --dry-run patchelf

Possible conflicting files are:
/home/linuxbrew/.linuxbrew/bin/patchelf -> /home/gigix/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/patchelf
...
...
...
$ command -v git
/home/linuxbrew/.linuxbrew/bin/git
$ brew link --overwrite patchelf
Linking /home/linuxbrew/.linuxbrew/Cellar/patchelf/0.10... 3 symlinks created
$ ls -l patchelf 
lrwxrwxrwx 1 gigix gigix 36 23 mars  20:09 patchelf -> ../Cellar/patchelf/0.10/bin/patchelf

Note that I don’t want to install anything via the OS package manager (pacman in this case) like gcc because I want to simulate a lambda user without root access.

I also try to install gcc with nix but brew does not detect it:

$ command -v gcc
/home/gigix/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/gcc

I also try to install gcc with nix but brew does not detect it

Homebrew tries to rely only on it’s own formulae on linux. This is intended behavior.

As for the difference between Ubuntu LTS and Arch Linux, there’s so many things those distros do exactly the opposite in. Maybe Ubuntu LTS ships with a different Clang in addition to GCC. This is just too broad a question to answer.

I understand but brew detects nothing and it works.

On the ubuntu (travis) brew config reports no clang and no gcc detected (apt-get --purge remove gcc clang) but the installation success:

Clang: N/A
/usr/bin/gcc: N/A
gcc: N/A

I’m pretty sure to install the patchelf bottle manually works but I haven’t try. If that is the case it would be a shame to block the user for that.

I don’t understand why patchelf refuses to install, there is surely a good reason but with my workaround it works…

Probably it’s best to try to reproduce this in a Docker image. It’s not clear whether this is a result of your specific machine’s configuration or an actual problem that brew could fix.