Skip to content

Spaces in prefix fix breaks passing the $PS1 environment variable #11893

@kenodegard

Description

@kenodegard

What happened?

After releasing conda 22.9.0, users (predominantly Linux) identified an issue (#11885) where the prompt would no longer update correctly on posix. After some digging, the issue appears because of the spaces in prefix fix (#11676).

How to replicate:

  1. Update conda:

    conda update conda
    
  2. At this point, depending on your system, the issue may already be present. If not, you'll need to continue to mock the issue users are encountering.

  3. Modify $CONDA_PREFIX/bin/conda's shebang to use the long prefix/space in prefix trick:

    So from this:

    #!/Users/kodegard/.conda/4.12.0/3.9/bin/python
    # -*- coding: utf-8 -*-
    ...
    

    To this:

    #!/bin/sh
    '''exec' "/Users/kodegard/.conda/4.12.0/3.9/bin/python" "$0" "$@"
    ' '''
    # -*- coding: utf-8 -*-
    ...
    
  4. Running conda activate will now break your prompt.

This has to do with how environment variables are passed to the sub-shell. Only exported environment variables are passed along and since $PS1 is not an exported value it gets lost with the exec call (this is why the bash shell interface for activate/deactivate calls conda as eval "$(PS1=${PS1:-} conda shell.posix activate ...)" to correctly pass along the $PS1 value). Now that our entry points are invoking another sub-shell that PS1 isn't being passed along to the exec's sub-shell, conda isn't able to identify the presence of a prompt.

A fix is needed as this issue likely propagates to all entry points & scripts that conda installs, i.e., I would be unable to pass environment variables to executables:

LIFE=42 $CONDA_PREFIX/bin/executable

Conda Details

conda info
active environment : None
            shell level : 0
       user config file : /Users/kodegard/.condarc
 populated config files : /Users/kodegard/.condarc
          conda version : 22.9.0
    conda-build version : 3.22.0
         python version : 3.9.12.final.0
       virtual packages : __osx=10.16=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /Users/kodegard/.conda/4.12.0/3.9  (writable)
      conda av data dir : /Users/kodegard/.conda/4.12.0/3.9/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/pytorch/osx-64
                          https://conda.anaconda.org/pytorch/noarch
                          https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/kodegard/.conda/4.12.0/3.9/pkgs
                          /Users/kodegard/.conda/pkgs
       envs directories : /Users/kodegard/.conda/4.12.0/3.9/envs
                          /Users/kodegard/.conda/envs
               platform : osx-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.12 Darwin/21.6.0 OSX/10.16
                UID:GID : 502:20
             netrc file : None
           offline mode : False
conda config
==> /Users/kodegard/.condarc <==
auto_update_conda: False
auto_activate_base: False
channels:
  - defaults
conda list
# packages in environment at /Users/kodegard/.conda/4.12.0/3.9:
#
# Name                    Version                   Build  Channel
beautifulsoup4            4.11.1           py39hecd8cb5_0    defaults
brotlipy                  0.7.0           py39h9ed2024_1003    defaults
bzip2                     1.0.8                h1de35cc_0    defaults
ca-certificates           2022.07.19           hecd8cb5_0    defaults
cctools                   949.0.1             h9abeeb2_23    defaults
cctools_osx-64            949.0.1             hc7db93f_23    defaults
certifi                   2022.9.14        py39hecd8cb5_0    defaults
cffi                      1.15.1           py39hc55c11b_0    defaults
chardet                   4.0.0           py39hecd8cb5_1003    defaults
charset-normalizer        2.0.4              pyhd3eb1b0_0    defaults
conda                     22.9.0           py39hecd8cb5_0    defaults
conda-build               3.22.0           py39hecd8cb5_0    defaults
conda-package-handling    1.9.0            py39hca72f7f_0    defaults
cryptography              37.0.1           py39hf6deb26_0    defaults
filelock                  3.6.0              pyhd3eb1b0_0    defaults
glob2                     0.7                pyhd3eb1b0_0    defaults
icu                       58.2                 h0a44026_3    defaults
idna                      3.3                pyhd3eb1b0_0    defaults
jinja2                    2.11.3             pyhd3eb1b0_0    defaults
ld64                      530                 h20443b4_23    defaults
ld64_osx-64               530                 h70f3046_23    defaults
ldid                      2.1.2                h2d21305_2    defaults
libarchive                3.6.1                he336d3b_0    defaults
libcxx                    14.0.6               h9765a3e_0    defaults
libffi                    3.3                  hb1e8313_2    defaults
libiconv                  1.16                 hca72f7f_2    defaults
liblief                   0.11.5               he9d5cce_1    defaults
libllvm12                 12.0.0               h9b2ccf5_3    defaults
libxml2                   2.9.14               hbf8cd5e_0    defaults
lz4-c                     1.9.3                h23ab428_1    defaults
markupsafe                2.0.1            py39h9ed2024_0    defaults
ncurses                   6.3                  hca72f7f_3    defaults
openssl                   1.1.1q               hca72f7f_0    defaults
patch                     2.7.6             h1de35cc_1001    defaults
pip                       22.1.2           py39hecd8cb5_0    defaults
pkginfo                   1.8.2              pyhd3eb1b0_0    defaults
psutil                    5.9.0            py39hca72f7f_0    defaults
py-lief                   0.11.5           py39he9d5cce_1    defaults
pycosat                   0.6.3            py39h9ed2024_0    defaults
pycparser                 2.21               pyhd3eb1b0_0    defaults
pyopenssl                 22.0.0             pyhd3eb1b0_0    defaults
pysocks                   1.7.1            py39hecd8cb5_0    defaults
python                    3.9.12               hdfd78df_1    defaults
python-libarchive-c       2.9                pyhd3eb1b0_1    defaults
python.app                3                py39hca72f7f_0    defaults
pytz                      2022.1           py39hecd8cb5_0    defaults
pyyaml                    6.0              py39hca72f7f_1    defaults
readline                  8.1.2                hca72f7f_1    defaults
requests                  2.28.1           py39hecd8cb5_0    defaults
ripgrep                   13.0.0               hc2228c6_0    defaults
ruamel_yaml               0.15.100         py39h9ed2024_0    defaults
setuptools                63.4.1           py39hecd8cb5_0    defaults
six                       1.16.0             pyhd3eb1b0_1    defaults
soupsieve                 2.3.1              pyhd3eb1b0_0    defaults
sqlite                    3.39.2               h707629a_0    defaults
tapi                      1000.10.8            ha1b3eb9_0    defaults
tk                        8.6.12               h5d9f67b_0    defaults
toml                      0.10.2             pyhd3eb1b0_0    defaults
toolz                     0.11.2             pyhd3eb1b0_0    defaults
tqdm                      4.64.0           py39hecd8cb5_0    defaults
tzdata                    2022c                h04d1e81_0    defaults
urllib3                   1.26.11          py39hecd8cb5_0    defaults
wheel                     0.37.1             pyhd3eb1b0_0    defaults
xz                        5.2.6                hca72f7f_0    defaults
yaml                      0.2.5                haf1e3a3_0    defaults
zlib                      1.2.12               h4dc903c_3    defaults
zstd                      1.5.2                hcb37349_0    defaults

Metadata

Metadata

Labels

cli::posixpertains to the CLI in Posix compliant shells (e.g. Bash, Zsh, KornShell, etc.)in-progressissue is actively being worked onlocked[bot] locked due to inactivityos::linuxrelevant to Linuxseverity::3major; broken functionality with a workaroundsource::anacondacreated by members of Anaconda, Inc.type::bugdescribes erroneous operation, use severity::* to classify the type

Type

No type

Projects

Status

🏁 Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions