Linuxbrew-core: brew install gcc fails. Actually everything fails because installing glibc fails...

Created on 21 Sep 2017  ·  99Comments  ·  Source: Homebrew/linuxbrew-core

To help us debug your issue please explain:

  • What you were trying to do (and why)

Install gcc because everything needs it. Also glibc.

  • What happened (include command output)
aersoares81@myserver:~> brew install gcc
Updating Homebrew...
==> Installing dependencies for gcc: glibc, xz, m4, gmp, mpfr, libmpc, isl
==> Installing gcc dependency: glibc
==> Downloading https://ftp.gnu.org/gnu/glibc/glibc-2.23.tar.gz
Already downloaded: /home/aersoares81/.cache/Homebrew/glibc-2.23.tar.gz
==> ../configure --disable-debug --disable-dependency-tracking --disable-silent-rules --prefix=/home/aersoares81/.linuxbrew/Cellar/glibc/2.23 --enable-obsolete-rpc --wit
==> make
Last 15 lines from /home/aersoares81/.cache/Homebrew/Logs/glibc/02.make:
gcc-6 -B/home/aersoares81/.linuxbrew/opt/binutils/bin/ canonicalize.c -c -std=gnu11 -fgnu89-inline  -O2 -Wall -Werror -Wundef -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes -Wold-style-definition   -fPIC   -ftls-model=initial-exec      -I../include -I/tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib  -I/tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /usr/local/gcc-6.3.0/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include -isystem /usr/local/gcc-6.3.0/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include-fixed -isystem /home/aersoares81/.linuxbrew/opt/linux-headers/include  -D_LIBC_REENTRANT -include /tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED     -o /tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib/canonicalize.os -MD -MP -MF /tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib/canonicalize.os.dt -MT /tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib/canonicalize.os
gcc-6 -B/home/aersoares81/.linuxbrew/opt/binutils/bin/ a64l.c -c -std=gnu11 -fgnu89-inline  -O2 -Wall -Werror -Wundef -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes -Wold-style-definition   -fPIC   -ftls-model=initial-exec      -I../include -I/tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib  -I/tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /usr/local/gcc-6.3.0/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include -isystem /usr/local/gcc-6.3.0/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include-fixed -isystem /home/aersoares81/.linuxbrew/opt/linux-headers/include  -D_LIBC_REENTRANT -include /tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED     -o /tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib/a64l.os -MD -MP -MF /tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib/a64l.os.dt -MT /tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib/a64l.os
cc1: all warnings being treated as errors
make[2]: *** [/tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib/setenv.o] Error 1
make[2]: *** Waiting for unfinished jobs....
setenv.c: In function ‘__unsetenv’:
setenv.c:279:6: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=parentheses]
   if (ep != NULL)
      ^
cc1: all warnings being treated as errors
make[2]: *** [/tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/build/stdlib/setenv.os] Error 1
make[2]: Leaving directory `/tmp/glibc-20170921-97952-cxeh2n/glibc-2.23/stdlib'
make[1]: *** [stdlib/subdir_lib] Error 2
make[1]: Leaving directory `/tmp/glibc-20170921-97952-cxeh2n/glibc-2.23'
make: *** [all] Error 2

READ THIS: https://github.com/Linuxbrew/brew/blob/master/docs/Troubleshooting.md#troubleshooting
Please do not report this issue to Homebrew/brew or Homebrew/core, which support macOS only.

/home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/utils/github.rb:226:in `raise_api_error': curl failed! curl: (35) error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm (GitHub::Error)
curl: (3) <url> malformed
        from /home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/utils/github.rb:184:in `open'
        from /home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/utils/github.rb:233:in `issues_matching'
        from /home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/utils/github.rb:272:in `issues_for_formula'
        from /home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/exceptions.rb:369:in `fetch_issues'
        from /home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/exceptions.rb:365:in `issues'
        from /home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/exceptions.rb:420:in `dump'
        from /home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:133:in `rescue in <main>'
        from /home/aersoares81/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:26:in `<main>'
aersoares81@myserver:~>

  • Other comments:

I also tried with HOMEBREW_CC=gcc-5 brew install gcc, and it also fails exactly the same way.

outdated stale user configuration

Most helpful comment

By the way, thank you so much, sjackman, for the extremely extensive support on this.

Happy to help! 😄

All 99 comments

Hi. On what Linux are you? You didn't fill out the issue template. Can you show us your brew config?

I have a similar problem. Everything involves gcc and glibc, and these two seem to be conflicting. The suggestion (below) to brew link --overwrite glibc, didn't help. The two relevant files turn out to be the same:

../Cellar/glibc/2.19_1/lib/libgcc_s.so.1 
../Cellar/gcc/5.3.0/lib/libgcc_s.so.1
==> Upgrading bison 
==> Installing dependencies for bison: glibc, gmp, mpfr, isl, gcc
==> Installing bison dependency: glibc
==> Downloading https://ftp.gnu.org/gnu/glibc/glibc-2.23.tar.gz
######################################################################## 100.0%
==> ../configure --disable-debug --disable-dependency-tracking --disable-silent-rules --prefix=/home/user/.linuxbrew/Cellar/glibc/2.23 --enable-obsolete-rpc --without-selinux --with-binutils=/hom
==> make
Last 15 lines from /home/user/.cache/Homebrew/Logs/glibc/02.make:
    -o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_clntout.o -MMD -MP -MF /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_clntout.o.dt -MT /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_clntout.o -c
gcc-5 -B/home/user/.linuxbrew/opt/binutils/bin/   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/config.h rpc_tblout.c \
    -o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_tblout.o -MMD -MP -MF /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_tblout.o.dt -MT /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_tblout.o -c
gcc-5 -B/home/user/.linuxbrew/opt/binutils/bin/   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/config.h rpc_sample.c \
    -o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_sample.o -MMD -MP -MF /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_sample.o.dt -MT /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_sample.o -c
gcc-5 -B/home/user/.linuxbrew/opt/binutils/bin/ rpcgen.c -c -std=gnu11 -fgnu89-inline  -O2 -Wall -Werror -Wundef -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes -Wold-style-definition          -D_RPC_THREAD_SAFE_ -I../include -I/home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc  -I/home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /home/user/.linuxbrew/Cellar/gcc/5.3.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include -isystem /home/user/.linuxbrew/Cellar/gcc/5.3.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed -isystem /home/user/.linuxbrew/opt/linux-headers/include  -D_LIBC_REENTRANT -include /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/libc-modules.h -DMODULE_NAME=nonlib -include ../include/libc-symbols.h       -D_RPC_THREAD_SAFE_ -o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/rpcgen.o -MD -MP -MF /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/rpcgen.o.dt -MT /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/rpcgen.o
gcc-5 -B/home/user/.linuxbrew/opt/binutils/bin/ /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_main.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_hout.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_cout.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_parse.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_scan.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_util.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_svcout.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_clntout.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_tblout.o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpc_sample.o  -o /home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpcgen
/home/user/.linuxbrew/opt/binutils/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make[2]: *** [/home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/build/sunrpc/cross-rpcgen] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23/sunrpc'
make[1]: *** [sunrpc/others] Error 2
make[1]: Leaving directory `/home/user/tmp/glibc-20170930-5669-vp71k6/glibc-2.23'
make: *** [all] Error 2
Error: Could not symlink lib/libgcc_s.so.1
Target /home/user/.linuxbrew/lib/libgcc_s.so.1
is a symlink belonging to gcc. You can unlink it:
  brew unlink gcc

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

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

Same question as above:

Hi. On what Linux are you? You didn't fill out the issue template. Can you show us your brew config?

Ya, I'm on CentOS-7. Config is below, along with relevant doctor output. (Note that I have reported two more issues regarding a new install, also on CentOS-7 - indeed that same machine, only a different account - but that's not this one. This one was working well but went haywire on the latest upgrade.)

I would run brew gist-logs glibc and maybe also gcc, but running it places personal information up on github, and I can't find a way to get that info locally and edit that out. If you guys can fix this, it could be helpful. I'll open an issue.

This is brew config:

brew config
HOMEBREW_VERSION: 1.3.1
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: 09208fb2af972b19a46f89ec8321232943e4c8d4
Last commit: 3 weeks ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: 661746ca8282ef6899ab4f8f40ca54bbae5cc925
Core tap last commit: 27 hours ago
HOMEBREW_PREFIX: /home/user/.linuxbrew
HOMEBREW_REPOSITORY: /home/user/.linuxbrew
HOMEBREW_CELLAR: /home/user/.linuxbrew/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://linuxbrew.bintray.com
CPU: 40-core 64-bit broadwell
Homebrew Ruby: 2.0.0-p648 => /home/user/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.0.0-p648/bin/ruby
Clang: N/A
Git: 2.7.4 => /usr/bin/git
Perl: /usr/bin/perl
Python: /home/user/.linuxbrew/opt/python/libexec/bin/python => /home/user/.linuxbrew/Cellar/python/2.7.13_1/bin/python2.7
Ruby: /usr/bin/ruby
Java: openjdk version "1.8.0_144"
Kernel: Linux 3.10.0-514.16.1.el7.x86_64 x86_64 GNU/Linux
OS: CentOS Linux release 7.4.1708 (Core) 
Host glibc: 2.17
/usr/bin/gcc: 4.8.5
glibc: 2.19_1
gcc: N/A
xorg: N/A

