I had this problem as well. I don't know why scl was failing to enable the environment, but I was able to get it to load with source /opt/rh/devtoolset-7/enable.

Answer from user561726 on serverfault.com
Discussions

linux - How to permanently enable newer version of software installed from SCL repo? - Unix & Linux Stack Exchange
So when you put it in your .bashrc, it creates a new shell...which loads your .bashrc, which runs scl enable devtoolset-1.1 bash, which creates a new shell, which loads your .bashrc... Forkbomb! You probably want something like this in your .bashrc: if [ "$(gcc -dumpversion)" != "4.7.2" ]; then ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
December 25, 2014
centos7 - How to `scl enable devtoolset-8 bash` when login in? - Stack Overflow
In my centos7, I tried to put scl enable devtoolset-8 bash command to ~/.bashrc but When I login in, processes of scl enable devtoolset-8 bash are started again and again until the process number r... More on stackoverflow.com
🌐 stackoverflow.com
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
docker - How to start another bash in Dockerfile - Stack Overflow
I want to update GCC from 4.4.7 to 4.7.2 in a container(CentOS 6.9) following this tutorial How to upgrade GCC on CentOS. In the end of the tutorial, the author uses scl enable devtoolset-1.1 bash to launch a new shell where all the environments are updated. More on stackoverflow.com
🌐 stackoverflow.com
April 27, 2017
🌐
Calvin
borg.calvin.edu › resources-softwarecollections.html
Resources - Software Collections - Borg
April 18, 2024 - To permanently enable a collection for your user account, you can add the following lines to your .bashrc: echo "source scl_source enable devtoolset-7" >> ~/.bashrc
🌐
Softwarecollections
softwarecollections.org › en › scls › rhscl › devtoolset-7
Developer Toolset 7 — Software Collections
Install the collection: $ sudo yum install devtoolset-7 # 3. Start using software collections: $ scl enable devtoolset-7 bash
🌐
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 ...
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
🌐
Jianshu
jianshu.com › p › 76fb9b6a781b
centos7 使用新版的gcc7 - Developer Toolset 7 - 云石畅想
September 11, 2020 - 为了避免每次手动生效,可以在.bashrc中设置: · $ source /opt/rh/devtoolset-7/enable or $ source scl_source enable devtoolset-7
🌐
University of Edinburgh
computing.help.inf.ed.ac.uk › scl
Software Collections | Documentation
As with the devtoolset the llvm-toolset packages are installed in an alternate location so that they can exist on a system alongside the standard versions. This means they are not in the standard path. To activate this collection you need to do something like this: scl enable llvm-toolset-7 bash ·
Find elsewhere
🌐
Red Hat
access.redhat.com › documentation › id-id › red_hat_developer_toolset › 7 › html-single › user_guide › index
User Guide Red Hat Developer Toolset 7 | Red Hat Customer Portal
In Red Hat Developer Toolset, the ... program on the command line, run the gcc compiler as follows: $ scl enable devtoolset-7 'gcc -o output_file source_file...'...
🌐
Softwarecollections
softwarecollections.org › en › scls › rhscl › devtoolset-8
Developer Toolset 8 — Software Collections
# 1. Install a package with repository ... # 2. Install the collection: $ sudo yum install devtoolset-8 # 3. Start using software collections: $ scl enable devtoolset-8 bash...
🌐
GitHub
github.com › sclorg › devtoolset-container › blob › master › 7-toolchain › Dockerfile
devtoolset-container/7-toolchain/Dockerfile at master · sclorg/devtoolset-container
PATH=/opt/app-root/src/bin:/opt/app-root/bin:/opt/rh/devtoolset-7/root/usr/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin · · RUN mkdir -p ${HOME} && \ groupadd -r default -f -g 1001 && \ usermod -g default default && \ chown -R 1001:1001 /opt/app-root /usr/bin/container-entrypoint /usr/bin/usage && \ chmod u+x /usr/bin/usage && \ rpm-file-permissions · · USER 1001 · · WORKDIR ${HOME} · # Enable the SCL for all bash scripts.
Author   sclorg
🌐
Stanford
confluence.slac.stanford.edu › display › SCSPub › Red+Hat+Software+Collections
Red Hat Software Collections - Scientific Computing Services Public - SLAC Confluence
July 5, 2024 - ksa@rhel6-64 $ scl enable devtoolset-7 'gcc --version' | head -1 gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
🌐
Red Hat
bugzilla.redhat.com › show_bug.cgi
1319936 – sudo is broken after installing devtoolset
Red Hat Bugzilla – Bug 1319936 · This site requires JavaScript to be enabled to function correctly, please enable it · Privacy Contact FAQ Legal
🌐
CERN
root-forum.cern.ch › t › gcc-7-3-1-not-available-when-generating-a-c-17-singularity-root-image › 32356
Gcc 7.3.1 not available when generating a C++17 Singularity ROOT image - ROOT - ROOT Forum
January 18, 2019 - ROOT Version: 6.14.08 _Platform: CentOS 7 Compiler: g++ Dear experts, I have run into a problem when trying to build root on CentOS 7. I have installed devtoolset-7-gcc* and enabled it via scl enable devtoolset-7 bash. Furthermore I have chosen the option -Dcxx17 for cmake and turned off the ...