Solve it by using echo "source /opt/rh/devtoolset-8/enable" >> /etc/profile

Answer from GOGO on Stack Overflow
Top answer
1 of 5
93

In your ~/.bashrc or ~/.bash_profile Simply source the "enable" script provided with the devtoolset. For example, with the Devtoolset 2, the command is:

source /opt/rh/devtoolset-2/enable

or

source scl_source enable devtoolset-2

Lot more efficient: no forkbomb, no tricky shell

2 of 5
17

An alternative of source /opt/rh/devtoolset-4/enable is

source scl_source enable devtoolset-4

The above shell script scl_source is more elegant than using a hard coded path (may be different on another machine). However scl_source does less because /opt/rh/devtoolset-4/enable uses scl_source and other stuff.

To use scl_source you may have to upgrade package scl-utils

yum update scl-utils  # old scl-utils versions miss scl_source

Quick copy-paste

echo 'source scl_source enable devtoolset-4' >> ~/.bashrc
    # Do not forget to change the version ↑

Source code for curious people

An example of scl_source source code:
https://gist.github.com/bkabrda/6435016

The scl_source installed on my Red Hat 7.1

#!/bin/bash

_scl_source_help="Usage: source scl_source <action> [<collection> ...]

Don't use this script outside of SCL scriptlets!

Options:
    -h, --help    display this help and exit"