The only relevant thing appearing in brew doctor is right at the end:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  gcc

Warning: Broken symlinks were found. Remove them with `brew prune`:
  /home/dev/.linuxbrew/bin/c++
  /home/dev/.linuxbrew/bin/cc

Warning: Some installed formula are missing dependencies.
You should `brew install` the missing dependencies:
  brew install [email protected]

Run `brew missing` for more details.

Given the appearance of [email protected] in brew doctor, could this could be linked to this other problem (https://github.com/Linuxbrew/homebrew-core/issues/4538), which is appearing on my new install? (New, as in, a different account on the same machine.)

I’ve got the same problem as @DiagonalArg (“cannot find -lc”) on Ubuntu 12.04.5. When checking where Homebrew’s/binutils ld looks for libraries (via ld --verbose | grep DIR), I find that it is linked to non-existent directories such as /home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/lib64. The /home/linuxbrew/ part does not exist, and I have no idea where it is coming from.

For context, this was after several (long-existing) Homebrewed binaries suddenly stopped working with errors relating to glibc, and I tried fixing the problem by reinstalling glibc.

Here are my logs: https://gist.github.com/klmr/dc720b20733c31c2155af17afe5c52a4

I've got the same problem! It's somehow got the wrong username.

ld --verbose | grep DIR   
SEARCH_DIR("=/home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/x86_64-pc-linux-gnu/lib64"); SEARCH_DIR("=/home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/lib64"); SEARCH_DIR("=/usr/local/lib64"); SEARCH_DIR("=/lib64"); SEARCH_DIR("=/usr/lib64"); SEARCH_DIR("=/home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/x86_64-pc-linux-gnu/lib"); SEARCH_DIR("=/home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");

The apparent wrong user name is a red herring. brew's Superenv tells binutils what the library search path should be.

It's looking for the file libc.so in the directory $(linuxbrew --prefix glibc)/lib. Please report the output of…

linuxbrew --prefix
linuxbrew --prefix glibc
ls -l $(linuxbrew --prefix glibc)
ls $(linuxbrew --prefix glibc)/lib/
$ brew --prefix
/home/user/.linuxbrew

$ brew --prefix glibc
/home/user/.linuxbrew/opt/glibc

$ ls -l $(brew --prefix glibc)
lrwxrwxrwx 1 user user 22 Oct  6 00:32 /home/user/.linuxbrew/opt/glibc -> ../Cellar/glibc/2.19_1

$ ls $(brew --prefix glibc)/lib/
audit                 libanl.so.1              libcrypt-2.19.so  libgcc_s.so.1   libnsl.so.1            libnss_files.so         libpcprofile.so         librt-2.19.so        libutil.so.1
crt1.o                libBrokenLocale-2.19.so  libcrypt.a        libieee.a       libnss_compat-2.19.so  libnss_files.so.2       libpthread-2.19.so      librt.a              locale
crti.o                libBrokenLocale.a        libcrypt.so       libm-2.19.so    libnss_compat.so       libnss_hesiod-2.19.so   libpthread.a            librt.so             Mcrt1.o
crtn.o                libBrokenLocale.so       libcrypt.so.1     libm.a          libnss_compat.so.2     libnss_hesiod.so        libpthread_nonshared.a  librt.so.1           Scrt1.o
gconv                 libBrokenLocale.so.1     libc.so           libmcheck.a     libnss_db-2.19.so      libnss_hesiod.so.2      libpthread.so           libSegFault.so
gcrt1.o               libc-2.19.so             libc.so.6         libmemusage.so  libnss_db.so           libnss_nis-2.19.so      libpthread.so.0         libthread_db-1.0.so
ld-2.19.so            libc.a                   libdl-2.19.so     libm.so         libnss_db.so.2         libnss_nisplus-2.19.so  libresolv-2.19.so       libthread_db.so
ld-linux-x86-64.so.2  libcidn-2.19.so          libdl.a           libm.so.6       libnss_dns-2.19.so     libnss_nisplus.so       libresolv.a             libthread_db.so.1
libanl-2.19.so        libcidn.so               libdl.so          libnsl-2.19.so  libnss_dns.so          libnss_nisplus.so.2     libresolv.so            libutil-2.19.so
libanl.a              libcidn.so.1             libdl.so.2        libnsl.a        libnss_dns.so.2        libnss_nis.so           libresolv.so.2          libutil.a
libanl.so             libc_nonshared.a         libg.a            libnsl.so       libnss_files-2.19.so   libnss_nis.so.2         librpcsvc.a             libutil.so

I should point out that those 3 last posts relate to an attempted install of a newer version of glibc that gives a similar but slightly different error:

$ brew upgrade glibc
==> Upgrading 1 outdated package, with result:
glibc 2.23
==> Upgrading glibc 
==> Downloading https://ftp.gnu.org/gnu/glibc/glibc-2.23.tar.gz
Already downloaded: /home/user/.cache/Homebrew/glibc-2.23.tar.gz
==> ../configure --disable-debug --disable-dependency-tracking --disable-silent-rules --prefix=/home/user/.linuxbrew/Cellar/glibc/2.23 --enable-obsolete-rpc --without-selinux --with-binutils=/hom
==> make
Last 15 lines from /home/user/.cache/Homebrew/Logs/glibc/02.make:
    -o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_tblout.o -MMD -MP -MF /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_tblout.o.dt -MT /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_tblout.o -c
gcc-5 -B/home/user/.linuxbrew/opt/binutils/bin/   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/config.h rpc_sample.c \
    -o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_sample.o -MMD -MP -MF /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_sample.o.dt -MT /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_sample.o -c
gcc-5 -B/home/user/.linuxbrew/opt/binutils/bin/ rpcgen.c -c -std=gnu11 -fgnu89-inline  -O2 -Wall -Werror -Wundef -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes -Wold-style-definition          -D_RPC_THREAD_SAFE_ -I../include -I/home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc  -I/home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /home/user/.linuxbrew/Cellar/gcc/5.3.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include -isystem /home/user/.linuxbrew/Cellar/gcc/5.3.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed -isystem /home/user/.linuxbrew/opt/linux-headers/include  -D_LIBC_REENTRANT -include /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/libc-modules.h -DMODULE_NAME=nonlib -include ../include/libc-symbols.h       -D_RPC_THREAD_SAFE_ -o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/rpcgen.o -MD -MP -MF /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/rpcgen.o.dt -MT /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/rpcgen.o
gcc-5 -B/home/user/.linuxbrew/opt/binutils/bin/ /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_main.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_hout.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_cout.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_parse.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_scan.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_util.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_svcout.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_clntout.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_tblout.o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpc_sample.o  -o /home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpcgen
/home/user/.linuxbrew/opt/binutils/bin/ld: cannot find -lgcc_s
/home/user/.linuxbrew/opt/binutils/bin/ld: cannot find -lc
/home/user/.linuxbrew/opt/binutils/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make[2]: *** [/home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/build/sunrpc/cross-rpcgen] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23/sunrpc'
make[1]: *** [sunrpc/others] Error 2
make[1]: Leaving directory `/home/user/tmp/glibc-20171006-88014-59ol2h/glibc-2.23'
make: *** [all] Error 2

In addition, oddly, when I try to run that from other than my home directory, I get:

$ brew upgrade glibc
==> Upgrading 1 outdated package, with result:
glibc 2.23
==> Upgrading glibc 
sudo: unable to resolve current working directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
==> Downloading https://ftp.gnu.org/gnu/glibc/glibc-2.23.tar.gz
Already downloaded: /home/user/.cache/Homebrew/glibc-2.23.tar.gz
Error: No such file or directory - getcwd

Here's the line of code that's supposed to tell it where to find -lc:

      # Fix error ld: cannot find -lc when upgrading glibc and compiling with a brewed gcc.
      ENV["BUILD_LDFLAGS"] = "-L#{opt_lib}" if opt_lib.directory?

https://github.com/Linuxbrew/homebrew-core/blob/master/Formula/glibc.rb#L101

That -L#{opt_lib} option doesn't seem to be making it into your link line though.

gcc-5 -B/home/user/.linuxbrew/opt/binutils/bin/ /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_main.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_hout.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_cout.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_parse.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_scan.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_util.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_svcout.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_clntout.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_tblout.o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpc_sample.o  -o /home/user/tmp/glibc-20171006-179201-1igf3zt/glibc-2.23/build/sunrpc/cross-rpcgen
/home/user/.linuxbrew/opt/binutils/bin/ld: cannot find -lgcc_s
/home/user/.linuxbrew/opt/binutils/bin/ld: cannot find -lc

Can you please report the output of…

brew irb <<EOS
Formula["gcc"].installed?
Formula["gcc"].version
EOS

For troubleshooting and possible a hack workaround, you could try brew edit glibc and change

if gcc.installed? && ENV.compiler == "gcc-" + gcc.version.to_s.split(".")[0]

to

if true

Just for completeness’ sake, my output is a bit difference since Linuxbrew’s glibc is missing:

⟩⟩⟩ brew --prefix
/lustre/scratch115/realdata/mdt2/teams/miska/users/kr15/linuxbrew
⟩⟩⟩ brew --prefix glibc
/lustre/scratch115/realdata/mdt2/teams/miska/users/kr15/linuxbrew/Cellar/glibc/2.23
⟩⟩⟩ ls -l $(brew --prefix glibc)
ls: cannot access /lustre/scratch115/realdata/mdt2/teams/miska/users/kr15/linuxbrew/Cellar/glibc/2.23: No such file or directory

The interactive console reports

Switch to inspect mode.
Formula["gcc"].installed?
true
Formula["gcc"].version
#<Version::FromURL:0x00000003407e70 @version="5.4.0">

Replacing the check in glibc.rb by if true as you mentioned doesn’t change the error, and no -L option is added to the relevant command line. In fact, Formula['glibc'].opt_lib.directory? is false when inspected in brew irb (not surprising: the path doesn’t exist, since the formula isn’t installed; see above).

It says not installed, but brew list says it is.

$ brew irb <<EOS
> Formula["gcc"].installed?
> Formula["gcc"].version
> EOS
==> Interactive Homebrew Shell
Example commands available with: brew irb --examples
Switch to inspect mode.
Formula["gcc"].installed?
false
Formula["gcc"].version
#<Version::FromURL:0x000000038f8ce0 @version="5.4.0">

$ brew list
autoconf  berkeley-db@4  colordiff  gcc      glibc   gperf     libatomic_ops  libgcrypt     libtool       linux-headers  nettle   patchelf    python3        sqlite        unzip       zlib
autogen   binutils       curl       gdbm     gmp     guile     libbsd         libgpg-error  libunistring  m4             nmap     pcre        readline       swig          util-linux
automake  bison          dante      gettext  gnutls  help2man  libevent       libmpc        libxml2       mpfr           openssl  pkg-config  speedtest_cli  tmux          w3m
bdw-gc    bzip2          emacs      glib     gpatch  isl       libffi         libtasn1      libxslt       ncurses        p11-kit  python      speedtest-cli  transmission  xz

$ printenv PATH
/home/user/.linuxbrew/sbin:/home/user/.linuxbrew/bin:/home/user/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

$ ls .linuxbrew/bin/g*
g++-4.8                 gdbus                   getopt                  gio-querymodules        glibtool                gobject-query           gresource               guile-config
gapplication            gdbus-codegen           gettext                 glib-compile-resources  glibtoolize             gold                    gsettings               guile-snarf
gcc-4.8                 gencat                  gettextize              glib-compile-schemas    gnutls-certtool         gperf                   gtester                 guile-tools
gdbm_dump               getconf                 gettext.sh              glib-genmarshal         gnutls-cli              gpg-error               gtester-report          
gdbm_load               getdefs                 gfortran-4.8            glib-gettextize         gnutls-cli-debug        gpg-error-config        guild                   
gdbmtool                getent                  gio                     glib-mkenums            gnutls-serv             gprof                   guile     

$ ls -l gcc-4.8 g++-4.8 
lrwxrwxrwx 1 user user 12 May 10 14:38 g++-4.8 -> /usr/bin/g++
lrwxrwxrwx 1 user user 12 May 10 14:38 gcc-4.8 -> /usr/bin/gcc

$ which gcc
/usr/bin/gcc

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)

It says not installed, but brew list says it is.

Please report the output of

brew list --versions gcc
brew info gcc
brew irb <<<'Formula["gcc"].installed?'
brew irb <<<'Formula["gcc"].any_version_installed?'
brew irb <<<'Formula["gcc"].linked?'
brew irb <<<'Formula["gcc"].optlinked?'
brew irb <<<'Formula["gcc"].prefix_linked?

@klmr I'd suggest trying a fresh install of Linuxbrew if that works for you. Follow these instructions for Ubuntu 12 Precise. https://github.com/Linuxbrew/brew/wiki/Ubuntu-12-Precise

@klmr Can you please report the output of ld --verbose | grep DIR? Do any of the listed directories contain the file libc.so? On Ubuntu it should be at /usr/lib/x86_64-linux-gnu/libc.so

$ brew list --versions gcc                                                                                                                                                        
gcc 5.3.0                                                                                                                                                                                         

$ brew info gcc                                                                                                                                                                   
gcc: stable 5.4.0 (bottled), HEAD                                                                                                                                                                 
GNU compiler collection                                                                                                                                                                           
https://gcc.gnu.org/                                                                                                                                                                              
/home/user/.linuxbrew/Cellar/gcc/5.3.0 (1,352 files, 253.0MB)                                                                                                                                      
  Poured from bottle on 2016-06-27 at 16:46:04                                                                                                                                                    
From: https://github.com/Linuxbrew/homebrew-core/blob/master/Formula/gcc.rb                                                                                                                       
==> Dependencies                                                                                                                                                                                  
Build: bzip2 ✔                                                                                                                                                                                    
Required: zlib ✔, gmp ✘, libmpc ✔, mpfr ✘, isl ✘                                                                                                                                                  
Recommended: glibc ✘                                                                                                                                                                              
==> Options                                                                                                                                                                                       
--with-all-languages                                                                                                                                                                              
        Enable all compilers and languages, except Ada                                                                                                                                            
--with-java                                     
        Build the gcj compiler                  
--with-jit                                      
        Build the jit compiler                  
--with-nls                                      
        Build with native language support (localization)                                        
--without-fortran                               
        Build without the gfortran compiler     
--without-glibc                                 
        Build without glibc support             
--HEAD                                          
        Install HEAD version                    

$ brew irb <<<'Formula["gcc"].installed?'                                        
==> Interactive Homebrew Shell                  
Example commands available with: brew irb --examples                                             
Switch to inspect mode.                         
Formula["gcc"].installed?                       
false                                           

$ brew irb <<<'Formula["gcc"].any_version_installed?'                            
==> Interactive Homebrew Shell                  
Example commands available with: brew irb --examples                                             
Switch to inspect mode.                         
Formula["gcc"].any_version_installed?           
true                                            

$ brew irb <<<'Formula["gcc"].linked?'                                           
==> Interactive Homebrew Shell                  
Example commands available with: brew irb --examples                                             
Switch to inspect mode.                         
Formula["gcc"].linked?                          
false

$ brew irb <<<'Formula["gcc"].optlinked?'                                        
==> Interactive Homebrew Shell                  
Example commands available with: brew irb --examples
Switch to inspect mode.
Formula["gcc"].optlinked?
true

$ brew irb <<<'Formula["gcc"].prefix_linked?'
==> Interactive Homebrew Shell
Example commands available with: brew irb --examples
Switch to inspect mode.
Formula["gcc"].prefix_linked?
false

Seem like…

if gcc.installed? && ENV.compiler == "gcc-" + gcc.version.to_s.split(".")[0]

should be something like…

if gcc.any_version_installed? && ENV.compiler == "gcc-" + gcc.version.to_s.split(".")[0]

This logic looks pretty fragile though. Need a better way of determining if the selected compiler is provided by the host or brewed. Following the symlink of the compiler in the bin directory to see whether it's under brew --prefix is probably a better way to go.

Here's the line in the glibc Makefile where BUILD_LDFLAGS is added to the link line for cross-rpcgen: https://github.com/lattera/glibc/blob/master/sunrpc/Makefile#L169

$(objpfx)cross-rpcgen: $(cross-rpcgen-objs)
    $(BUILD_CC) $^ $(BUILD_LDFLAGS) -o $@

Well, both fixes you suggest return the same error:

Error: The original GCC specs file is missing: /home/user/.linuxbrew/Cellar/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/specs.orig

This file does exist, though:

~/.linuxbrew/Cellar/gcc/5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/specs.orig

This clearly needs a better fix. As a workaround for now, copy the file

~/.linuxbrew/Cellar/gcc/5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/specs.orig

to

~/.linuxbrew/Cellar/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/specs.orig

ld --verbose | grep DIR | tr ';' '\n' | sed 's/ *SEARCH_DIR("=\(.*\)")/\1/' shows the following:

/home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/x86_64-pc-linux-gnu/lib64
/home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/lib64
/usr/local/lib64
/lib64
/usr/lib64
/home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/x86_64-pc-linux-gnu/lib
/home/linuxbrew/.linuxbrew/Cellar/binutils/2.29.1/lib
/usr/local/lib
/lib
/usr/lib

Alas, none of these directories contains libc.so. I’ll try reinstalling Linuxbrew using the instructions you provided. Thanks!

Huh. That is indeed a problem. Does the file exist at /usr/lib/x86_64-linux-gnu/libc.so?
If it does and you have write permission to any of the above directories, a workaround would be to symlink the above file to that location. If you don't, you could brew edit glibc and set the environment variable LIBRARY_PATH to /usr/lib/x86_64-linux-gnu/libc.so. Another option is to reinstall binutils from source: brew reinstall -s binutils

Hi @sjackman ,

I opened #4670 and was instructed to join the discussion.

I tried two suggestion from https://github.com/Linuxbrew/homebrew-core/issues/4388#issuecomment-335019916 but both failed.

On my machine, I found that libc.so is under /usr/lib64/libc.so.
Therefore, I added ENV["LIBRARY_PATH"] = "/usr/lib64" after https://github.com/Linuxbrew/homebrew-core/blob/master/Formula/glibc.rb#L92 but the same error occurred again.

I cannot install binutils from source. It failed during configure:

configure: WARNING: you should use --build, --host, --target
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for gcc... gcc-5
checking for C compiler default output file name...
configure: error: in `/tmp/binutils-20171016-8733-lwnl7s/binutils-2.29.1':
configure: error: C compiler cannot create executables
See `config.log' for more details.

My system information is included in #4670.

Note that the linuxbrew claims that the minimal requirement is gcc 4.4 and linux 2.6.16, but I cannot install anything because current glibc-2.23 disable support of gcc 4.4: https://github.com/Linuxbrew/homebrew-core/commit/59b343a86689531bc59702e376654821f766b1c8#diff-eaf50caf94594abf81cb37c83a20e322. On my machine, I can only install glibc and gcc based on 6fb5dfd50895416bea3d00628b8d3b41fa1f4f32 before upgrading homebrew. Is it possible to provide older glibc for old compiler / linux?

Hi, Wush. Consider installing Linuxbrew in /home/linuxbrew/.linuxbrew/ if possible so that you can use precompiled binary packages (known as bottles) for non-relocatable formula like glibc.

If you don't have sudo access, you could consider opening a ticket with your systems department to ask that they create a linuxbrew role account with home directory /home/linuxbrew for the purpose of sharing software that is used by your group.

OS: CentOS release 6.8 (Final) (Final)

https://gist.github.com/anonymous/c080e352a764614b8d5f3bc045c85eb0#file-00-config-out-L21

If it's an option for you, try a fresh installation of Linuxbrew following these instructions:
https://github.com/Linuxbrew/brew/wiki/CentOS6
My apologies for the hassle.

Is it possible to provide older glibc for old compiler / linux?

We do in fact provide an older version of GCC 4.9 [email protected], whose binary bottle requires glibc ≥ 2.19 to use.

Linuxbrew doesn't currently handle the situation well when the host OS provides GCC < 4.7, and you want to install in your home directory. One possible solution is to install a new version of gcc from source first, before installing glibc.

What is the state of this? I would like to know if there is some action that we need to take to help people to get this to run.

I have sometimes a hard time to follow all the use cases with the different glibc/gcc versions. We have some wiki pages here https://github.com/Linuxbrew/brew/wiki that may need some updates and more details. Could somebody summarise a little bit the situation?

Installing in /home/linuxbrew/.linuxbrew should work just fine, regardless of the host system.
Installing elsewhere when the host provides gcc < 4.7 can be a bit tricky, because glibc requires gcc ≥ 4.7 to compiler from source.
We have workarounds for the common distributions in https://github.com/Linuxbrew/brew/wiki

@iMichka - I don't know if @sjackman is talking about a new install, but I'm at gcc 4.8 and I was not able to upgrade without the problems you see above.

Same here. gcc 5.4 and cannot install glibc, and linux brew is installed at $HOME/.linuxbrew

@paulhybryant Please report brew gist-logs glibc (or whichever formula failed to build).

The issue is fixed by

brew rm gcc
brew reinstall -s binutils
brew install glibc

Glad to hear that you got it working. Do you know why it was necessary to rebuild binutils from source? I take it the bottle didn't work for you. The bottle for binutils is meant to work on any system.

I forgot from which thread I saw that but it should be one of the issue in
linuxbrew.
Before I did the described steps, brew install glibc or brew install wget
will fail with
error like ld: cannot find -lc or ld: cannot find -lutil.

Rebuilding binutils from source solves that problem.

@paulhybryant Your workaround did not work for me. I'm still unable to install glibc.

HOMEBREW_VERSION: >1.2.0 (shallow or no git repository)
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: 3aecdc02948da03bb9feab52643eecfc02d903d5
Last commit: 29 hours ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: dbe8816162b3aeafc62fc551205e3bd937577d2b
Core tap last commit: 6 hours ago
HOMEBREW_PREFIX: /home/hg299/.linuxbrew
HOMEBREW_REPOSITORY: /home/hg299/.linuxbrew/Homebrew
HOMEBREW_CELLAR: /home/hg299/.linuxbrew/Cellar
HOMEBREW_CACHE: /home/hg299/.cache/Homebrew
HOMEBREW_CELLAR: /home/hg299/.linuxbrew/Cellar
HOMEBREW_DEV_CMD_RUN: 1
HOMEBREW_GIT_CONFIG_FILE: /home/hg299/.linuxbrew/Homebrew/.git/config
HOMEBREW_PREFIX: /home/hg299/.linuxbrew
HOMEBREW_REPOSITORY: /home/hg299/.linuxbrew/Homebrew
CPU: octa-core 64-bit nehalem
Homebrew Ruby: 2.3.3 => /home/hg299/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: N/A
Git: 2.9.5 => /home/hg299/usr/local/bin/git
Curl: 7.37.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/bin/python => /usr/bin/python2.7
Ruby: /usr/bin/ruby => /usr/bin/ruby.ruby2.1
Java: openjdk version "1.8.0_151"
Kernel: Linux 4.4.92-31-default x86_64 GNU/Linux
OS: openSUSE Leap 42.3 (n/a)
Host glibc: 2.22
/usr/bin/gcc: 4.8.5
glibc: N/A
gcc: N/A
xorg: N/A
~> brew install glibc
==> Downloading https://ftp.gnu.org/gnu/glibc/glibc-2.23.tar.gz
Already downloaded: /home/hg299/.cache/Homebrew/glibc-2.23.tar.gz
==> ../configure --disable-debug --disable-dependency-tracking --disable-silent-rules --prefix=/hom
==> make
==> make install
.....
rm -f /tmp/glibc-20171129-11566-12lc21e/glibc-2.23/build/elf/symlink.list
test ! -x /tmp/glibc-20171129-11566-12lc21e/glibc-2.23/build/elf/ldconfig || LC_ALL=C \
  /tmp/glibc-20171129-11566-12lc21e/glibc-2.23/build/elf/ldconfig  \
            /home/hg299/.linuxbrew/Cellar/glibc/2.23/lib /home/hg299/.linuxbrew/Cellar/glibc/2.23/lib64
/tmp/glibc-20171129-11566-12lc21e/glibc-2.23/build/elf/ldconfig: Warning: ignoring configuration file that cannot be opened: /home/hg299/.linuxbrew/Cellar/glibc/2.23/etc/ld.so.conf: No such file or directory
make[1]: Leaving directory '/tmp/glibc-20171129-11566-12lc21e/glibc-2.23'
==> Kept temporary files
Temporary files retained at /tmp/glibc-20171129-11566-12lc21e
Error: Failure while executing: /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/ldd /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/gencat
    not a dynamic executable

HOMEBREW_VERSION: >1.2.0

That's super old. Could you update first?

@iMichka I was given the 1.2 version when the system did not have a git (maybe this is another bug). So, I compiled and installed one. And, I removed the old brew and had a fresh install (when git was available).

But I still got the same error. BTW, I did not have the root permission.

~> brew install -d glibc
....
==> Downloading https://ftp.gnu.org/gnu/glibc/glibc-2.23.tar.gz
Already downloaded: /home/hg299/.cache/Homebrew/glibc-2.23.tar.gz
==> ../configure --disable-debug --disable-dependency-tracking --disable-silent-rules --prefix=/hom
==> make
==> make install
==> Kept temporary files
Temporary files retained at /tmp/glibc-20171129-13893-q6p0z
Error: Failure while executing: /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/ldd /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/gencat
    not a dynamic executable

/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/debrew.rb:11:in `raise'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/os/linux/elf.rb:68:in `initialize'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/os/linux/elf.rb:109:in `new'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/os/linux/elf.rb:109:in `metadata'
...

```
~> brew config
HOMEBREW_VERSION: 1.3.8
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: fbc16c2b5b62baea3e63bac5bf2e82f1e75126df
Last commit: 8 days ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: dbe8816162b3aeafc62fc551205e3bd937577d2b
Core tap last commit: 16 hours ago
HOMEBREW_PREFIX: /home/hg299/.linuxbrew
HOMEBREW_REPOSITORY: /home/hg299/.linuxbrew/Homebrew
HOMEBREW_CELLAR: /home/hg299/.linuxbrew/Cellar
HOMEBREW_CACHE: /home/hg299/.cache/Homebrew
HOMEBREW_CELLAR: /home/hg299/.linuxbrew/Cellar
HOMEBREW_GIT_CONFIG_FILE: /home/hg299/.linuxbrew/Homebrew/.git/config
HOMEBREW_PREFIX: /home/hg299/.linuxbrew
HOMEBREW_REPOSITORY: /home/hg299/.linuxbrew/Homebrew
CPU: octa-core 64-bit nehalem
Homebrew Ruby: 2.3.3 => /home/hg299/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: N/A
Git: 2.9.5 => /home/hg299/usr/local/bin/git
Curl: 7.37.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/bin/python => /usr/bin/python2.7
Ruby: /usr/bin/ruby => /usr/bin/ruby.ruby2.1
Java: openjdk version "1.8.0_151"
Kernel: Linux 4.4.92-31-default x86_64 GNU/Linux
OS: openSUSE Leap 42.3 (n/a)
Host glibc: 2.22
/usr/bin/gcc: 4.8.5
glibc: N/A
gcc: N/A

~> brew list
binutils bzip2 gmp linux-headers m4 patchelf xz zlib
````

I have also tried this. No luck.

Thanks.

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

If it's an option for you, you could open a ticket with your systems department to ask that they create a linuxbrew role account with home directory /home/linuxbrew for the purpose of sharing software that is used by your group.

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, but wherever it reads /usr/local, which is for macOS, read instead /home/linuxbrew/.linuxbrew.

Error: Failure while executing: /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/ldd /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/gencat
    not a dynamic executable

For troubleshooting, try…

brew install -dv glibc
/home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/ldd /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/gencat
file /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/gencat
/home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/gencat --version

@sjackman Thanks for the reminder. The error codes are actually the same as my previous post.

brew install -dv glibc
....
rm -f /tmp/glibc-20171129-23339-139dmxg/glibc-2.23/build/stubs.h
/tmp/glibc-20171129-23339-139dmxg/glibc-2.23/build/elf/sln /tmp/glibc-20171129-23339-139dmxg/glibc-2.23/build/elf/symlink.list
rm -f /tmp/glibc-20171129-23339-139dmxg/glibc-2.23/build/elf/symlink.list
test ! -x /tmp/glibc-20171129-23339-139dmxg/glibc-2.23/build/elf/ldconfig || LC_ALL=C \
  /tmp/glibc-20171129-23339-139dmxg/glibc-2.23/build/elf/ldconfig  \
            /home/hg299/.linuxbrew/Cellar/glibc/2.23/lib /home/hg299/.linuxbrew/Cellar/glibc/2.23/lib64
/tmp/glibc-20171129-23339-139dmxg/glibc-2.23/build/elf/ldconfig: Warning: ignoring configuration file that cannot be opened: /home/hg299/.linuxbrew/Cellar/glibc/2.23/etc/ld.so.conf: No such file or directory
make[1]: Leaving directory '/tmp/glibc-20171129-23339-139dmxg/glibc-2.23'
==> Kept temporary files
Temporary files retained at /tmp/glibc-20171129-23339-139dmxg
Error: Failure while executing: /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/ldd /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/gencat
    not a dynamic executable

/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/debrew.rb:11:in `raise'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/os/linux/elf.rb:68:in `initialize'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/os/linux/elf.rb:109:in `new'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/os/linux/elf.rb:109:in `metadata'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/os/linux/elf.rb:120:in `dynamically_linked_libraries'
.....
~> brew config
HOMEBREW_VERSION: 1.3.8
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: fbc16c2b5b62baea3e63bac5bf2e82f1e75126df
Last commit: 8 days ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: a034ee119aabb6777a727e50a63da2f142ab735c
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /home/hg299/.linuxbrew
HOMEBREW_REPOSITORY: /home/hg299/.linuxbrew/Homebrew
HOMEBREW_CELLAR: /home/hg299/.linuxbrew/Cellar
HOMEBREW_CACHE: /home/hg299/.cache/Homebrew
HOMEBREW_CELLAR: /home/hg299/.linuxbrew/Cellar
HOMEBREW_GIT_CONFIG_FILE: /home/hg299/.linuxbrew/Homebrew/.git/config
HOMEBREW_PREFIX: /home/hg299/.linuxbrew
HOMEBREW_REPOSITORY: /home/hg299/.linuxbrew/Homebrew
CPU: octa-core 64-bit nehalem
Homebrew Ruby: 2.3.3 => /home/hg299/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: N/A
Git: 2.9.5 => /home/hg299/usr/local/bin/git
Curl: 7.37.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/bin/python => /usr/bin/python2.7
Ruby: /usr/bin/ruby => /usr/bin/ruby.ruby2.1
Java: openjdk version "1.8.0_151"
Kernel: Linux 4.4.92-31-default x86_64 GNU/Linux
OS: openSUSE Leap 42.3 (n/a)
Host glibc: 2.22
/usr/bin/gcc: 4.8.5
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 and just ignore them. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /usr/bin/X11/libpng16-config
  /usr/bin/X11/ncursesw6-config
  /usr/bin/X11/python-config
  /usr/bin/X11/MagickCore-config
  /usr/bin/X11/python3.4m-config
  /usr/bin/X11/xslt-config
  /usr/bin/X11/ggz-config
  /usr/bin/X11/libpng-config
  /usr/bin/X11/curl-config
  /usr/bin/X11/xine-config
  /usr/bin/X11/pcre-config
  /usr/bin/X11/antlr-config
  /usr/bin/X11/pkg-config
  /usr/bin/X11/isolinux-config
  /usr/bin/X11/python2.7-config
  /usr/bin/X11/MagickWand-config
  /usr/bin/X11/ncursesw5-config
  /usr/bin/X11/cups-config
  /usr/bin/X11/libassuan-config
  /usr/bin/X11/icu-config
  /usr/bin/X11/Wand-config
  /usr/bin/X11/apu-1-config
  /usr/bin/X11/apr-1-config
  /usr/bin/X11/wv2-config
  /usr/bin/X11/ncurses5-config
  /usr/bin/X11/Magick-config
  /usr/bin/X11/libusb-config
  /usr/bin/X11/freetype-config
  /usr/bin/X11/pspell-config
  /usr/bin/X11/kde4-config
  /usr/bin/X11/gphoto2-config
  /usr/bin/X11/x86_64-suse-linux-gnu-pkg-config
  /usr/bin/X11/gphoto2-port-config
  /usr/bin/X11/python3-config
  /usr/bin/X11/python3.4-config
  /usr/bin/X11/gpg-error-config
  /usr/bin/X11/ncurses6-config
  /usr/bin/X11/xml2-config
  /usr/bin/X11/python2-config
  /usr/bin/X11/libart2-config
  /usr/bin/X11/libgcrypt-config
  /usr/bin/X11/sdl-config
  /usr/bin/X11/gpgme-config
  /usr/bin/X11/kf5-config
  /usr/lib/mit/bin/krb5-config

I was hoping that brew -dv would give a prompt where you could inspect further what's awry with the gencat executable. Sadly no prompt it seems.

As hack workaround, try commenting out this line:

raise ErrorDuringExecution, "#{command.join(" ")}\n#{libs.join("\n")}" unless $CHILD_STATUS.success?

https://github.com/Linuxbrew/brew/blob/master/Library/Homebrew/os/linux/elf.rb#L68
Then set export HOMEBREW_NO_AUTO_UPDATE=1 and try brew install again.
After glibc is installed, we can inspect what's up with gencat.

@sjackman Thanks. Glibc is installed. However, its post-installation failed.

==> make install
==> /home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/localedef -i en_GB -f UTF-8 en_GB.UTF-8
Last 15 lines from /home/hg299/.cache/Homebrew/Logs/glibc/post_install.01.localedef:
2017-11-29 20:44:52 +0000

/home/hg299/.linuxbrew/Cellar/glibc/2.23/bin/localedef
-i
en_GB
-f
UTF-8
en_GB.UTF-8

cannot create temporary file: /home/hg299/.linuxbrew/Cellar/glibc/2.23/lib64/locale/locale-archive.yLJQvd: No such file or directory
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall glibc`
==> Summary
🍺  /home/hg299/.linuxbrew/Cellar/glibc/2.23: 1,413 files, 88.2MB, built in 4 minutes 13 seconds

I tried to run "brew postinstall glibc" again. It reported the same error.

UPDTAE: So I manually created the directory .linuxbrew/Cellar/glibc/2.23/lib64/locale/. The post-installation finished with no errors. But gcc was still stuck.

gcc was then successfully installed. However, it did not pass the test.

~> brew test gcc
Testing gcc
==> /home/hg299/.linuxbrew/Cellar/gcc/5.4.0/bin/gcc-5 -o hello-c hello-c.c
Last 15 lines from /home/hg299/.cache/Homebrew/Logs/gcc/test.01.gcc-5:
2017-11-29 20:51:00 +0000

/home/hg299/.linuxbrew/Cellar/gcc/5.4.0/bin/gcc-5
-o
hello-c
hello-c.c

/usr/bin/X11/ld: cannot find -lc
collect2: error: ld returned 1 exit status
Error: gcc: failed
Failed executing: /home/hg299/.linuxbrew/Cellar/gcc/5.4.0/bin/gcc-5 -o hello-c hello-c.c
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1796:in `block in system'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1734:in `open'
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1734:in `system'
/home/hg299/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gcc.rb:299:in `block in <class:Gcc>'

When I tried to compile a helloworld.c with gcc.

~> gcc helloworld.c -o a
/home/hg299/.linuxbrew/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status

Try…

brew postinstall gcc

and check that /home/hg299/.linuxbrew/lib/libc.so exists.

@sjackman post-installed gcc with no errors. but it still failed the test (cannot find -lc).

~> brew postinstall gcc
==> Postinstalling gcc
==> Creating the GCC specs file: /home/hg299/.linuxbrew/Cellar/gcc/5.4.0/bin/../lib/gcc/x86_64-unkn

> brew test gcc
Testing gcc
==> /home/hg299/.linuxbrew/Cellar/gcc/5.4.0/bin/gcc-5 -o hello-c hello-c.c
Last 15 lines from /home/hg299/.cache/Homebrew/Logs/gcc/test.01.gcc-5:
2017-11-29 21:33:05 +0000

/home/hg299/.linuxbrew/Cellar/gcc/5.4.0/bin/gcc-5
-o
hello-c
hello-c.c

/usr/bin/X11/ld: cannot find -lc
collect2: error: ld returned 1 exit status
Error: gcc: failed

BTW, I already had these in my bash_profile

export XDG_DATA_DIRS="/home/hg299/.linuxbrew/share:$XDG_DATA_DIRS"

export MANPATH="/home/hg299/.linuxbrew/share/man:$HOME/usr/local/share/man:$MANPATH"
export INFOPATH="/home/hg299/.linuxbrew/share/info:$INFOPATH"
export PATH='/home/hg299/.linuxbrew/bin:/home/hg299/.linuxbrew/sbin':"$PATH"
/usr/bin/X11/ld: cannot find -lc

That's a strange path for ld. Do you have binutils installed by brew? Please report…

which -a ld
ld --verison
brew install binutils

Yes, it was already there. I installed it by brew install -s binutils

OK, let me rollback. I executed the following steps first.

~> brew remove glibc
~> brew remove binutils
~> brew install binutils
~> brew install glibc
~> mkdir -p /home/hg299/.linuxbrew/Cellar/glibc/2.23/lib64/locale/
~> brew postinstall glibc
~> brew install gcc
~> brew postinstall gcc

The above commands were executed with no errors (with the aforementioned workarounds)

~> brew test gcc
...
/usr/bin/X11/ld: cannot find -lc
collect2: error: ld returned 1 exit status
Error: gcc: failed
~> which -a ld
/home/hg299/.linuxbrew/bin/ld
/usr/bin/ld
/usr/bin/X11/ld
~> ld -v
GNU ld (GNU Binutils) 2.29.1
~> brew install binutils
Warning: binutils 2.29.1 is already installed
~> brew list
binutils  bzip2  gcc  glibc  gmp  isl  libmpc  linux-headers  m4  mpfr  patchelf  xz  zlib
~> gcc helloworld.c 
/home/hg299/.linuxbrew/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status

Report the output of…

brew postinstall gcc -v

The last few lines of the specs file should look like this:

*cpp_unique_options:
+ -isystem /home/sjackman/.linuxbrew/include

*link_libgcc:
-nostdlib -L/home/sjackman/.linuxbrew/Cellar/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0 -L/home/sjackman/.linuxbrew/lib

*link:
+ --dynamic-linker /home/sjackman/.linuxbrew/lib/ld.so -rpath /home/sjackman/.linuxbrew/lib

~> brew postinstall gcc -dv
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/hg299/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gcc.rb
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/hg299/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/glibc.rb
==> Postinstalling gcc
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/postinstall.rb (Formulary::FromPathLoader): loading /home/hg299/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gcc.rb
/home/hg299/.linuxbrew/Homebrew/Library/Homebrew/postinstall.rb (Formulary::FormulaLoader): loading /home/hg299/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/glibc.rb
==> Creating the GCC specs file: /home/hg299/.linuxbrew/Cellar/gcc/5.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.4.0/specs

The list few lines:

*cpp_unique_options:
+ -isystem /home/hg299/.linuxbrew/include

*link_libgcc:
-nostdlib -L/home/hg299/.linuxbrew/Cellar/gcc/5.4.0/lib/gcc/x86_64-unknown-linux-gnu/5.4.0 -L/home/hg299/.linuxbrew/lib

*link:
+ --dynamic-linker /home/hg299/.linuxbrew/lib/ld.so -rpath /home/hg299/.linuxbrew/lib

I'm running out of ideas. Sorry, Han.

Thanks @sjackman . I suspect this is caused by something else.

There is a missing step to generate "~/.linuxbrew/Cellar/glibc/2.23/etc/ld.so.conf" and run ldconfig for the cache.

However when I run ldconfig, I got:

ldconfig: file /home/hg299/.linuxbrew/lib/libgmp.so.10 is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libz.so is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libbz2.so is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libz.so.1.2.11 is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libisl.so.15.3.0 is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libgmpxx.so.4 is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libbz2.so.1 is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libgmpxx.so is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libmpfr.so.4.1.6 is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libgmp.so is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libisl.so is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libbz2.so.1.0 is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libmpc.so is truncated

ldconfig: file /home/hg299/.linuxbrew/lib/libmpfr.so.4 is truncated
.....

everything is truncated. What does that imply? The compiled libs are not compatible with the brew base? Interesting. I can confirm that the ldconfig is the brew's.

Linuxbrew uses RPATH embedded in each executable rather than ld.so.conf. It's not necessary to run ldconfig. The executables are modified with patchelf after they're installed. Most tools are fine with that, but ldconfig is not. It thinks they're "truncated".

Thanks anyway. I'm giving up. So the conclusion is that the current brew does not work on "openSUSE Leap 42.3" with a non-root account. I have seen similar posts somewhere else before.

I've successfully installed Linuxbrew as a non-root user on an OpenSUSE 42.3 Leap system using Docker. So, I'm afraid that I'm not able to replicate your issue. It appears to be unique to your system.

Here's the Dockerfile that I used for a user with sudo access:
https://github.com/Linuxbrew/docker/blob/master/opensuse/Dockerfile

Here's a Dockerfile script for a user that does not have sudo access:

FROM opensuse:leap
LABEL maintainer="Shaun Jackman <[email protected]>"

RUN zypper --non-interactive install curl git glibc-i18ndata gcc glibc-locale make sudo tar which \
    && localedef -i en_US -f UTF-8 en_US.UTF-8 \
    && useradd -m -s /bin/bash user

USER user
WORKDIR /home/user
ENV PATH=/home/user/.linuxbrew/bin:/home/user/.linuxbrew/sbin:$PATH \
    SHELL=/bin/bash \
    USER=user

RUN yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" \
    && brew config

CMD ["/bin/bash"]

Run these commands to test it:

docker build -t linuxbrew-opensuse .
docker run -it linuxbrew-opensuse
brew install hello
brew test glibc gcc hello

@sjackman Would this be helpful for you to find out what went wrong?

strace gcc helloworld.c

https://paste.fedoraproject.org/paste/uFvOPuXLRYsCQZF4xy3X7A

Actually, I tried the same thing on another cluster (Cent OS 6). I got the similar issue that ldd always tells me *** is not a dynamic executable.

I'm afraid that I don't have the time available to help troubleshoot. Sorry!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@hangong

I got the similar issue that ldd always tells me * is not a dynamic executable.

Though I don't know what was causing it, this particular error message should not occur with Linuxbrew 1.3.9.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@sjackman I tried your suggestion for installing to /home/linuxbrew to get around glibc failing (in my case it's failing due to the new compilers giving warnings for glibc and all warnings being treated as errors). Here is my gist-log here for the attempt at install glibc, https://gist.github.com/anonymous/5568abacbd36e5c29cc486131cc89322

