in a nutshell, here are some examples for how to install and configure

  • for python3 to get python3.9: dnf install -y python39 && alternatives --set python3 $(command -v python3.9)
  • for gcc to get gcc-12: dnf install gcc-toolset-12 && source scl_source enable gcc-toolset-12
  • for java to get java-17: dnf install java-17 && bin_java_filename=$(rpm -qa|grep java-17|xargs rpm -ql|grep "bin\/java$"|head -1) && alternatives --set java ${bin_java_filename}
  • tested on rocky8, rocky9

which repo has the newer software versions?

  • the old method using "SCL" was deprecated
  • the new method is to use a repo called "appstream"
  • here is a post written by the distro maintainers explaining the change https://developers.redhat.com/blog/2018/11/15/rhel8-introducing-appstreams
  • the repo is enabled by default

how to: install newer software versions?

  • for python3: dnf install python39
  • for gcc: dnf install gcc-toolset-12

how to: change the system default?

  • for python3: alternatives --set python3 $(command -v python3.9)
  • for gcc:
    • edit your user .bashrc or .bash_profile or create a new file under /etc/profile.d/ with the following: source scl_source enable gcc-toolset-12
    • i thought scl_source would go away in el8, el9 but apparently not
    • for more info on scl_source go to this link https://unix.stackexchange.com/a/195219/5510 or Permanently enable RHEL scl

p.s. what is the difference between alternatives and update-alternatives?

  • the original tool is called update-alternatives and is from Debian linux distro
  • in EnterpriseLinux, Redhat rewrote the tool and called it alternatives and when you install alternatives the package also installs a symlink with name update-alternatives on your env var PATH to help you find the tool
  • the two are similar but not the same because their source code is different
Answer from Trevor Boyd Smith on Stack Overflow
🌐
Ucsf
wynton.ucsf.edu › hpc › software › scl.html
Software Collections (SCL)
[alice@dev2 ~]$ scl enable gcc-toolset-12 "$SHELL" [alice@dev2 ~]$ gcc --version gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-7) Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions.
Discussions

linux - How to permanently enable newer version of software installed from SCL repo? - Unix & Linux Stack Exchange
On CentOS 6.4: I installed a newer version of devtoolset (1.1) and was wondering how I would go about permanently setting these to be default. Right now, when I ssh into my server running CentOS 6, I More on unix.stackexchange.com
🌐 unix.stackexchange.com
December 25, 2014
rhel8 - How to Install devtoolset 8 in RHEL 8 image - Stack Overflow
Please help me to install dev toolset-8 in rhel 8 image. i have pulled the base image as below . I want to install devtoolset-8. is there any other way please let me know. sudo docker pull registry. More on stackoverflow.com
🌐 stackoverflow.com
linux - "scl load gcc-toolset-11" run failed - Stack Overflow
But it failed. I want to know how to let scl load work normally. ... A work-around may be to "source /opt/rh/gcc-toolset-11/enable" as that appears to be the core functionality of "scl load", but I can't test further at the moment. 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
Top answer
1 of 1
1

in a nutshell, here are some examples for how to install and configure

  • for python3 to get python3.9: dnf install -y python39 && alternatives --set python3 $(command -v python3.9)
  • for gcc to get gcc-12: dnf install gcc-toolset-12 && source scl_source enable gcc-toolset-12
  • for java to get java-17: dnf install java-17 && bin_java_filename=$(rpm -qa|grep java-17|xargs rpm -ql|grep "bin\/java$"|head -1) && alternatives --set java ${bin_java_filename}
  • tested on rocky8, rocky9

which repo has the newer software versions?

  • the old method using "SCL" was deprecated
  • the new method is to use a repo called "appstream"
  • here is a post written by the distro maintainers explaining the change https://developers.redhat.com/blog/2018/11/15/rhel8-introducing-appstreams
  • the repo is enabled by default

how to: install newer software versions?

  • for python3: dnf install python39
  • for gcc: dnf install gcc-toolset-12