if [ $# -eq 0 -o $1 = "-h" -o $1 = "--help" ]; then
    echo "$_scl_source_help"
    return 0
fi


if [ -z "$_recursion" ]; then
    _recursion="false"
fi
if [ -z "$_scl_scriptlet_name" ]; then
    # The only allowed action in the case of recursion is the same
    # as was the original
    _scl_scriptlet_name=$1
fi
shift 1

if [ -z "$_scl_dir" ]; then
    # No need to re-define the directory twice
    _scl_dir=/etc/scl/conf
    if [ ! -e $_scl_dir ]; then
        _scl_dir=/etc/scl/prefixes
    fi
fi

for arg in "$@"; do
    _scl_prefix_file=$_scl_dir/$arg
    _scl_prefix=`cat $_scl_prefix_file 2> /dev/null`
    if [ $? -ne 0 ]; then
        echo "Can't read $_scl_prefix_file, $arg is probably not installed."
        return 1
    fi

    # First check if the collection is already in the list
    # of collections to be enabled
    for scl in ${_scls[@]}; do
        if [ scl ]; then
            continue 2
        fi
    done

    # Now check if the collection isn't already enabled
    /usr/bin/scl_enabled $arg > /dev/null 2> /dev/null
    if [ $? -ne 0 ]; then
        _scls+=($arg)
        _scl_prefixes+=($_scl_prefix)
    fi;
done

if [ $_recursion == "false" ]; then
    _i=0
    _recursion="true"
    while [ {#_scls[@]} ]; do
        _scl_scriptlet_path="${_scl_prefixes[$_i]}/${_scls[$_i]}/${_scl_scriptlet_name}"
        source "$_scl_scriptlet_path"
        if [ $? -ne 0 ]; then
            echo "Can't source $_scl_scriptlet_name, skipping."
        else
            export X_SCLS="${_scls[$_i]} $X_SCLS"
        fi;
        _i=_i+1))
    done
    _scls=()
    _scl_prefixes=()
    _scl_scriptlet_name=""
    _recursion="false"
fi
Discussions

centos7 - Enable devtoolset-8 for zsh on Centos 7 - Stack Overflow
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 ap... More on stackoverflow.com
🌐 stackoverflow.com
linux - How to install gcc8 using devtoolset-8-gcc - Stack Overflow
I am using CentOS Linux release 7.3.1611 which has gcc 4.8.5 20150623 installed. I am looking for a way to install a newer version of gcc, specially 8.1. I found the following site on how to inst... More on stackoverflow.com
🌐 stackoverflow.com
Installing devtoolset-X
$ sudo dnf search toolset Last metadata expiration check: 2:26:13 ago on Mon 15 Nov 2021 05:10:30 AM EST. ============================================= Name & Summary Matched: toolset ==== gcc-toolset-10.x86_64 : Package that installs gcc-toolset-10 gcc-toolset-10-runtime.x86_64 : Package that handles gcc-toolset-10 Software Collection. gcc-toolset-11.x86_64 : Package that installs gcc-toolset-11 gcc-toolset-11-runtime.x86_64 : Package that handles gcc-toolset-11 Software Collection. gcc-toolset-9.x86_64 : Package that installs gcc-toolset-9 gcc-toolset-9-runtime.x86_64 : Package that handles gcc-toolset-9 Software Collection. So do dnf-install gcc-toolset-X, then scl enable devtoolset-X bash More on reddit.com
🌐 r/AlmaLinux
1
7
November 14, 2021
bash - How to disable devtoolset-8? - Stack Overflow
I have a bash script that executes the command scl enable devtoolset-8 'echo -e "%__ld $(which ld)\n%__nm $(which nm)\n%__objcopy $(which objcopy)\n%__objdump $(which objdump)\n%__strip $(which More on stackoverflow.com
🌐 stackoverflow.com
October 20, 2020
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360004312319-enable-scl-devtoolset
enable scl devtoolset – IDEs Support (IntelliJ Platform) | JetBrains
When you do scl enable devtoolset, it is simply pointing towards what devtoolset provides. ... And you will see that the g++ version has changed after enabling devtoolset. ... actually just a replacing the paths of the toolchain with a specific for devtoolset, seems doesn't work for me in all cases, something with link paths · anyway an applying that is a more correct way, isn't it? so bashrc script on remote host applies this to work properly, so default configured toolchain replaced on the compilation.
🌐
Softwarecollections
softwarecollections.org › en › scls › rhscl › devtoolset-8
Developer Toolset 8 — Software Collections
Install the collection: $ sudo yum install devtoolset-8 # 3. Start using software collections: $ scl enable devtoolset-8 bash
Find elsewhere
🌐
University of Edinburgh
computing.help.inf.ed.ac.uk › scl
Software Collections | Documentation
To activate the devtoolset you ... You can run any application or script you wish, it does not need to be a shell. The scl enable command is used to enable the specified software collection....
🌐
Calvin
borg.calvin.edu › resources-softwarecollections.html
Resources - Software Collections - Borg
April 18, 2024 - devtoolset-7 devtoolset-8 llvm-toolset-7 rh-python36 rust-toolset-7 · To enable and enter a specific software collection, issue the command: scl enable rh-python36 bash · Software Collections will restart your bash shell, and the requested software collection will be available.
🌐
Stack Overflow
stackoverflow.com › tags › software-collections › hot
Hottest 'software-collections' Answers - Stack Overflow
CentOS 8 already comes with GCC 8. On CentOS 7, you can install GCC 8 from Developer Toolset. First you need to enable the Software Collections repository: yum install centos-release-scl Then you ...
🌐
Stack Overflow
stackoverflow.com › questions › 43880358 › scl-enable-not-setting-path-with-bash
software collections - 'scl enable' not setting PATH with bash - Stack Overflow
I'm trying to use software collections on CentOS 6.8 server, but it won't set the environment variable PATH corectly if the command passed is "bash", but "tcsh" works... (however we don't use tcsh on this machine) ... $ scl --list devtoolset-4 python27 rh-java-common rh-perl524 rh-python35 $ which python /usr/bin/python $ python --version Python 2.6.6 $ scl enable python27 bash $ which python /usr/bin/python $ python --version Python 2.6.6 $ cat /opt/rh/python27/enable export PATH=/opt/rh/python27/root/usr/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64${LD_LIBRARY_
🌐
MTU Service Desk
servicedesk.mtu.edu › TDClient › 1801 › Portal › KB › ArticleDet
Linux Software Collections (scl) - Service Desk
May 2, 2018 - We expect most people will want to use ‘$ scl enable devtoolset-6 bash’ for their work. To modify your environment to always use a scl environment, add ‘source scl_source enable devtoolset-6’ to your ~/.bashrc .