Linuxbrew-core: Can't install gcc on WSL for Ubuntu

Created on 10 Jun 2019  Â·  24Comments  Â·  Source: Homebrew/linuxbrew-core

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • [x] are reporting a bug others will be able to reproduce and not asking a question or requesting software. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh. To get software added or changed in Homebrew please file a Pull Request
  • [x] have a problem with brew install (or upgrade, reinstall) a single, Homebrew/homebrew-core formula (not cask) on macOS? If it's a general brew problem please file this issue at Homebrew/brew: https://github.com/Homebrew/brew/issues/new/choose. If it's a Linux problem please file this issue at https://github.com/Homebrew/linuxbrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • [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 gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
  • [x] if brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

To help us debug your issue please explain:

  • What you were trying to do (and why)
    Trying to install gcc
  • What happened (include command output)
gkrishna@S03448-7480:~$ brew install --verbose --debug gcc
Updating Homebrew...
/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/zlib.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/[email protected]
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/patchelf.rb
==> Installing dependencies for gcc: patchelf, zlib, gmp, mpfr, libmpc and [email protected]
==> Installing gcc dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.10.x86_64_linux.bottle.tar.gz
/usr/bin/curl -q --show-error --user-agent Linuxbrew/2.1.4\ \(Linux\;\ x86_64\ Ubuntu\ 18.04.2\ LTS\)\ curl/7.58.0 --location --silent --head --request GET https://linuxbrew.bintray.com/bottles/patchelf-0.10.x86_64_linux.bottle.tar.gz
Already downloaded: /home/gkrishna/.cache/Homebrew/downloads/405227c46362964d2bc2e9ff6428fe082dff4dbd3a4b0b29453743f71923304b--patchelf-0.10.x86_64_linux.bottle.tar.gz
==> Verifying 405227c46362964d2bc2e9ff6428fe082dff4dbd3a4b0b29453743f71923304b--patchelf-0.10.x86_64_linux.bottle.tar.gz checksum
==> Pouring patchelf-0.10.x86_64_linux.bottle.tar.gz
tar xof /home/gkrishna/.cache/Homebrew/downloads/405227c46362964d2bc2e9ff6428fe082dff4dbd3a4b0b29453743f71923304b--patchelf-0.10.x86_64_linux.bottle.tar.gz -C /tmp/d20190610-2898-1iw4mdf
cp -pR /tmp/d20190610-2898-1iw4mdf/patchelf/. /home/linuxbrew/.linuxbrew/Cellar/patchelf
chmod -Rf +w /tmp/d20190610-2898-1iw4mdf
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`.
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:309:in `rescue in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:287:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:599:in `install_dependency'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:553:in `block in install_dependencies'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:553:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:553:in `install_dependencies'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:259:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:332:in `install_formula'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:264:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:262:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:262:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:102:in `<main>'
gkrishna@S03448-7480:~$ 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`.
gkrishna@S03448-7480:~$ brew config
HOMEBREW_VERSION: 2.1.4
ORIGIN: https://github.com/Homebrew/brew
HEAD: d5a90f6f4af0a8e3d0ff1d806fb65e1b3bdbbe42
Last commit: 2 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/linuxbrew-core
Core tap HEAD: f47fabd3e37b4c4d603da282810d1380a6116928
Core tap last commit: 52 minutes ago
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CACHE: /home/gkrishna/.cache/Homebrew
HOMEBREW_LOGS: /home/gkrishna/.cache/Homebrew/Logs
CPU: octa-core 64-bit skylake
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 => /usr/bin/git
Curl: 7.58.0 => /usr/bin/curl
Kernel: Linux 4.4.0-17763-Microsoft x86_64 GNU/Linux
OS: Ubuntu 18.04.2 LTS (bionic)
Host glibc: 2.27
/usr/bin/gcc: N/A
glibc: N/A
gcc: N/A
xorg: N/A
  • What you expected to happen
    Install gcc
  • Step-by-step reproduction instructions (by running brew install commands)
    brew install gcc
outdated question

Most helpful comment

Thanks @sjackman for response. Surprised that brew install gccworked after doing sudo apt-get install build-essential, sudo apt-get install binutils and sudo apt-get install file. The other day I did sudo apt-get install build-essential but couldnt install/find readelf. I chased this rabbit hole while trying to get brew install node. Anyhow it worked and thanks for your sincere response.

One another observation. I keep seeing this warning (i suppose) nice: cannot set niceness: permission denied all through out the process and it was quite annoying. I saw somewhere to ignore this as its an windows upstream known issue. But just wanted to report here.

All 24 comments

Hi, @stevesuh. Thanks for reporting this.

This is a bit of a strange one as to install GCC you need to install its dependencies, and one of them - patchelf - needs to build from source (which it can't do without GCC installed).

I can reproduce this on a brand new WSL install, before I install any of Homebrew's dependencies (done via sudo apt-get install build-essential). If you run sudo apt-get install build-essential (if you have enough permissions to do so), does brew install gcc then complete?

Yes we ran that first. I even just ran apt-get update and just tried brew install hello. It's still complaining about patchelf.

I"m gonna attempt to uninstall Ubuntu WSL and try an older version of the WSL.

You should only see this error message if you do not have /usr/bin/readelf installed. readelf is provided by the package binutils, which is a dependency of build-essential. So you should not see this error message if you have build-essential installed. Please report the output of…

which -a patchelf readelf
ls -l /usr/bin/readelf

Unfortunately we already uninstalled the WSL. We will see if it happens again.

Feel free to comment if you have further questions.

I am facing the same issue today. I m also trying to install GCC using the command.

brew install gcc

So I am following @sjackman instruction for troubleshooting and when I run

which -a patchelf readelf

I get nothing. And when I run

ls -l /usr/bin/readelf

I get this..

ls: cannot access '/usr/bin/readelf': No such file or directory

Btw, per the suggestion above from @issyl0 , I have done also.

sudo apt-get install build-essential

Dont know what else to try. Please help.

sudo apt-get install build-essential should install readelf. Please report the output of that command and also sudo apt-get install binutils. Try also sudo apt-get install file.

Thanks @sjackman for response. Surprised that brew install gccworked after doing sudo apt-get install build-essential, sudo apt-get install binutils and sudo apt-get install file. The other day I did sudo apt-get install build-essential but couldnt install/find readelf. I chased this rabbit hole while trying to get brew install node. Anyhow it worked and thanks for your sincere response.

One another observation. I keep seeing this warning (i suppose) nice: cannot set niceness: permission denied all through out the process and it was quite annoying. I saw somewhere to ignore this as its an windows upstream known issue. But just wanted to report here.

Glad to hear that you got it working! Thanks for following up.

nice: cannot set niceness: permission denied

Here's the upstream issue: https://github.com/microsoft/WSL/issues/1838 They reported it as being fixed, and others reported that they're still seeing this error.

I haven't seen it since updating to build 1903, personally.

@EshChn What Windows build are you running?

Windows 10

I suspect this bug is only fixed in development releases of Windows.

I was facing the same issue but the solution suggested by @sjackman worked for me.

had the same issue today, @sjackman solution worked form me as well.

Which fix did you use, exactly? sudo apt-get install build-essential ?

sudo apt-get install build-essential + sudo apt-get install binutils

Did build-essential not include binutils? I thought that it should.

I ran into this today also. sudo apt-get install build-essential was all I needed. After that brew install hello worked fine for me. Thanks!

Hello, I am running into the same problem. I tried sudo apt-get install build-essential and I get Not Found [IP: 91.189.88.31 80] E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-7/gcc-7_7.4.0-1ubuntu1~18.04_amd64.deb 404 Not Found [IP: 91.189.88.31 80]

sudo apt-get install build-essential

This is a debian/ubuntu command. This has nothing to do with homebrew, so we can't help with that.

@aymLL run sudo apt update btw.

@dawidd6 @aymLL yes sudo apt update fixed the fetching error. Thanks!

Was this page helpful?
0 / 5 - 0 ratings