HenrikBengtsson / conda-stage

conda-stage: Stage a Conda Environment on Local Disk
https://github.com/HenrikBengtsson/conda-stage
ISC License
7 stars 0 forks source link

BUG: Stray output from 'conda install' when staging, causing issues for `conda-stage()` #15

Closed HenrikBengtsson closed 2 years ago

HenrikBengtsson commented 2 years ago
(base) [hb-test@dev2 ~]$ time conda-stage
INFO: Staging current conda (/wynton/home/bengtsson/hb-test/miniconda3) environment to local disk ...
INFO: Installing conda-pack ...

==> WARNING: A newer version of conda exists. <==
  current version: 4.11.0
  latest version: 4.12.0

Please update conda by running

    $ conda update -n base -c defaults conda

INFO: Packaging conda environment ...
INFO: Extracting /wynton/home/bengtsson/hb-test/base.tar.gz (444294844 bytes; 2022-04-14 10:01:25.000000000 -0700) to /tmp/conda-stage-t6WY/base
INFO: Activating staged conda environment: /tmp/conda-stage-t6WY/base
-bash: syntax error near unexpected token `('
-bash: syntax error near unexpected token `('
HenrikBengtsson commented 2 years ago

This is because conda install --yes --channel=conda-forge conda-pack outputs some messages to stdout;

$ conda install --yes --channel=conda-forge conda-pack > stdout 2> stderr
$ ls -l stdout stderr
-rw-rw-r-- 1 hb hb 183 Apr 14 13:06 stderr
-rw-rw-r-- 1 hb hb 838 Apr 14 13:06 stdout

$ cat stderr

==> WARNING: A newer version of conda exists. <==
  current version: 4.11.0
  latest version: 4.12.0

Please update conda by running

    $ conda update -n base -c defaults conda

$ cat stdout
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/hb/.conda/envs/myenv

  added / updated specs:
    - conda-pack

The following NEW packages will be INSTALLED:

  conda-pack         conda-forge/noarch::conda-pack-0.7.0-pyh6c4a22f_0
  python_abi         conda-forge/linux-64::python_abi-3.9-2_cp39

The following packages will be SUPERSEDED by a higher-priority channel:

  ca-certificates    pkgs/main::ca-certificates-2022.3.29-~ --> conda-forge::ca-certificates-2021.10.8-ha878542_0
  certifi            pkgs/main::certifi-2021.10.8-py39h06a~ --> conda-forge::certifi-2021.10.8-py39hf3d152e_2

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
HenrikBengtsson commented 2 years ago

"Fixed", by redirecting stdout to stderr;

$ conda-stage --debug --quiet
DEBUG: Next CLI argument: --quiet
DEBUG: action: stage
DEBUG: debug: true
DEBUG: verbose: false
DEBUG: dryrun: false
DEBUG: force: false
DEBUG: args: [n=0] 
DEBUG: - Current conda environment: myenv
DEBUG: - Using conda-stage 0.2.0-9003
DEBUG: - Using conda 4.11.0
DEBUG: Additional 'conda install' options: --yes --quiet
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/hb/.conda/envs/myenv

  added / updated specs:
    - conda-pack

The following NEW packages will be INSTALLED:

  conda-pack         conda-forge/noarch::conda-pack-0.7.0-pyh6c4a22f_0
  python_abi         conda-forge/linux-64::python_abi-3.9-2_cp39

The following packages will be SUPERSEDED by a higher-priority channel:

  ca-certificates    pkgs/main::ca-certificates-2022.3.29-~ --> conda-forge::ca-certificates-2021.10.8-ha878542_0
  certifi            pkgs/main::certifi-2021.10.8-py39h06a~ --> conda-forge::certifi-2021.10.8-py39hf3d152e_2

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
DEBUG: - Using conda-pack 0.7.0
DEBUG: - CONDA_PREFIX=/home/hb/.conda/envs/myenv
DEBUG: - Stage cache path: /home/hb/.conda/envs
DEBUG: - Packaged conda environment: /home/hb/.conda/envs/myenv.tar.gz (397363972 bytes; 2022-04-14 13:19:53.185540031 -0700)
DEBUG: - Stage path: /tmp/hb/conda-stage-nrvU/myenv
DEBUG: Command to activate staged conda environment: conda activate "/tmp/hb/conda-stage-nrvU/myenv"