Is there something else I need to do to have glibc install as bottle?

Thanks!
Nick

You're installing to /data/home/linuxbrew/.linuxbrew
https://gist.github.com/anonymous/5568abacbd36e5c29cc486131cc89322#file-00-config-out-L8
It ought to be /home/linuxbrew/.linuxbrew

gcc-7 -B/data/home/linuxbrew/.linuxbrew/opt/binutils/bin/ ../sysdeps/wordsize-64/strtoll.c -c -std=gnu11 -fgnu89-inline -fno-stack-protector -O2 -Wall -Werror -Wundef -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes -Wold-style-definition     -ftls-model=initial-exec   -U_FORTIFY_SOURCE   -I../include -I/tmp/glibc-20180120-12853-2vz38y/glibc-2.23/build/stdlib  -I/tmp/glibc-20180120-12853-2vz38y/glibc-2.23/build  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/7/include -isystem /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -isystem /data/home/linuxbrew/.linuxbrew/opt/linux-headers/include  -D_LIBC_REENTRANT -include /tmp/glibc-20180120-12853-2vz38y/glibc-2.23/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h       -o /tmp/glibc-20180120-12853-2vz38y/glibc-2.23/build/stdlib/strtoll.o -MD -MP -MF /tmp/glibc-20180120-12853-2vz38y/glibc-2.23/build/stdlib/strtoll.o.dt -MT /tmp/glibc-20180120-12853-2vz38y/glibc-2.23/build/stdlib/strtoll.o
setenv.c: In function ‘__unsetenv’:
setenv.c:279:6: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=dangling-else]
   if (ep != NULL)

