Enable devtoolset-8 for zsh on Centos 7

2.7k views Asked by At

I run Centos 7, and I installed devtoolset-8 in order to get gcc 8. Here I found how to enable it for bash, which is done simply by adding

source scl_source enable devtoolset-8

to .bashrc.

If I append this to the .zshrc, or run that command from within zsh, I get

/usr/bin/scl_source:58: = not found

It seems that in scl-utils there is no zsh support (see this discussion).

Is there a way of enabling devtoolset-8 it for zsh?

Currently, I set the gnome terminal emulator to run zsh instead of the shell (bash), so I thought that the correct version of devtools would be inherited by zsh, but it's not the case. As I open the terminal, % gcc --version (in zsh) gives

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
...

but if I first run bash, then $ gcc --version gives what's expected,

gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
...

Apparently, I don't understand what gnome-terminal is actually doing when I have it run zsh instead of the bash shell. What am I not understanding?

2

There are 2 answers

0
berberto On BEST ANSWER

A work-around that I found is to set gnome-terminal to run

bash -c "$HOME/.bashrc; exec zsh"

as a custom command in place of the default shell, which is equivalent to opening a terminal emulator with

gnome-terminal -- bash -c "$HOME/.bashrc; exec zsh"

adapted from here.

0
FunkyBeats99 On

It seems you could also use:

source /opt/rh/devtoolset-8/enable

Tested on RHEL7.6 for package rh-php73, it worked:

source /opt/rh/rh-php73/enable

Found the hint here