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
🌐
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
Discussions

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
centos - How to make devtoolset g++ available for Makefile in docker's centos7? - Unix & Linux Stack Exchange
I am building a docker image from ... CentOS 7. The code that need to be compiled need some features in C++14/17 standard, thus i have to update the default gcc/g++ version from 4.8.5 to a higher version. I've read some post and article, do the following command to update the g++ in Dockerfile · RUN yum -y install centos-release-scl && \ yum -y install devtoolset-7-gcc* && ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
July 19, 2019
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
Announcing release of Developer Toolset 7 on CentOS Linux 7 x86_64 SCL - announce - lists.centos.org
$ sudo yum install centos-release-scl ... $ scl enable devtoolset-7 bash · At this point you should be able to use gcc and other tools just as a normal application. See examples bellow: $ gcc hello.c $ sudo yum install devtoolset-7-valgrind $ valgrind ./a.out $ gdb ./a.out · In order to view the individual components included in this collection, including additional development tools, you can run: ... Last but not least you can try this Software Collection in Docker... More on lists.centos.org
🌐 lists.centos.org
🌐
Docker Hub
hub.docker.com › r › centos › devtoolset-7-toolchain-centos7
centos/devtoolset-7-toolchain-centos7 - Docker Image
docker run -ti --rm -v /src/app:/opt/app-root/src:z rhscl/devtoolset-7-toolchain-rhel7 bash bash-4.3$ gcc -o foo -ggdb -g2 foo.c Copy
🌐
Austindewey
austindewey.com › 2019 › 03 › 26 › enabling-software-collections-binaries-on-a-docker-image
Enabling Software Collections Binaries On A Docker Image<!-- --> - Austin Dewey
An entrypoint can be written in the Dockerfile to enable the SCL binary on container startup. Here’s an example Dockerfile: FROM docker.io/centos:7 # Install SCL release package and python SCL RUN yum -y install centos-release-scl && \ yum -y install --setopt=tsflags=nodocs rh-python35 # Enable rh-python scl binary COPY entrypoint.sh /usr/bin/entrypoint.sh RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT [ "/usr/bin/entrypoint.sh" ]
Find elsewhere
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 [ $arg == $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 [ $_i -lt ${#_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
🌐
Softwarecollections
softwarecollections.org › en › scls › rhscl › devtoolset-8
Developer Toolset 8 — Software Collections
$ sudo yum install centos-release-scl-rh $ sudo yum-config-manager --enable centos-sclo-rh-testing $ sudo yum install devtoolset-8 · On CentOS 7 and RHEL 7 you can pull the images with the following commands: $ docker pull registry.access.redhat.com/rhscl/devtoolset-8-perftools-rhel7 $ docker ...
🌐
Centos
lists.centos.org › hyperkitty › list › announce@lists.centos.org › thread › 2APH7YUSNGVRJD5LAXBI46BBB5AKWHZZ
Announcing release of Developer Toolset 7 on CentOS Linux 7 x86_64 SCL - announce - lists.centos.org
$ sudo yum install centos-release-scl $ sudo yum install devtoolset-7 $ scl enable devtoolset-7 bash · At this point you should be able to use gcc and other tools just as a normal application. See examples bellow: $ gcc hello.c $ sudo yum install devtoolset-7-valgrind $ valgrind ./a.out $ ...
🌐
Stack Overflow
stackoverflow.com › questions › 68203238 › enable-scl-toolset-by-default
docker - Enable scl toolset by default - Stack Overflow
July 1, 2021 - My attempt at the Dockerfile to make this happen is: 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
🌐
Ucsd
browndye.ucsd.edu › download.html
Download & Installation
The GCC/G++ compilers in CentOS 7 are too old for Browndye to compile so it is necessary to install SCL and devtoolset-9 to update the compilers. The SCL needs to be enabled before compilation. yum install centos-release-scl epel-release yum install devtoolset-9 ocaml expat-devel lapack-devel apbs scl enable devtoolset-9 bash...
🌐
GitHub
github.com › sclorg › devtoolset-container › blob › master › 6-toolchain › Dockerfile
devtoolset-container/6-toolchain/Dockerfile at master · sclorg/devtoolset-container
usage="docker run -ti -v /src/app:/opt/app-root/src:z centos/devtoolset-6-toolchain-centos7 bash" · RUN yum install -y centos-release-scl-rh && \ INSTALL_PKGS="devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-gcc-gfortran devtoolset-6-gdb" && \ yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ yum -y clean all --enablerepo='*' ·
Author   sclorg
🌐
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.
🌐
GitHub
github.com › bemehiser › centos-cmake-build › blob › master › Dockerfile
centos-cmake-build/Dockerfile at master · bemehiser/centos-cmake-build
bash cmake-3.9.1-Linux-x86_64.sh ... devtoolset-7-gcc* ENV PATH="/opt/rh/devtoolset-7/root/usr/bin:$PATH" RUN source scl_source enable devtoolset-7 ·...
Author   bemehiser
🌐
Stack Overflow
stackoverflow.com › questions › tagged › devtoolset
Recently Active 'devtoolset' Questions - Stack Overflow
... To install devtoolset-7.x86_64 on CentOS6 is pretty easy: yum install -y centos-release-scl yum install -y devtoolset-7-toolchain However, i686 is not available for download: http://mirror.centos.org/...