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

Answer from Destroyica on Stack Exchange
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
🌐
GitHub
github.com › sclorg › scl-utils
GitHub - sclorg/scl-utils: Tool to setup and run software from Software Collection environment · GitHub
If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License.
Starred by 15 users
Forked by 23 users
Languages   C 79.8% | Shell 15.2% | CMake 5.0%
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_enterprise_linux › 6 › html › 6.5_technical_notes › scl-utils
8.195. scl-utils | 6.5 Technical Notes | Red Hat Enterprise Linux | 6 | Red Hat Documentation
If the PATH variable was not set as scl-utils expected it, executing the "scl enable" command produced a "command not found" error. This was caused by the scl utility calling the scl_enabled command without an absolute path, and relying on the PATH that the user has set.
🌐
Linux Man Pages
linux.die.net › man › 1 › scl
scl(1) - Linux man page
scl <action> [<collection1> <collection2> ...] <command> ... This manual page documents scl, a program which is an utility for running software packaged as a Software Collection.
🌐
ManKier
mankier.com › home › scl-utils
scl: Setup and run software from Software Collection environment | Man Page | Commands | scl-utils | ManKier
scl utility allows to execute an ... to the system one has to use scl utility as an interface. enable, run <collection1> [<collection2> ...] <command> [-x|--exec]...
🌐
Soton
linuxdesktops.soton.ac.uk › softwarecollections.html
Software collections (SCL) — Linux Desktops RHEL7 documentation
Once you have installed an SCL package you must first ‘enable’ its use and run a program with the package enabled. For example: ... This ‘enables’ the rh-python35 package (Python 3.5) and then runs the command bash.
🌐
SysTutorials
systutorials.com › docs › linux › man › 1-scl
scl: Setup and run software from Software Collection environment - Linux Manuals (1)
<collection> will no longer be considered SCL. If the <collection> was installed locally, then the use of --force is needed.i ... run set of commands listed in my_command file in the environment with baz Software Collection enabled
🌐
Codebar
tutorials.codebar.io › python › lesson0 › tutorial.html
Installation Guide
August 6, 2016 - Install scl-utils: yum install scl-utils · Install the extra repo needed for Pytyhon 3: rpm -Uvh https://www.softwarecollections.org/en/scls/rhscl/python33/epel-7-x86_64/download/rhscl-python33-epel-7-x86_64.noarch.rpm · Install Python 3 with this new repo: yum install Python33 (no the second 3 is not a typo) Run scn enable python3 /bin/bash.
Find elsewhere
🌐
University of Edinburgh
computing.help.inf.ed.ac.uk › scl
Software Collections | Documentation
You can use a function, such as function python() { scl enable rh-python36 python $*; } ...but we'd suggest not overriding defaults in this way except on a case-by-case basis.
🌐
LinuxConfig
linuxconfig.org › home › how to install python 3 on centos 7 with scl
How to install Python 3 on CentOS 7 with SCL
July 6, 2019 - The following command will install Software Collections and allow you to run applications from SCL shell: $ sudo yum install centos-release-scl scl-utils-build
🌐
Euro-linux
man.docs.euro-linux.com › el 9 › scl-utils › scl(1)
scl(1) — scl-utils
scl utility allows to execute an ... to the system one has to use scl utility as an interface. enable, run <collection1> [<collection2> ...] <command> [-x|--exec]...
🌐
UW PCE
uwpce-pythoncert.github.io › PythonCertDevel › supplemental › installing › python_for_linux.html
Setting Up Linux for Python — PythonCert 5.0 documentation
[centos@ip-172-31-21-5 ~]$ python2 ... install python3 using the package manager. Step one install “Software Collections” to help us: $ sudo yum -y install scl-utils ·...
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_enterprise_linux › 5 › html › 5.11_technical_notes › scl-utils
3.81. scl-utils | Red Hat Product Documentation
This update introduces a new way to call the "scl enable" command. The scl utility now supports the double dash (--) as a separator between collections and the command; using the separator makes calling the "scl enable" command more convenient.
🌐
Red Hat
docs.redhat.com › en › documentation › Red_Hat_Enterprise_Linux › 5 › html › 5.10_Technical_Notes › scl-utils.html
4.97. scl-utils | 5.10 Technical Notes | Red Hat Enterprise Linux | 5 | Red Hat Documentation
If the PATH variable was not set as expected by scl-utils, executing the "scl enable" command led to a "command not found" error message. This was caused by the scl utility calling the scl_enabled command without the absolute PATH and relying on the PATH set by the user.
🌐
Linuxcnf
linuxcnf.com › 2019 › 09 › how-to-enable-software-collections-scl.html
The Linux Guide: How to Enable Software Collections (SCL) yum repository on CentOS 7
Step 2. Verification: Verify the installation using the below command: Now the SCL repository is enabled using yum command.
🌐
Gitbook
uaf-rcs.gitbook.io › uaf-rcs-hpc-docs › third-party-software › using-software-collections-scl
Using Software Collections (SCL) | UAF-RCS HPC Documentation
March 28, 2020 - To launch a bash script (including a job script) that loads the python 3.6.X SCL, for example, put the following as the first line. ... Until the script exits, any python commands or scripts will then be executed using python 3.6.9 instead of the system default.