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

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
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
Dovecot build failed | DirectAdmin Forums
Error: Nothing to do Loaded plugins: ... package devtoolset-7 available. Error: Nothing to do Installing dovecot 2.3.17.1 ... Found /usr/local/directadmin/custombuild/dovecot-2.3.17.1.tar.gz Extracting ... Done. Patching syslog with LOG_PID ... Patching maildirlock utility... patching file src/util/maildirlock.c Configuring dovecot 2.3.17.1 ... Unable to open /etc/scl/prefixes/devtoo... More on forum.directadmin.com
🌐 forum.directadmin.com
December 14, 2021
🌐
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!
🌐
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 - The user account that generates the error, Unable to open /etc/scl/prefixes/devtoolset-9! has the directory /soft/ieco1.0.3/support_2.6.32/devtoolset-9_as6/root/usr/bin in their $PATH (the list of directories that are searched for commands).
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
🌐
DirectAdmin
forum.directadmin.com › home › forums › technical discussion › e-mail › dovecot
Dovecot build failed | DirectAdmin Forums
December 14, 2021 - If you would have it, you would know it, because you have to pay for it. I'm not sure, but it's saying it did not find the repository, so for some reason the system is looking for it. But it might not be required. The version dovecot.conf looks fine, that is the newest one. No package devtoolset-7 available.
Find elsewhere
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.

🌐
GitHub
github.com › openssl › openssl › issues › 7982
Build fails on centos7 with devtoolset-7 · Issue #7982 · openssl/openssl
April 1, 2019 - $ 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 · if [ `uname` == Darwin ]; then ./Configure darwin64-x86_64-cc shared --prefix=$PREFIX --openssldir=$PREFIX/ssl else ./config shared --prefix=$PREFIX --openssldir=$PREFIX/ssl fi make --quiet if [ "$(whoami)" == 'root' ]; then # Some tests don't like to be run as "root".
Author   openssl
🌐
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" .
🌐
NVIDIA
docs.nvidia.com › doca › archive › doca-v2-5-1 › NVIDIA+DOCA+Troubleshooting+Guide › index.html
NVIDIA DOCA Troubleshooting Guide - NVIDIA Docs
$ sudo yum install epel-release $ sudo yum install centos-release-scl-rh $ sudo yum install devtoolset-8 # This will enable the use of devtoolset-8 to the *current* bash session $ source /opt/rh/devtoolset-8/enable · When statically compiling against the DOCA SDK on RHEL 7.x machines, a known issue in the default pkg-config version (0.27) causes a linking error.
🌐
GitHub
github.com › fedora-ruby › fermig › issues › 3
"Unable to open /etc/scl/prefixes/" error after running f19.rb · Issue #3 · fedora-ruby/fermig
November 26, 2014 - Fixes this error: + scl enable ruby200 ' mkdir -p ./opt/rh/ruby200/root/usr/share/gems CONFIGURE_ARGS=--with-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' ' gem install -V --local --install-dir ./opt/rh/ruby200/root ' Unable to open /etc/scl/prefixes/ mkdir -p ./opt/rh/ruby200/root/usr/share/gems
Author   fedora-ruby
🌐
GitHub
gist.github.com › sub-mod › a79ee1c45a2d6ebefe815770f77a5656
glibc ABI issue · GitHub
glibc ABI issue. GitHub Gist: instantly share code, notes, and snippets.
🌐
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 - The default installation path is /usr/local/zeek, which would typically require root privileges when doing the make install. A different installation path can be chosen by specifying the configure script --prefix option.
🌐
Fedora Documentation
jfearn.fedorapeople.org › fdocs › en-US › Fedora_Contributor_Documentation › 1 › html › Software_Collections_Guide › sect-Unable_to_open_etc_scl_prefixes_software_collection_name.html
5.3. Unable to open /etc/scl/prefixes/software_collection_name
This error message can be caused by using incorrect arguments with the scl command you are calling. Check the scl command is correct and that you have not mistyped any of the arguments · The same error message can also be caused by a missing Software Collection.
🌐
University of Edinburgh
computing.help.inf.ed.ac.uk › scl
Software Collections | Documentation
To activate the devtoolset you need to do something like this: ... This would launch a new sub-shell with the necessary settings for your path, library load path, etc. When you exit the shell (in the usual way with ctrl-d or by typing exit) everything returns to normal. 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.
🌐
MISP
misp.github.io › MISP › xINSTALL.centos7.html
deprecated INSTALLATION INSTRUCTIONS | MISP
# install maec ${SUDO_WWW} ${PATH_TO_MISP}/venv/bin/pip install -U maec # install zmq ${SUDO_WWW} ${PATH_TO_MISP}/venv/bin/pip install -U zmq # install redis ${SUDO_WWW} ${PATH_TO_MISP}/venv/bin/pip install -U redis # lief needs manual compilation sudo yum install devtoolset-7 cmake3 -y # TODO: Fix static path with PATH_TO_MISP cd ${PATH_TO_MISP}/app/files/scripts/lief $SUDO_WWW git config core.filemode false ${SUDO_WWW} mkdir build cd build ${SUDO_WWW} scl enable devtoolset-7 'bash -c "cmake3 \ -DLIEF_PYTHON_API=on \ -DLIEF_DOC=off \ -DCMAKE_INSTALL_PREFIX=$LIEF_INSTALL \ -DCMAKE_BUILD_TYPE=R