using scl enable actually opens a new shell inside your current one, which is quite unclean, especially if done from a login script.

You should place, instead, in your ~/.bash_profile:

source /opt/rh/rh-nginx18/enable

or:

source scl_source enable rh-nginx18

The latter is more "elegant" as it is independent from the actual installation path.

This has the effect of loading the environment in your current shell.

Answer from l3g3nd4ryf0x on serverfault.com
🌐
Red Hat
access.redhat.com › solutions › 527703
How can I make a Red Hat Software Collection persist after a reboot/logout? - Red Hat Customer Portal
However, software collections will ... The usual way to enable software collections for whole sessions is to run a new bash wrapped with "scl enable" call, for example like that:...
Discussions

linux - How to permanently enable newer version of software installed from SCL repo? - Unix & Linux Stack Exchange
GCC 4.7 isn't really installed on your system, it's in the SCL environment. Only the older version (4.4?) is really installed. To install apps natively, use your distro's package manager. On Ubuntu, this is apt-get, e.g. sudo apt-get install gcc. On CentOS, this is yum, e.g. More on unix.stackexchange.com
🌐 unix.stackexchange.com
May 8, 2020
redhat - Permanently enable RHEL scl - Stack Overflow
Is there a way to permanently enable custom Software Collections for RedHat? I have installed an scl to provide python27 in RHEL6 and don't want to have to enable the custom scl every time. More on stackoverflow.com
🌐 stackoverflow.com
rhel7 - How do I enable python35 from Software Collections at login? - Stack Overflow
I followed the Software Collections Quick Start and I now have Python 3.5 installed. How can I make it always enabled in my ~/.bashrc, so that I do not have to enable it manually with scl enable rh- More on stackoverflow.com
🌐 stackoverflow.com
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
🌐
GitHub
github.com › rust-embedded › cross › issues › 566
Permanently enable scl in centos extending from x86_64-unknown-linux-gnu · Issue #566 · cross-rs/cross
July 1, 2021 - 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
Author   cross-rs
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
🌐
Austindewey
austindewey.com › 2019 › 03 › 26 › enabling-software-collections-binaries-on-a-docker-image
Enabling Software Collections Binaries On A Docker Image<!-- --> - Austin Dewey
Another way to persistently enable scl binaries in a docker image is to set environment variables. 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 ...
🌐
CopyProgramming
copyprogramming.com › howto › how-to-permanently-enable-scl-centos-6-4
Linux: Enabling SCL on CentOS 6.4 Permanently: A Guide
April 2, 2023 - ##############################...############ # Enable SCL ################################################## yum -y install centos-release-scl yum-config-manager --enable rhel-server-rhscl-7-rpms ################################################## # Python 2.7 ############...
🌐
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
Method 1. The package to enable Software Collection SCL is available in CentOS 7 repository and it can be installed by yum command.
Find elsewhere
Top answer
1 of 2
9

Use the scl_source feature.

Create a new file in /etc/profile.d/ to enable your collection automatically on start up:

$ cat /etc/profile.d/enablepython35.sh
#!/bin/bash
source scl_source enable python35

See How can I make a Red Hat Software Collection persist after a reboot/logout? for background and details.

2 of 2
1

This answer would be helpful to those who have limited auth access on the server.

I had a similar problem for python3.5 in HostGator's shared hosting. Python3.5 had to be enabled every single damn time after login. Here are my 10 steps for the resolution:

  1. Enable the python through scl script python_enable_3.5 or scl enable rh-python35 bash.

  2. Verify that it's enabled by executing python3.5 --version. This should give you your python version.

  3. Execute which python3.5 to get its path. In my case, it was /opt/rh/rh-python35/root/usr/bin/python3.5. You can use this path to get the version again (just to verify that this path is working for you.)

  4. Awesome, now please exit out of the current shell of scl.

  5. Now, lets get the version again through this complete python3.5 path /opt/rh/rh-python35/root/usr/bin/python3.5 --version.

    It won't give you the version but an error. In my case, it was

/opt/rh/rh-python35/root/usr/bin/python3.5: error while loading shared libraries: libpython3.5m.so.rh-python35-1.0: cannot open shared object file: No such file or directory
  1. As mentioned in Tamas' answer, we gotta find that so file. locate doesn't work in shared hosting and you can't install that too.

    Use the following command to find where that file is located:

find /opt/rh/rh-python35 -name "libpython3.5m.so.rh-python35-1.0"
  1. Above command would print the complete path (second line) of the file once located. In my case, output was