https://gist.github.com/anonymous/5568abacbd36e5c29cc486131cc89322#file-02-make-L887
Well that's frustrating. You can edit the glibc formula with brew edit glibc to add the option --disable-werror to ./configure.
See https://www.gnu.org/software/libc/manual/html_node/Configuring-and-compiling.html

/usr/bin/gcc: 6.3.0

https://gist.github.com/anonymous/5568abacbd36e5c29cc486131cc89322#file-00-config-out-L28
You can try…

brew install glibc --cc=gcc-6
OS: Ubuntu 14.04.5 LTS (trusty)
Host glibc: 2.19
/usr/bin/gcc: 6.3.0

The default compiler on Ubuntu 14.04 is usually gcc-4.8. It's unusual that /usr/bin/gcc points to 6.3.0 on your system.

Excellent, @sjackman thanks so much for the speedy response! The warnings started to appear with gcc-6 it seems so the following did the trick.

brew install glibc --cc=gcc-5

And yes the main person who admins the server is a tad ridiculous, he moved /home/ to /data/home and then created a symlink from /data/home to /home, not sure why and so I'm sure there are several other quirky things as well on the system like the default compiler being different.

Thanks for the fix!

Glad that you got it working, Nick! Since you have that symlink of /home to /data/home, you could also use

brew install --force-bottle foo

to install whichever package foo that you want, including glibc. You could even set up an alias:

alias install='brew install --force-bottle'
install foo

Excellent, good to know

I am trying to install git in $HOME without root access or gcc (and $HOME != /user/linuxbrew) on Ubuntu 14.04. But it refuses to install glibc with Error: The following formula: glibc cannot be installed as a binary package and must be built from source.

I have read through the comments here, and tried several of the suggestions with no success. It is not clear whether there is any consensus whether it is possible or not. What is the final verdict? Impossible?

I'm not sure why that's an error for you. I believe it should be a warning. In any case, try…

brew install -s glibc
brew install gcc
brew install git
~$ brew install -s glibc
Error: The following flag:
  --build-from-source
requires building tools, but none are installed.
Install Clang or brew install gcc

I am trying to install git in $HOME without root access

Installing in $HOME requires a compiler, and it looks as though you do not have a compiler installed.
If you have root access, install in /home/linuxbrew/.linuxbrew, which does not require a compiler.
If you do not have root access, contact your system administrator and ask them to install a compiler.

Alternatively, open a ticket with your systems department to ask that they create a linuxbrew role account with home directory /home/linuxbrew for the purpose of sharing software that is used by your group.

Ok so you're saying it's impossible to install linuxbrew in $HOME with no root access and no gcc when $HOME is not /home/linuxbrew, is that right?

