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
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 - 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
Scl enable devtoolset-7 bash on Rocky 9
I didn’t find scl or devtoolset-7 to install. How should I do? Thank you very much. More on forums.rockylinux.org
🌐 forums.rockylinux.org
16
0
March 9, 2023
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
Solved: Bamboo how to set scl enable with docker environme...
Hello :) I am having a hard time to change GCC version on centos image. I use Docker image to build on a centos environment. I made my base image and I tried to use the image. I already set the "scl" command for my base image. I also gave these two commands inside of my Dockerfile. SHELL [... More on community.atlassian.com
🌐 community.atlassian.com
October 10, 2019
🌐
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.
🌐
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
Find elsewhere
🌐
CopyProgramming
copyprogramming.com › howto › how-to-permanently-enable-scl-centos-6-4
Linux: Enabling SCL on CentOS 6.4 Permanently: A Guide
April 2, 2023 - SCL Centos nodejs10 - still "secure/up-to-date", I need to install nodejs10 on a CentOS 7 box - so I tried using SCL to achieve this goal: #yum install centos-release-scl-rh #yum install rh-nodejs10 #scl enable rh-nodejs10 bash #node -v v10.10.0. So this version is not the most recent, but if all necessary patches are applied this should be OK. ... Given the frequency of inquiries, I authored a blog post on the topic, which can be accessed at http://developerblog.redhat.com/2014/03/19/permanently-enable-a-software-collection/. ... Instead of just adding source /opt/rh/devtoolset-1.1/enable in your .bashrc, you can opt for a more effective solution by including it.
🌐
Stack Overflow
stackoverflow.com › tags › software-collections › hot
Hottest 'software-collections' Answers - Stack Overflow
First you need to enable the Software Collections repository: yum install centos-release-scl Then you ... ... Permanently adding DTS to your development environment After installing the devtoolset: yum ...
🌐
Softwarecollections
softwarecollections.org › en › scls › rhscl › devtoolset-8
Developer Toolset 8 — Software Collections
# 1. Install a package with repository ... yum-config-manager --enable rhel-server-rhscl-7-rpms # 2. Install the collection: $ sudo yum install devtoolset-8 # 3. Start using software collections: $ scl enable devtoolset-8 bash...
🌐
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....
🌐
GitHub
github.com › rust-embedded › cross › issues › 566
Permanently enable scl in centos extending from x86_64-unknown-linux-gnu · Issue #566 · cross-rs/cross
July 1, 2021 - FROM rustembedded/cross:x86_64-unknown-linux-gnu RUN yum update -y && \ yum install centos-release-scl -y && \ yum install llvm-toolset-7 -y && \ yum install scl-utils -y && \ echo "source scl_source enable llvm-toolset-7" >> ~/.bash_profile
Author   cross-rs
🌐
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_
🌐
LinuxQuestions.org
linuxquestions.org › questions › red-hat-31 › make-not-using-developer-set-version-of-gcc-in-bash-4175615807
[SOLVED] make not using developer-set version of gcc in bash
October 17, 2017 - Hi! Code: [idae@rh69bdb scripts] cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.9 (Santiago) With this version, it's gcc 4.4
🌐
Red Hat
developers.redhat.com › blog › 2014 › 03 › 19 › permanently-enable-a-software-collection
Permanently Enable a Software Collection | Red Hat Developer
November 2, 2023 - $ cat /etc/profile.d/enablepython33.sh #!/bin/bash source /opt/rh/python33/enable export X_SCLS="`scl enable python33 'echo $X_SCLS'`"
🌐
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