find: `/opt/rh/rh-python35/root/root': Permission denied
/opt/rh/rh-python35/root/usr/lib64/libpython3.5m.so.rh-python35-1.0
  1. Here is the complete command for the python3.5 to work in such shared hosting which would give the version,
LD_LIBRARY_PATH=/opt/rh/rh-python35/root/usr/lib64 /opt/rh/rh-python35/root/usr/bin/python3.5 --version
  1. Finally, for shorthand, append the following alias in your ~/.bashrc
alias python351='LD_LIBRARY_PATH=/opt/rh/rh-python35/root/usr/lib64 /opt/rh/rh-python35/root/usr/bin/python3.5'
  1. For verification, reload the .bashrc by source ~/.bashrc and execute python351 --version.

Well, there you go, now whenever you login again, you have got python351 to welcome you.

This is not just limited to python3.5, but can be helpful in case of other scl installed softwares.

🌐
GitHub
github.com › sclorg › centos-release-scl
GitHub - sclorg/centos-release-scl: yum Configs and basic docs for Software Collections as delivered via the CentOS SCLo SIG. · GitHub
On RHEL, there is no centos-release-scl-rh package available and users are expected to enable RHSCL repository, like this: sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
Starred by 70 users
Forked by 15 users
Languages   Shell
🌐
Soton
linuxdesktops.soton.ac.uk › softwarecollections.html
Software collections (SCL) — Linux Desktops RHEL7 documentation
Unlike the environment modules system the binaries of the programs do not have a PREFIX set so they can locate shared libraries (shared/dynamic objects) without setting the LD_LIBRARY_PATH variable. This is set automatically by the scl enable command.
🌐
Xmodulo
xmodulo.com › enable-software-collections-centos.html
How to enable Software Collections (SCL) on CentOS
September 23, 2020 - If you want to run multiple commands while enabling python33 package, you can actually create an SCL-enabled bash session as follows.
🌐
Softwarecollections
softwarecollections.org › en › docs
Quick Start — Software Collections
On CentOS, install the SCL release package `centos-release-scl`: ... On RHEL, enable the RHSCL repository. Note that you may also need to enable the Optional channel and attach a subscription providing access to RHSCL to be able to use that repository. yum-config-manager --enable ...
🌐
CentOS
wiki.centos.org › AdditionalResources(2f)Repositories(2f)SCL.html
The Software Collections ( SCL ) Repository
In order to gain access to SCLs for CentOS, you need to install the CentOS Linux Software Collections release file.
🌐
Server Fault
serverfault.com › questions › tagged › scl
Newest 'scl' Questions - Server Fault
I have a relatively old server with CentOS 6 on it. The default gcc is 4.4.7 but after some googling, I found I can update this via devtoolset-7. I installed devtoolset-7 via root (i.e. sudo -i), and ... ... I have a dockerfile building oel6 linux that uses the SCL python27.
🌐
Server Fault
serverfault.com › questions › 1140417 › centos-7-scl-software-collections-abandoned
centos7 - CentOS 7 SCL (Software Collections) abandoned? - Server Fault
There is a difference in version between httpd24-httpd installed with Software Collections on CentOS 7.9 and httpd24-httpd installed with RHEL (Universal Base Images). ... yum install centos-release-scl centos-release-scl-rh yum install httpd24-httpd rpm -q --changelog httpd24-httpd | head -3 # * Tue Sep 20 2022 Luboš Uhliarik <[email protected]> - 2.4.34-23.5 # - Related: #2035029 - CVE-2021-44224 httpd24-httpd: httpd: possible NULL # dereference or SSRF in forward proxy configurations
🌐
Madboa
madboa.com › blog › 2016 › 08 › 29 › scl-intro
Red Hat/CentOS Software Collections (SCL) - madboa.com
August 29, 2016 - Use yum to make SCL repositories available on a CentOS machine: ... The SCL repositories have a lot of packages, but you may be interested to see everything that’s offered. I suggest piping the output of the following commands to less or your favorite pager to ease the reading. # RHEL 6 yum --disablerepo='*' --enablerepo='rhel-server-rhscl-6-rpms' list available # RHEL 7 yum --disablerepo='*' --enablerepo='rhel-server-rhscl-7-rpms' list available # CentOS 6 and 7 yum --disablerepo='*' \ --enablerepo='centos-sclo-rh' \ --enablerepo='centos-sclo-sclo' \ list available
🌐
Qastack
qastack.mx › unix › 175851 › how-to-permanently-enable-scl-centos-6-4
¿Cómo habilitar permanentemente scl CentOS 6.4?
Entonces, cuando lo pones en tu .bashrc, crea un nuevo shell ... que carga tu .bashrc, que se ejecuta scl enable devtoolset-1.1 bash, que crea un nuevo shell, que carga tu .bashrc ... ¡Forkbomb! Probablemente quieras algo como esto en tu .bashrc: if [ "$(gcc -dumpversion)" != "4.7.2" ]; then ...