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
🌐
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
🌐
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-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...
Find elsewhere
🌐
GitHub
github.com › sclorg › devtoolset-container › blob › master › 7-toolchain › Dockerfile
devtoolset-container/7-toolchain/Dockerfile at master · sclorg/devtoolset-container
usage="docker run -ti -v /src/app:/opt/app-root/src:z centos/devtoolset-7-toolchain-centos7 bash" · RUN yum install -y centos-release-scl-rh && \ INSTALL_PKGS="devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-gcc-gfortran devtoolset-7-gdb make" && \ yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ yum -y clean all --enablerepo='*' ·
Author   sclorg
🌐
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
🌐
Anl
polaris.taps.anl.gov › polaris › development › setup › centos.html
CentOS 7 — Polaris 26.02 documentation
sudo yum update sudo yum group install "Development Tools" sudo yum install centos-release-scl sudo yum-config-manager --enable rhel-server-rhscl-7-rpms sudo yum install devtoolset-9 sudo yum install devtoolset-9-gcc-plugin-devel scl enable devtoolset-9 bash # You can add this the line below ...
🌐
Chapel-lang
chapel-lang.org › docs › 2.1 › usingchapel › prereqs.html
Chapel Prerequisites — Chapel Documentation 2.1
sudo dnf install gcc gcc-c++ m4 perl python3 python3-devel bash make gawk git cmake sudo dnf install which diffutils sudo dnf install clang clang-devel llvm-devel ... sudo pacman -Syu sudo pacman -S base-devel sudo pacman -S cmake git python sudo pacman -S llvm14 clang14 · CentOS 7 Devtoolset 11 (but note CentOS 7 CHPL_LLVM=system incompatibility): sudo yum install centos-release-scl sudo yum install devtoolset-11-gcc* sudo yum install epel-release sudo scl enable devtoolset-11 bash sudo echo source scl_source enable devtoolset-11 >> ~/.bashrc sudo yum install git gcc gcc-c++ m4 perl tcsh bash python3 make gawk wget openssl-devel wget https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1.tar.gz tar xvzf cmake-3.25.1.tar.gz cd cmake-3.25.1 ./bootstrap make sudo make install sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1
🌐
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 ...
Top answer
1 of 1
1

This issue in this case is RedHat subscription channels. Though the subscription and software are free (provided you have an active subscription already), for some reason you have to make a 'special request' to RedHat as per:

https://access.redhat.com/solutions/472793

You can automate this by visiting:

https://www.redhat.com/wapps/try/RHSCL

(when logged into the support portal). This should automatically be approved after which you can attach a new subscription. Identify the pool id using:

subscription-manager list --available --all

To find the pool id:

 Subscription Name:   Software Collections and Developer Toolset
 Provides:            Red Hat Developer Tools (for RHEL Server)
                      Red Hat Developer Tools Beta (for RHEL Workstation)
                      Red Hat Software Collections Beta (for RHEL Server)
                      Red Hat Software Collections Beta (for RHEL Workstation)
                      Red Hat Software Collections (for RHEL Server)
                      Red Hat Developer Tools Beta (for RHEL Server)
                      Red Hat Developer Toolset (for RHEL Workstation)
                      Red Hat Software Collections Beta (for RHEL Client)
                      Red Hat Software Collections (for RHEL Workstation)
                      Red Hat Developer Toolset (for RHEL Server)
                      Red Hat Developer Tools (for RHEL Workstation)
                      Red Hat Software Collections (for RHEL Client) 
SKU:                 foobar 
Contract:            1234 Pool ID: XXXXXXXXXX

Then attach this and enable the newly available repos:

>subscription-manager attach --pool=XXXXXXXXXXXXXXXXXXXX
Successfully attached a subscription for: Software Collections and Developer Toolset
>subscription-manager repos --enable rhel-workstation-rhscl-7-rpms
Repository 'rhel-workstation-rhscl-7-rpms' is enabled for this system.
>subscription-manager repos --enable rhel-7-workstation-devtools-rpms
Repository 'rhel-7-workstation-devtools-rpms' is enabled for this system.

You can now install freely:

>yum update -y 
>yum install -y devtoolset-7-gcc-c++

Quite why they make you jump through so many hoops is explained by RedHat as follows:

-If you have a 2013 RHEL SKU with Standard or Premium service level, there should be no action on your part, and your subscription should have full access to RHSCL.

-If you have a 2010 or older RHEL SKU with Standard or Premium service level, you should contact Red Hat Customer Service to request the RHSCL SKU (and all related content) added to your account.

NOTE: Developer Toolset is now included as part of Red Hat Software Collections. This change was made on May 29, 2014.

As you had Red Hat Enterprise Linux Workstation, Standard subscription which is older RHEL SKU with Standard service level, you had to initiate a special request for it