Brew: C compiler shim doesn't respect PATH

Created on 12 Sep 2017  路  5Comments  路  Source: Linuxbrew/brew

I have two versions of gcc installed on my machine, one in /usr/bin and another in ~/.local/bin. Even though my PATH puts the .local directory before the usr one, brew install still wants to use the (outdated) gcc under /usr/bin.

The only way I can force brew to use the intended gcc under ~/.local/bin is to change the ~/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/cc shim script to a soft link to ~/.local/bin/gcc.

I'm not quite sure what the shims are for, but I suppose this is not desired behavior? If possible, I think the user should be able to decide which compiler will be used in an intuitive way, i.e. by manipulating the PATH.

question

Most helpful comment

but that required installing glibc first, which I couldn't compile with the older (system) gcc compiler

Here's a relevant issue:
https://github.com/Linuxbrew/homebrew-core/issues/4077#issuecomment-329636939

This problem is relatively recent, since we upgraded from glibc 2.19 to 2.23. I'm working on a better solution. It's a tricky one though.

All 5 comments

Linuxbrew selects the most recent compiler that it knows of. It searches for compilers named gcc-4.x or gcc-x. Best solution is to brew install gcc
Otherwise see https://github.com/Linuxbrew/brew/wiki/Symlink-GCC

Thanks for the link! The newer compiler was named gcc-5.3, so that might have been the problem...? At any rate I still think it's a bit counterintuitive...

Best solution is to brew install gcc

... especially since brew installing gcc was actually what I was trying to do at the time, but that required installing glibc first, which I couldn't compile with the older (system) gcc compiler, so that's why I was trying to get brew to use my custom gcc in the first place :)

Maybe it would be nice to put a link to the wiki page in the instructions displayed after installing brew? Or in the tips which are displayed when glibc / gcc installation fails -- something along the lines of "If you need to bootstrap brew with a custom version of gcc, this is how you do it: \

The newer compiler was named gcc-5.3, so that might have been the problem...

Yep, it needs to be named gcc-5 and g++-5.

but that required installing glibc first, which I couldn't compile with the older (system) gcc compiler

Here's a relevant issue:
https://github.com/Linuxbrew/homebrew-core/issues/4077#issuecomment-329636939

This problem is relatively recent, since we upgraded from glibc 2.19 to 2.23. I'm working on a better solution. It's a tricky one though.

Here's instructions to install Linuxbrew on CentOS 6 without sudo. https://github.com/Linuxbrew/brew/wiki/CentOS6
Which distribution of Linux are you using?

Was this page helpful?
0 / 5 - 0 ratings