Skip to content

Conda command not exported to subshells #7753

@jamessynge

Description

@jamessynge

Context

I'm writing a bash script for installing and updating a system that uses conda for package management and am trying to test whether the user's shell already has conda set up with the correct environment. Prior to conda version 4.4 I could test for whether conda was on the PATH using which conda before running conda info, but with 4.4 conda is shell function. I attempted to use type -t conda to work around this, but then found that conda isn't exported to subshells.

OS: Ubuntu 18.04

Current Behavior

Sourcing etc/profile.d/conda.sh defines several shell functions, but these are not set to be exported to subshells. As a result bash scripts started by the shell don't have access to the conda command.

Steps to Reproduce

With miniconda 4.4 or greater installed...

$ source /var/panoptes/miniconda/etc/profile.d/conda.
$ type -t conda
function
$ bash  # Start a nested shell
$ type conda
bash: type: conda: not found

Expected Behavior

Ideally the conda command would be exported to nested shells so that my install script can determine whether to tell the user that they need to logout and log back in again; note that the users of this script are generally not experienced with Linux, so we want to provide simple steps like log-out/log-in, rather than several commands that can get confusing. But we want to avoid asking for them to log-out more often than necessary, hence the desire to determine whether the environment was OK already.

Environment Information

`conda info`

     active environment : panoptes-env
    active env location : /var/panoptes/miniconda/envs/panoptes-env
            shell level : 1
       user config file : /home/james/.condarc
 populated config files : /home/james/.condarc
          conda version : 4.5.11
    conda-build version : not installed
         python version : 3.7.0.final.0
       base environment : /var/panoptes/miniconda  (writable)
           channel URLs : https://conda.anaconda.org/astropy/linux-64
                          https://conda.anaconda.org/astropy/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /var/panoptes/miniconda/pkgs
                          /home/james/.conda/pkgs
       envs directories : /var/panoptes/miniconda/envs
                          /home/james/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Linux/4.15.0-29-generic ubuntu/18.04 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

`conda config --show-sources`

==> /home/james/.condarc <==
channels:
  - astropy
  - defaults
  - conda-forge

`conda list --show-channel-urls`

# packages in environment at /var/panoptes/miniconda/envs/panoptes-env:
#
# Name                    Version                   Build  Channel
astroplan                 0.4                       <pip>
astropy                   3.0.4                     <pip>
astropy-healpix           0.2.1                     <pip>
astroscrappy              1.0.5                     <pip>
atomicwrites              1.2.1                     <pip>
attrs                     18.2.0                    <pip>
blas                      1.0                         mkl    defaults
ca-certificates           2018.03.07                    0    defaults
cachetools                2.1.0                     <pip>
ccdproc                   1.3.0.post1               <pip>
certifi                   2018.8.24                py36_1    defaults
chardet                   3.0.4                     <pip>
cloudpickle               0.5.5                     <pip>
codecov                   2.0.15                    <pip>
coverage                  4.5.1                     <pip>
coveralls                 1.5.0                     <pip>
cycler                    0.10.0                    <pip>
dask                      0.19.1                    <pip>
dateparser                0.7.0                     <pip>
decorator                 4.3.0                     <pip>
docopt                    0.6.2                     <pip>
ffmpy                     0.2.2                     <pip>
gcloud                    0.18.3                    <pip>
google-api-core           1.3.0                     <pip>
google-auth               1.5.1                     <pip>
google-cloud-core         0.28.1                    <pip>
google-cloud-storage      1.11.0                    <pip>
google-resumable-media    0.3.1                     <pip>
googleapis-common-protos  1.5.3                     <pip>
hexdump                   3.3                       <pip>
httplib2                  0.11.3                    <pip>
idna                      2.7                       <pip>
intel-openmp              2018.0.3                      0    defaults
kiwisolver                1.0.1                     <pip>
libedit                   3.1.20170329         h6b74fdf_2    defaults
libffi                    3.2.1                hd88cf55_4    defaults
libgcc-ng                 8.2.0                hdf63c60_1    defaults
libgfortran-ng            7.3.0                hdf63c60_0    defaults
libstdcxx-ng              8.2.0                hdf63c60_1    defaults
matplotlib                2.2.3                     <pip>
mkl                       2018.0.3                      1    defaults
mkl_fft                   1.0.4            py36h4414c95_1    defaults
mkl_random                1.0.1            py36h4414c95_1    defaults
mocket                    2.4.0                     <pip>
more-itertools            4.3.0                     <pip>
ncurses                   6.1                  hf484d3e_0    defaults
networkx                  2.1                       <pip>
numpy                     1.15.1           py36h1d66e8a_0    defaults
numpy-base                1.15.1           py36h81de0dd_0    defaults
oauth2client              4.1.3                     <pip>
oauthlib                  2.1.0                     <pip>
openssl                   1.0.2p               h14c3975_0    defaults
pandas                    0.23.4           py36h04863e7_0    defaults
Pillow                    5.2.0                     <pip>
pip                       10.0.1                   py36_0    defaults
pluggy                    0.7.1                     <pip>
protobuf                  3.6.1                     <pip>
py                        1.6.0                     <pip>
pyasn1                    0.4.4                     <pip>
pyasn1-modules            0.2.2                     <pip>
pycodestyle               2.3.1                     <pip>
pymongo                   3.7.1                     <pip>
pyparsing                 2.2.0                     <pip>
pyserial                  3.4                       <pip>
PySocks                   1.6.8                     <pip>
pytest                    3.8.0                     <pip>
python                    3.6.6                hc3d631a_0    defaults
python-dateutil           2.7.3                    py36_0    defaults
python-magic              0.4.15                    <pip>
pytz                      2018.5                   py36_0    defaults
PyWavelets                1.0.0                     <pip>
PyYAML                    3.13                      <pip>
pyzmq                     17.1.2                    <pip>
readline                  6.2.4.1                   <pip>
readline                  7.0                  h7b6447c_5    defaults
regex                     2018.8.29                 <pip>
reproject                 0.4                       <pip>
requests                  2.19.1                    <pip>
requests-oauthlib         1.0.0                     <pip>
rsa                       3.4.2                     <pip>
scikit-image              0.14.0                    <pip>
scipy                     1.1.0                     <pip>
setuptools                40.2.0                   py36_0    defaults
six                       1.11.0                   py36_1    defaults
sqlite                    3.24.0               h84994c4_0    defaults
tk                        8.6.8                hbc83047_0    defaults
toolz                     0.9.0                     <pip>
transitions               0.6.8                     <pip>
tweepy                    3.6.0                     <pip>
tzlocal                   1.5.1                     <pip>
urllib3                   1.23                      <pip>
wcsaxes                   0.9                       <pip>
wheel                     0.31.1                   py36_0    defaults
xz                        5.2.4                h14c3975_4    defaults
zlib                      1.2.11               ha838bed_2    defaults

Metadata

Metadata

Assignees

No one assigned

    Labels

    source::communitycatch-all for issues filed by community membersstale::recovered[bot] recovered after being marked as staletype::featurerequest for a new feature or capability

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions