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
Discussions

When I use sudo command, it returns "Unable to open /etc/scl/prefixes/devtoolset-9!" - Unix & Linux Stack Exchange
My system is RHEL 6.7, Output of echo $PATH [geoeast@hp2-12 ~]$ which rm rm: aliased to rm -i [geoeast@hp2-12 ~]$ which cp cp: aliased to cp -i [geoeast@hp2-12 ~]$ echo $PATH /soft/geoeas... More on unix.stackexchange.com
🌐 unix.stackexchange.com
September 24, 2022
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
Building ATS: Unable to get file status /etc/scl/conf/devtoolset-7: No such file or directory
I'm submitting a ... bug report Traffic Control components affected ... Traffic Server (Transitive Source Build) Current behavior: ATS fails to build when using pkg. Expected behavior: ATS shou... More on github.com
🌐 github.com
0
June 4, 2021
Build fails on centos7 with devtoolset-7
The build of openssl 1.1.0 (and also 1.1.1) fails when devtoolset-7 is installed and enabled. Building 1.1.0 on a "vanilla" centos7 works. Installed devtoolset like this: $ yum install -y centos-re... More on github.com
🌐 github.com
8
April 1, 2019
🌐
Stack Exchange
unix.stackexchange.com › questions › 718533 › when-i-use-sudo-command-it-returns-unable-to-open-etc-scl-prefixes-devtoolset
When I use sudo command, it returns "Unable to open /etc/scl/prefixes/devtoolset-9!" - Unix & Linux Stack Exchange
September 24, 2022 - I would surmise therefore that the sudo your first user is executing is actually in that that extra directory, and it is this that is trying to access /etc/scl/prefixes/devtoolset-9. (You can check this with type sudo and confirming that it is not in /usr/bin.)
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 › apache › trafficcontrol › issues › 5916
Building ATS: Unable to get file status /etc/scl/conf/devtoolset-7: No such file or directory · Issue #5916 · apache/trafficcontrol
June 4, 2021 - Pulling ats ... done Creating build_ats_run ... Creating build_ats_run ... done Building ats_build. Building ats_build [...] Creating _tsb_ats_build_run ... Creating _tsb_ats_build_run ... done Unable to get file status /etc/scl/conf/devtoolset-7: No such file or directory 3 Failed to build ats_build.
Author   apache
🌐
GitHub
github.com › openssl › openssl › issues › 7982
Build fails on centos7 with devtoolset-7 · Issue #7982 · openssl/openssl
April 1, 2019 - The build of openssl 1.1.0 (and also 1.1.1) fails when devtoolset-7 is installed and enabled. Building 1.1.0 on a "vanilla" centos7 works. ... $ yum install -y centos-release-scl \ $ yum-config-manager --enable rhel-server-rhscl-7-rpms $ yum install -y devtoolset-7 $ source /opt/rh/devtoolset-7/enable
Author   openssl
🌐
GitHub
gist.github.com › sub-mod › a79ee1c45a2d6ebefe815770f77a5656
glibc ABI issue · GitHub
glibc ABI issue. GitHub Gist: instantly share code, notes, and snippets.
Find elsewhere
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360004312319-enable-scl-devtoolset
enable scl devtoolset – IDEs Support (IntelliJ Platform) | JetBrains
1. I moved all my configuring code from .bashrc to .profile because (I don't remember exactly when) sometimes .bashrc was not applied to the environment. so for now devtoolset in .profile · 2. the command is "source scl_source enable devtoolset-4" .
🌐
Red Hat
access.redhat.com › solutions › 3090181
Why `scl enable` command shows error "Unable to open /etc/scl/prefixes/gcc!" ? - Red Hat Customer Portal
July 21, 2017 - On installation of devtoolset-4-gcc-c++ the scl enable gcc bash gives the following error. # scl enable gcc bash Unable to open /etc/scl/prefixes/gcc!
🌐
Red Hat
access.redhat.com › discussions › 3279251
Red Hat Customer Portal - Access to 24x7 support and knowledge
January 4, 2018 - When executing scl command remote from other server cause error. Example ssh user1@server1.com scl enable rh-python36 'python /home/user1/setup.py install --user' cause error : Unable to open /etc/scl/conf/python!
🌐
Oracle
docs.oracle.com › en › operating-systems › oracle-linux › scl-user › scl-ReleaseNotes.html
Oracle Linux: Software Collection Library for Oracle Linux 7
January 2, 2025 - The workaround is to remove the libasan-static package before installing the devtoolset-3-libasan-devel package. ... You cannot install multiple versions of software collections on a system due to package conflicts within matching software collections.
🌐
GitHub
github.com › MISP › MISP › issues › 2430
install issue on RHEL7 · Issue #2430 · MISP/MISP
August 31, 2017 - /var/tmp/sclaPcqKl: line 8: /var/www/MISP/app/Console/worker/start.sh: Permission denied ! [root@XXXX ~]# su -s /bin/bash apache -c 'scl enable rh-php56 bash -c /var/www/MISP/app/Console/worker/start.sh' Unable to open /etc/scl/conf/bash!
Author   MISP
🌐
Processmaker
wiki.processmaker.net › 3.3 › Database_Connections › MSSQL
3.2 - 3.7 - Database Connections - Microsoft SQL Server | Documentation@ProcessMaker
sudo yum-config-manager --enable rhel-server-rhscl-7-rpms sudo yum install centos-release-scl sudo yum install devtoolset-7-gcc-c++ scl enable devtoolset-7 bash
Top answer
1 of 3
3

You should try using -- instead of surrounding your command with quotes.

scl enable python27 -- ls /tmp

I was able to make a python script that uses the rh-python35 collection with this shebang:

#!/usr/bin/scl enable rh-python35 -- python

import sys
print(sys.version)
2 of 3
1

The parsing of arguments in the she-bang command is not really defined. From man execve:

The semantics of the optional-arg argument of an interpreter script vary across implementations. On Linux, the entire string following the interpreter name is passed as a single argument to the interpreter, and this string can include white space. However, behavior differs on some other systems. Some systems use the first white space to terminate optional-arg. On some systems, an interpreter script can have multiple arguments, and white spaces in optional-arg are used to delimit the arguments.

No matter what, argument splitting based on quote sis not supported. So when you write:

#!/usr/bin/scl enable python27 "ls /tmp"

It's very possible that what gets invoked is (using bash notation):

'/usr/bin/scl' 'enable' 'python27' '"ls' '/tmp"'

This is probably why it tries to open the "ls file at /etc/scl/prefixes/"ls

But it is just as likely that the shebang evaluates to:

'/usr/bin/scl' 'enable python27 "ls /tmp"'

And that would fail since it wont be able to find a command named enable python27 "ls /tmp" for scl to execute.

There's a few workarounds you can use.

You can call your script via scl:

$ cat myscript
#!/bin/bash
echo hello

$ scl enable python27 ./myscript
hello

You can also use the heredoc notation, but it might lead to subtle issues. I personally avoid this:

$ cat ./myscript
#!/bin/bash
scl enable python27 -- <<EOF
echo hi
echo \$X_SCLS
EOF

$ bash -x myscript 
+ scl enable python27 --
hi
python27

You can see one of the gotcha's already: I had to write \$X_SCLS to access the environment variable instead of just $X_SCL.

Edit: Another option is two have two scripts. One that has the actual code, and the second that simply does scl enable python27 $FIRST_SCRIPT. Then you wont have to remember to enter scl ... manually.

🌐
NVIDIA
docs.nvidia.com › doca › archive › doca-v1.5.1 › troubleshooting › index.html
Troubleshooting Guide - NVIDIA Docs
Upgrading the devtoolset on the machine to the one used when building the gRPC package resolves the version conflict: ... $ sudo yum install epel-release $ sudo yum install centos-release-scl-rh $ sudo yum install devtoolset-8 $ sudo scl enable devtoolset-8 # This will enable the use of devtoolset-8 to the *current* bash session $ source /opt/rh/devtoolset-8/enable
🌐
Zeek
docs.zeek.org › en › v7.0.11 › install.html
Installing Zeek — Book of Zeek (v7.0.11)
October 13, 2025 - sudo yum install cmake3 devtoolset-7 scl enable devtoolset-7 bash
🌐
Posit Support
support.posit.co › hc › en-us › articles › 360006142673-Posit-Connect-with-devtoolset-enabled
Posit Connect with devtoolset enabled – Posit Support
April 9, 2025 - #!/bin/bash echo arguments: "$@" >&2 echo >&2 source scl_source enable devtoolset-7 exec "$@" 3. Allow access to the file with: chmod 755 /opt/scripts/devtool-enable.sh · 4. Add the following to /etc/rstudio-connect/rstudio-connect.gcfg