how to: change the system default?

  • for python3: alternatives --set python3 $(command -v python3.9)
  • for gcc:
    • edit your user .bashrc or .bash_profile or create a new file under /etc/profile.d/ with the following: source scl_source enable gcc-toolset-12
    • i thought scl_source would go away in el8, el9 but apparently not
    • for more info on scl_source go to this link https://unix.stackexchange.com/a/195219/5510 or Permanently enable RHEL scl

p.s. what is the difference between alternatives and update-alternatives?

  • the original tool is called update-alternatives and is from Debian linux distro
  • in EnterpriseLinux, Redhat rewrote the tool and called it alternatives and when you install alternatives the package also installs a symlink with name update-alternatives on your env var PATH to help you find the tool
  • the two are similar but not the same because their source code is different
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_developer_toolset › 12 › html-single › user_guide › index
User Guide | Red Hat Developer Toolset | 12 | Red Hat Documentation
In Red Hat Developer Toolset, the ... To compile a C++ program on the command line, run the g++ compiler as follows: $ scl enable devtoolset-12 'g++ -o output_file source_file...'...
🌐
Ucsf
c4.ucsf.edu › software › scl.html
Software Collections (SCL)
[alice@c4-dev2 ~]$ scl enable gcc-toolset-12 "$SHELL" [alice@c4-dev2 ~]$ gcc --version gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-7) Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions.
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
🌐
RPMfind
rpmfind.net › linux › RPM › centos-stream › 9 › appstream › ppc64le › gcc-toolset-12-runtime-12.0-5.el9.ppc64le.html
gcc-toolset-12-runtime-12.0-5.el9.ppc64le RPM
June 29, 2022 - /etc/rpm/macros.gcc-toolset-12-enable /etc/scl/prefixes/gcc-toolset-12 /opt/rh /opt/rh/gcc-toolset-12 /opt/rh/gcc-toolset-12/enable /opt/rh/gcc-toolset-12/root /opt/rh/gcc-toolset-12/root/bin /opt/rh/gcc-toolset-12/root/boot /opt/rh/gcc-toolset-12/root/dev /opt/rh/gcc-toolset-12/root/etc ...
Find elsewhere
🌐
SciVision
scivision.dev › install-modern-compilers-redhat
Use modern compilers in RHEL | Scientific Computing
July 2, 2023 - GCC Toolset enables modern compiler selection for RHEL users.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360004312319-enable-scl-devtoolset
enable scl devtoolset – IDEs Support (IntelliJ Platform) | JetBrains
2. the command is "source scl_source enable devtoolset-4" . here "4" constant depends which devtoolset you need, 4 refers to GCC531 for me
🌐
Computing Support
peden.ece.uw.edu › computing › linux-lab › custom-configuration-gcc
Custom Configuration – Modern gcc - UWECE Internal Website
We have installed the application streams for gcc 11 (gcc-toolset-11) and gcc 13 (gcc-toolset-13). To use either of these versions, you must run your shell under the desired software stream as shown below (what you type is in bold): $ which gcc /usr/bin/gcc $ gcc --version gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22) ... $ scl enable gcc-toolset-11 "$SHELL" $ which gcc /opt/rh/gcc-toolset-11/root/usr/bin/gcc $ gcc --version gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9) ...
🌐
Rocky Linux Forum
forums.rockylinux.org › rocky linux help & support
Devtoolset for Rocky Linux - Rocky Linux Help & Support - Rocky Linux Forum
September 9, 2021 - So we can use “Development Tools” from future e.g. Rocky 10.4 on Rocky 8.4 without upgrading the OS. – devtoolset: GNU Compiler Collection, GNU Debugger, and other development, debugging, and performance monitoring too…
🌐
Utk
help.eecs.utk.edu › knowledge-base › linux-topics › using-redhat-software-collections
Using Red Hat Software Collections [EECS IT Help]
user:hydra0 ~> scl list-collections gcc-toolset-11 gcc-toolset-12 gcc-toolset-13 gcc-toolset-14 gcc-toolset-9