Yes, that's correct. If you're installing in $HOME with no root access, no compiler, and you have glibc < 2.23, it's (probably) impossible. If you had glibc ≥ 2.23 (Ubuntu 14.04 or later) you could use the precompiled gcc bottle.

The precompiled GCC bottle is compiled against glibc 2.23, and you have glibc 2.19. Before the precompiled GCC bottle can be used, you have to install glibc. The glibc bottle is not relocatable, so it must be compiled from source when installing in your home directory, which requires a compiler.

If you're technically savvy and are willing to do some troubleshooting on your own, you can try…

brew install --force-bottle glibc
brew install gcc
brew install git

I don't know how technically savvy I am, but for the sake of science:

~$ brew install --force-bottle glibc
==> Installing dependencies for glibc: patchelf, zlib, binutils, linux-headers
==> Installing glibc dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.9_1.x86_64_linux.bottle.tar.gz
Already downloaded: /home/user/.cache/Homebrew/patchelf-0.9_1.x86_64_linux.bottle.tar.gz
==> Pouring patchelf-0.9_1.x86_64_linux.bottle.tar.gz
🍺  /home/user/.linuxbrew/Cellar/patchelf/0.9_1: 6 files, 1.2MB
==> Installing glibc dependency: zlib
==> Downloading https://linuxbrew.bintray.com/bottles/zlib-1.2.11.x86_64_linux.bottle.tar.gz
Already downloaded: /home/user/.cache/Homebrew/zlib-1.2.11.x86_64_linux.bottle.tar.gz
==> Pouring zlib-1.2.11.x86_64_linux.bottle.tar.gz
🍺  /home/user/.linuxbrew/Cellar/zlib/1.2.11: 12 files, 423.5KB
==> Installing glibc dependency: binutils
==> Downloading https://linuxbrew.bintray.com/bottles/binutils-2.30.x86_64_linux.bottle.tar.gz
Already downloaded: /home/user/.cache/Homebrew/binutils-2.30.x86_64_linux.bottle.tar.gz
==> Pouring binutils-2.30.x86_64_linux.bottle.tar.gz
🍺  /home/user/.linuxbrew/Cellar/binutils/2.30: 5,002 files, 222.2MB
==> Installing glibc dependency: linux-headers
==> Downloading https://linuxbrew.bintray.com/bottles/linux-headers-4.4.80.x86_64_linux.bottle.tar.gz
Already downloaded: /home/user/.cache/Homebrew/linux-headers-4.4.80.x86_64_linux.bottle.tar.gz
==> Pouring linux-headers-4.4.80.x86_64_linux.bottle.tar.gz
🍺  /home/user/.linuxbrew/Cellar/linux-headers/4.4.80: 772 files, 3.7MB
==> Installing glibc
==> Downloading https://linuxbrew.bintray.com/bottles/glibc-2.23.x86_64_linux.bottle.tar.gz
Already downloaded: /home/user/.cache/Homebrew/glibc-2.23.x86_64_linux.bottle.tar.gz
==> Pouring glibc-2.23.x86_64_linux.bottle.tar.gz
==> Installing locale data for en_US.UTF-8
==> /home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
Last 15 lines from /home/user/.cache/Homebrew/Logs/glibc/post_install.01.localedef:
2018-03-27 10:02:27 -0700

