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
🌐
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
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
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 › rctrh › rh-tthw › blob › master › get-started-scl-rhel7-perl.adoc
rh-tthw/get-started-scl-rhel7-perl.adoc at master · rctrh/rh-tthw
Doing this can cause conflicts ... packages a permanent part of your development environment, you can add it to the login script for your specific user ID....
Author   rctrh
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 › voxpupuli › puppet-python › issues › 233
Add scl_enable_onlogin option to class python · Issue #233 · voxpupuli/puppet-python
August 22, 2015 - # Permanently Enable a Software Collection # see http://developerblog.redhat.com/2014/03/19/permanently-enable-a-software-collection/ # WARNING: this will not work for cron, virtualenv etc. file { "/etc/profile.d/enable${python::python_version}.sh": mode => '0755', content => "#!/bin/bash\nsource /opt/rh/${python::python_version}/enable\nexport X_SCLS=\"`scl enable ${python::python_version} 'echo \$X_SCLS'`\"", }
Author   voxpupuli
🌐
GitHub
github.com › rctrh › rh-tthw › blob › master › get-started-scl-rhel7-php.adoc
rh-tthw/get-started-scl-rhel7-php.adoc at master · rctrh/rh-tthw
Doing this can cause conflicts ... packages a permanent part of your development environment, you can add it to the login script for your specific user ID....
Author   rctrh
🌐
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:...
Find elsewhere
🌐
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.
🌐
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
For enabling Software Collections that are not in RHSCL, but are build by SCLo SIG group in CentOS, install this package by:
Starred by 70 users
Forked by 15 users
Languages   Shell
🌐
Austindewey
austindewey.com › 2019 › 03 › 26 › enabling-software-collections-binaries-on-a-docker-image
Enabling Software Collections Binaries On A Docker Image<!-- --> - Austin Dewey
In this post, we will learn how to persistently enable SCL binaries on a Docker image, such that the correct version of the binary is enabled on startup.
🌐
Red Hat
developers.redhat.com › blog › 2014 › 03 › 19 › permanently-enable-a-software-collection
Permanently Enable a Software Collection | Red Hat Developer
November 2, 2023 - $ cat /etc/profile.d/enablepython33.sh #!/bin/bash source /opt/rh/python33/enable export X_SCLS="`scl enable python33 'echo $X_SCLS'`"
🌐
GitHub
github.com › sclorg › scl-utils › blob › master › shell › scl_enabled
scl-utils/shell/scl_enabled at master · sclorg/scl-utils
Tool to setup and run software from Software Collection environment - scl-utils/shell/scl_enabled at master · sclorg/scl-utils
Author   sclorg
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
gist.github.com › 42cc52cbac6fc6f5bdec
How to enable Software Collections (SCL) on Amazon/RHEL/CentOS · GitHub
Save dasgoll/42cc52cbac6fc6f5bdec to your computer and use it in GitHub Desktop. Download ZIP · How to enable Software Collections (SCL) on Amazon/RHEL/CentOS · Raw · gistfile1.txt · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
GitHub
github.com › sclorg › scl-utils › issues › 45
scl enable leaves temporary files in /var/tmp · Issue #45 · sclorg/scl-utils
May 23, 2022 - ✔ 8.6 wilkpio@wilkpio-server /local/wilkpio/scl-utils/o [master|✚ 1…94] $ cat /etc/redhat-release Red Hat Enterprise Linux release 8.6 (Ootpa) ✔ 8.6 wilkpio@wilkpio-server /local/wilkpio/scl-utils/o [master|✚ 1…94] $ scl --version^C ✘-INT 8.6 wilkpio@wilkpio-server /local/wilkpio/scl-utils/o [master|✚ 1…94] $ cd ✔ 8.6 wilkpio@wilkpio-server ~ $ cat /etc/redhat-release Red Hat Enterprise Linux release 8.6 (Ootpa) ✔ 8.6 wilkpio@wilkpio-server ~ $ scl --version scl-utils-2.0.2 ✔ 8.6 wilkpio@wilkpio-server ~ $ scl enable gcc-toolset-10 bash ✔ 8.6 wilkpio@wilkpio-server ~ $ ls -lt /var/tmp/ | head -n 2 total 469368 -rw------- 1 wilkpio users 132 May 23 15:52 scl3ok0hl ✔ 8.6 wilkpio@wilkpio-server ~ $ cat /var/tmp/scl3ok0hl eval "SCLS=( ${X_SCLS[*]} )" SCLS+=(gcc-toolset-10) export X_SCLS=$(printf '%q ' "${SCLS[@]}") .
Author   sclorg
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_software_collections › 3 › html › packaging_guide › sect-enabling_the_software_collection
1.6. Enabling a Software Collection | Packaging Guide | Red Hat Software Collections | 3 | Red Hat Documentation
You have to disable an enabled Software Collection first to be able to enable it again. To disable the Software Collection, exit the subshell created when enabling the Software Collections. When using the scl tool to enable a Software Collection, you can only perform one action with the enabled ...
🌐
GitHub
github.com › openshift › jenkins › issues › 582
How to enable scl in PodTemplate with maven and nodejs ? · Issue #582 · openshift/jenkins
April 22, 2018 - It would be nice if developers does not need to bother about scl enablement. ... Sorry, I don't think it is not possible. The mechanism the kubernetes plugin uses to invoke the commands in the sidecar container does not give us a way to ensure the scl packages are enabled within that execution context, that I am aware of.
Author   openshift
🌐
GitHub
github.com › SCL-Git
SCL-Git - Overview
SCL-Git has 4 repositories available. Follow their code on GitHub.