/home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef
-i
en_US
-f
UTF-8
en_US.UTF-8

Warning: The post-install step did not complete successfully
You can try again using `brew postinstall glibc`

and then

~$ brew postinstall glibc
==> Postinstalling glibc
==> Installing locale data for en_US.UTF-8
==> /home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
Last 15 lines from /home/user/.cache/Homebrew/Logs/glibc/post_install.01.localedef:
2018-03-27 10:06:47 -0700

/home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef
-i
en_US
-f
UTF-8
en_US.UTF-8


READ THIS: https://github.com/Linuxbrew/brew/wiki/troubleshooting
Please do not report this issue to Homebrew/brew or Homebrew/core, which support macOS only.

These open issues may also help:
brew install glibc fails looking for gcc 5.5.0_1 specs file https://github.com/Linuxbrew/homebrew-core/issues/5707

Error: No developer tools installed.
Install Clang or brew install gcc

For science! 🔬 ☣️ :atom:
Try running…

/home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
brew install gcc
brew install git

So much for tech-savvy, lol. Here I get an error I do not understand at all:

$ /home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef
-bash: /home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef: No such file or directory

even though

$ ls -la /home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef
-r-xr-xr-x 1 user user 1434696 Feb 18  2016 /home/user/.linuxbrew/Cellar/glibc/2.23/bin/localedef

returns successfully. The file is definitely there, with executable permissions, but I cannot find it or execute it?

That means that the dynamic linker is missing. Report…

patchelf --print-interpreter ~/.linuxbrew/Cellar/glibc/2.23/bin/localedef
ls -l $(patchelf --print-interpreter ~/.linuxbrew/Cellar/glibc/2.23/bin/localedef)
ls -l ~/.linuxbrew/lib/ld.so
realpath ~/.linuxbrew/lib/ld.so

I remember now. glibc is intentionally not relocated because relocating its dynamic libraries breaks it. Relocating its executables would probably be fine. In any case, you can ignore this error for now and continue on with…

brew install gcc
brew install git

First:

$ patchelf --print-interpreter ~/.linuxbrew/Cellar/glibc/2.23/bin/localedef
/home/linuxbrew/.linuxbrew/Cellar/glibc/2.23/lib/ld-linux-x86-64.so.2
$ ls -l ~/.linuxbrew/lib/ld.so
lrwxrwxrwx 1 user user 67 Mar 27 10:06 /home/user/.linuxbrew/lib/ld.so -> /home/user/.linuxbrew/Cellar/glibc/2.23/lib/ld-linux-x86-64.so.2



md5-2d8fb914f29147ecd1a320015b54b845



$ realpath ~/.linuxbrew/lib/ld.so
The program 'realpath' is currently not installed. To run 'realpath' please ask your administrator to install the package 'realpath'



md5-0a3c7cb577ac036010b9e69b4362cc9d



$ brew install gcc
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
php-cs-fixer
==> Updated Formulae
amber           clinfo          git-ftp         kompose         [email protected]    php             teleport
ant             cockroach       gtk-doc         kubernetes-cli  media-info      picard-tools    terragrunt
apibuilder-cli  convmv          headphones      languagetool    mediaconch      planck          typescript
artifactory     dartsim         heroku          laszip          nuxeo           pmd             vala
azure-cli       dcm2niix        hwloc           libatomic_ops   openssl         pygobject3      vnu
ballerina       dovecot         ircd-hybrid     libqalculate    [email protected]     redis           webpack
buku            fades           jbig2enc        lmod            packer          rom-tools       yq
bzt             fonttools       joplin          mame            paket           rust            zstd
caddy           geth            kedge           mariadb         pdal            sbt

==> Installing dependencies for gcc: gmp, mpfr, libmpc, [email protected]
==> Installing gcc dependency: gmp
==> Downloading https://linuxbrew.bintray.com/bottles/gmp-6.1.2_2.x86_64_linux.bottle.tar.gz
Already downloaded: /home/user/.cache/Homebrew/gmp-6.1.2_2.x86_64_linux.bottle.tar.gz
==> Pouring gmp-6.1.2_2.x86_64_linux.bottle.tar.gz
Error: Failure while executing: ["readelf", "-d", "/home/user/.linuxbrew/Cellar/gmp/6.1.2_2/lib/libgmp.so.10.3.2"]
Warning: Bottle installation failed: building from source.
Error: The following formula:
  gmp
cannot be installed as a binary package and must be built from source.
Install Clang or brew install gcc

This seems like a new error than before. Have we succcessfully installed glibc, only to have same failure with gmp?

Well, we're making progress. Please report…

which -a readelf
readelf --version
readelf -d /home/user/.linuxbrew/Cellar/gmp/6.1.2_2/lib/libgmp.so.10.3.2
which -a file
file --version
file /home/user/.linuxbrew/Cellar/gmp/6.1.2_2/lib/libgmp.so.10.3.2
$ which -a readelf
/home/user/.linuxbrew/bin/readelf
/home/user/.linuxbrew/bin/readelf

why twice?

$ readelf --version
GNU readelf (GNU Binutils) 2.30

$ ls /home/user/.linuxbrew/Cellar/gmp
ls: cannot access /home/user/.linuxbrew/Cellar/gmp: No such file or directory

so obviously the other references to the gmp shared object also fail.

And finally

$ which -a file
/usr/bin/file

and

$ file --version
file-5.14
magic file from /etc/magic:/usr/share/misc/magic

Report…

HOMEBREW_STDERR=1 brew install -v gmp
$ HOMEBREW_STDERR=1 brew install -v gmp
==> Downloading https://linuxbrew.bintray.com/bottles/gmp-6.1.2_2.x86_64_linux.bottle.tar.gz
Already downloaded: /home/user/.cache/Homebrew/gmp-6.1.2_2.x86_64_linux.bottle.tar.gz
==> Verifying gmp-6.1.2_2.x86_64_linux.bottle.tar.gz checksum
==> Pouring gmp-6.1.2_2.x86_64_linux.bottle.tar.gz
tar xzf /home/user/.cache/Homebrew/gmp-6.1.2_2.x86_64_linux.bottle.tar.gz
/home/user/.linuxbrew/opt/patchelf/bin/patchelf --force-rpath --set-rpath /home/user/.linuxbrew/Cellar/gmp/6.1.2_2/lib:/home/user/.linuxbrew/lib /home/user/.linuxbrew/Cellar/gmp/6.1.2_2/lib/libgmp.so.10.3.2
/home/user/.linuxbrew/opt/patchelf/bin/patchelf --force-rpath --set-rpath /home/user/.linuxbrew/Cellar/gmp/6.1.2_2/lib:/home/user/.linuxbrew/lib /home/user/.linuxbrew/Cellar/gmp/6.1.2_2/lib/libgmpxx.so.4.5.2
brew: command not found: readelf
Error: Failure while executing: ["readelf", "-d", "/home/user/.linuxbrew/Cellar/gmp/6.1.2_2/lib/libgmp.so.10.3.2"]
Warning: Bottle installation failed: building from source.
Error: The following formula:
  gmp
cannot be installed as a binary package and must be built from source.
Install Clang or brew install gcc

But readelf is present and in my PATH as previously reported, so what gives...?

brew resets the PATH to /usr/bin:/bin by default. In this case it should display Please install either readelf (from binutils) or file. Odd that it's not displaying this error message.
Try…

HOMEBREW_NO_ENV_FILTERING=1 brew install gcc git

Definite progress! The last command appears to have installed gcc successfully, although it still barfs on git,

Error: The following formula:
  git
cannot be installed as a binary package and must be built from source.

I'm assuming something like brew install --build-from-source git is next, but I'll let you confirm first.

And the full output from last brew is on gist.

That's a strange error. It should install git from source using the gcc compiler that we just installed, Yep, the next step is brew install -s git.

Well brew install -s git did

==> Installing dependencies for git: gdbm, berkeley-db, libbsd, expat, perl, openssl, pkg-config, curl
==> Installing git dependency: gdbm
==> Downloading https://linuxbrew.bintray.com/bottles/gdbm-1.14.1_1.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gdbm-1.14.1_1.x86_64_linux.bottle.tar.gz
Error: Failure while executing: ["readelf", "-d", "/home/user/.linuxbrew/Cellar/gdbm/1.14.1_1/bin/gdbm_dump"]
Warning: Bottle installation failed: building from source.
==> Downloading https://ftp.gnu.org/gnu/gdbm/gdbm-1.14.1.tar.gz
######################################################################## 100.0%
==> ./configure --disable-silent-rules --without-readline --prefix=/home/user/.linuxbrew/Cellar/gdbm/1.14.1
==> make install
Last 15 lines from /home/user/.cache/Homebrew/Logs/gdbm/02.make:
2018-03-29 08:20:26 -0700

make
install


READ THIS: https://github.com/Linuxbrew/brew/wiki/troubleshooting
Please do not report this issue to Homebrew/brew or Homebrew/core, which support macOS only.

recognizing that readelf error, I then did HOMEBREW_NO_ENV_FILTERING=1 brew install --build-from-source git and got

gist of make not found error

So make is not installed? Is that not part of the gcc package? No, I guess it's its own brew package. Ok, so I then tried HOMEBREW_NO_ENV_FILTERING=1 brew install --build-from-source make. No error, but no install either...

==> Downloading https://ftp.gnu.org/gnu/make/make-4.2.1.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/home/user/.linuxbrew/Cellar/make/4.2.1_1
==> make install
Last 15 lines from /home/user/.cache/Homebrew/Logs/make/02.make:
2018-03-29 08:23:56 -0700

make
install


READ THIS: https://github.com/Linuxbrew/brew/wiki/troubleshooting
Please do not report this issue to Homebrew/brew or Homebrew/core, which support macOS only.

$ which make
<no result>
$ ls ~/.linuxbrew/bin/make
ls: cannot access /home/user/.linuxbrew/bin/make: No such file or directory

Please report brew gist-logs make or if that fails, post the contents of the directory /home/user/.cache/Homebrew/Logs/make/ or at least the file 02.make at https://gist.github.com

Try…

export HOMEBREW_NO_ENV_FILTERING=1
brew install --force-bottle make
brew install git

I couldn't get brew gist-logs to authenticate.

But I copy-pasted 02.make log to this gist. As you see, there is no error message. It seems to just set some environment variables and then conclude silently. Like it didn't even try to compile.

So anyway... --force-bottle worked. It's in the middle of a lengthy compilation of some dependency, perl, I think, looks like it may take a while to finish. But at this point I'm pretty sure it's going to install git.

make install

https://gist.github.com/ziggurism/2f80111cdf909dffae55f317fc55c767#file-02-make-L3-L4

The first thing that brew install -s make does is try to run make. 😜😶🤔
Glad that you're making progress!

oh whoops! I guess I was expecting it at the bottom, or I dunno. So anyway, what do you make of that 02.make file? Should there be a message reporting success or failure of the install?

In other news, git and all dependencies finished compiling. You're a freakin wizard, dude! I thought it was impossible because precompiled glibc had hardcoded pathnames. You did some black magic, I dunno.

Yeah, there should be an error, saying something like bash: make: command not found. I'm not sure why that error message is not printed.

Hah! I'm a ninja wizard. We need ninja and wizard emoji.

You should be mostly okay, but there may be some glibc features that don't work for you. localedef for example still isn't working for you (which is fixable with some patchelf hackery).

Now that we got to the end of this, I'm curious. What sort of system are you on that you're running Ubuntu 14, with no root access, and no compiler? The first two are pretty common on academic systems, but they would typically have a compiler installed. It's unusual not to have a compiler.

So to sum up, the key steps were

  1. $ patchelf --print-interpreter ~/.linuxbrew/Cellar/glibc/2.23/bin/localedef to get glibc to install,
  2. HOMEBREW_NO_ENV_FILTERING=1 brew install --force-bottle <whatever bottles are still being bad> for the rest.

By the way, thank you so much, sjackman, for the extremely extensive support on this.

patchelf --print-interpreter ~/.linuxbrew/Cellar/glibc/2.23/bin/localedef

That command doesn't do anything. =) It was just for troubleshooting. The key was…

HOMEBREW_NO_ENV_FILTERING=1 brew install --force-bottle glibc make

and ignore the brew postinstall glibc failure like a 🤠

By the way, thank you so much, sjackman, for the extremely extensive support on this.

Happy to help! 😄

Was this page helpful?
0 / 5 - 0 ratings