Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conda run uses verbosity meant for executable #13639

Open
2 tasks done
milongo opened this issue Feb 29, 2024 · 8 comments
Open
2 tasks done

conda run uses verbosity meant for executable #13639

milongo opened this issue Feb 29, 2024 · 8 comments
Labels
backlog issue has been triaged but has not been earmarked for any upcoming release severity::1 blocker; broken functionality with no workaround source::community catch-all for issues filed by community members type::bug describes erroneous operation, use severity::* to classify the type

Comments

@milongo
Copy link

milongo commented Feb 29, 2024

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

Hi,
I have a python script that accepts a verbosity parameter exactly like conda run does, i.e. with -v or --verbose, where doing -vv or -vvv increases the verbosity level. If I do something like

conda run -n myenv -v ./myscript.py -vv 

I get this log at the beginning of my app's execution:

DEBUG conda.gateways.logging:set_log_level(232): log_level set to 10

It seems like the -vs were somehow added?
I'm not sure if this is a bug or not, but it looks like it since I did not mean to set the conda verbosity level to debug mode.

Conda Info

active environment : myenv
       user config file : /.condarc
 populated config files : 
          conda version : 24.1.2
    conda-build version : not installed
         python version : 3.11.5.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=m1
                          __conda=24.1.2=0
                          __glibc=2.31=0
                          __linux=6.4.16=0
                          __unix=0=0
       base environment : /opt/conda  (read only)
      conda av data dir : /opt/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-aarch64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-aarch64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /opt/conda/pkgs
                          /.conda/pkgs
       envs directories : /.conda/envs
                          /opt/conda/envs
               platform : linux-aarch64
             user-agent : conda/24.1.2 requests/2.31.0 CPython/3.11.5 Linux/6.4.16-linuxkit debian/11.8 glibc/2.31 solver/libmamba conda-libmamba-solver/23.11.1 libmambapy/1.5.3
                UID:GID : 1500:1500
             netrc file : None
           offline mode : False

Conda Config

==> envvars <==
always_yes: True

Conda list

# packages in environment at /opt/conda:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main    defaults
_openmp_mutex             5.1                      51_gnu    defaults
archspec                  0.2.1              pyhd3eb1b0_0    defaults
boltons                   23.0.0          py311hd43f75c_0    defaults
brotli-python             1.0.9           py311h419075a_7    defaults
bzip2                     1.0.8                hfd63f10_2    defaults
c-ares                    1.19.1               h998d150_0    defaults
ca-certificates           2023.12.12           hd43f75c_0    defaults
certifi                   2024.2.2        py311hd43f75c_0    defaults
cffi                      1.15.1          py311h998d150_3    defaults
charset-normalizer        2.0.4              pyhd3eb1b0_0    defaults
conda                     24.1.2          py311hd43f75c_0    defaults
conda-content-trust       0.2.0           py311hd43f75c_0    defaults
conda-libmamba-solver     23.11.1         py311hd43f75c_0    defaults
conda-package-handling    2.2.0           py311hd43f75c_0    defaults
conda-package-streaming   0.9.0           py311hd43f75c_0    defaults
cryptography              41.0.3          py311h5077475_0    defaults
distro                    1.8.0           py311hd43f75c_0    defaults
fmt                       9.1.0                hb8fdbf2_0    defaults
icu                       73.1                 h419075a_0    defaults
idna                      3.4             py311hd43f75c_0    defaults
jsonpatch                 1.32               pyhd3eb1b0_0    defaults
jsonpointer               2.1                pyhd3eb1b0_0    defaults
krb5                      1.20.1               h2e2fba8_1    defaults
ld_impl_linux-aarch64     2.38                 h8131f2d_1    defaults
libarchive                3.6.2                h654c02d_2    defaults
libcurl                   8.4.0                hfa2bbb0_0    defaults
libedit                   3.1.20221030         h998d150_0    defaults
libev                     4.33                 hfd63f10_1    defaults
libffi                    3.4.4                h419075a_0    defaults
libgcc-ng                 11.2.0               h1234567_1    defaults
libgomp                   11.2.0               h1234567_1    defaults
libmamba                  1.5.3                h78dbd8a_0    defaults
libmambapy                1.5.3           py311hd82f176_0    defaults
libnghttp2                1.57.0               hb788212_0    defaults
libsolv                   0.7.24               h94b7715_0    defaults
libssh2                   1.10.0               h6ac735f_2    defaults
libstdcxx-ng              11.2.0               h1234567_1    defaults
libuuid                   1.41.5               h998d150_0    defaults
libxml2                   2.10.4               h045d036_1    defaults
lz4-c                     1.9.4                h419075a_0    defaults
menuinst                  2.0.2           py311hd43f75c_0    defaults
ncurses                   6.4                  h419075a_0    defaults
openssl                   3.0.13               h2f4d8fa_0    defaults
packaging                 23.1            py311hd43f75c_0    defaults
pcre2                     10.42                hcfaa891_0    defaults
pip                       23.3            py311hd43f75c_0    defaults
platformdirs              3.10.0          py311hd43f75c_0    defaults
pluggy                    1.0.0           py311hd43f75c_1    defaults
pybind11-abi              4                    hd3eb1b0_1    defaults
pycosat                   0.6.6           py311h998d150_0    defaults
pycparser                 2.21               pyhd3eb1b0_0    defaults
pyopenssl                 23.2.0          py311hd43f75c_0    defaults
pysocks                   1.7.1           py311hd43f75c_0    defaults
python                    3.11.5               h4bb2201_0    defaults
readline                  8.2                  h998d150_0    defaults
reproc                    14.2.4               h22f4aa5_1    defaults
reproc-cpp                14.2.4               h22f4aa5_1    defaults
requests                  2.31.0          py311hd43f75c_0    defaults
ruamel.yaml               0.17.21         py311h998d150_0    defaults
setuptools                68.0.0          py311hd43f75c_0    defaults
sqlite                    3.41.2               h998d150_0    defaults
tk                        8.6.12               h241ca14_0    defaults
tqdm                      4.65.0          py311h2163289_0    defaults
truststore                0.8.0           py311hd43f75c_0    defaults
tzdata                    2023c                h04d1e81_0    defaults
urllib3                   1.26.18         py311hd43f75c_0    defaults
wheel                     0.41.2          py311hd43f75c_0    defaults
xz                        5.4.2                h998d150_0    defaults
yaml-cpp                  0.8.0                h419075a_0    defaults
zlib                      1.2.13               h998d150_0    defaults
zstandard                 0.19.0          py311h998d150_0    defaults
zstd                      1.5.5                h6a09583_0    defaults

Additional Context

No response

@milongo milongo added the type::bug describes erroneous operation, use severity::* to classify the type label Feb 29, 2024
@travishathaway travishathaway added the source::community catch-all for issues filed by community members label Mar 1, 2024
@travishathaway
Copy link
Contributor

Hi @milongo,

Thanks for filing this. I've tried to recreate this issue on both macOS and Linux with no luck.

Here are the steps I took:

  1. Create a new conda environment with conda create -n test --yes python
  2. Create a test script (test.py) with the following contents:
    #! /usr/bin/env python
    import sys
    
    print(sys.argv)
  3. Change permissions of the script with chmod 755 test.py to make it executable.
  4. Run the following"conda run" command: conda run -n test -v ./test.py -vv, which returns the following output:
    ['./test.py', '-vv']
    
  5. When I run, conda run -n test -vvv ./test.py -vv it returns the following output:
    DEBUG conda.gateways.logging:set_log_level(232): log_level set to 10
    DEBUG conda.gateways.subprocess:subprocess_call(86): executing>> /bin/bash /tmp/tmpkt99ue97
    ['./test.py', '-vv']
    

All the above indicates to me that everything is working as it should.

Is there something I am not doing that you are? And, is there anything else about your system that would be useful to know to help us figure out why you are seeing this?

Unfortunately, until we are able to reliably recreate this on our side, we will be unable to implement fix.

@travishathaway travishathaway added the pending::feedback indicates we are waiting on feedback from the user label Mar 1, 2024
@milongo
Copy link
Author

milongo commented Mar 1, 2024

Hey @travishathaway thanks for the prompt reply. I was working with docker as well and I assumed this would be reproducible outside docker. Now I am thinking I must be doing something wrong, but I'm not sure what it is.

With your example, I built a simple dockerfile:

# syntax=docker/dockerfile:1

FROM continuumio/miniconda3:latest

COPY . .

RUN conda create -n test --yes python

ENTRYPOINT ["conda", "run", "-n", "test", "./test.py"]
CMD ["-vvv"]

If you do docker build and docker run, you'll see a debug log from conda:

(base) ➜  dev-playground docker build -t test/conda .
(base) ➜  dev-playground docker run test/conda       
DEBUG conda.gateways.logging:set_log_level(232): log_level set to 10
DEBUG conda.gateways.subprocess:subprocess_call(80): executing>> /bin/bash /tmp/tmp6ov2mdri
['./test.py', '-vvv']

@conda-bot conda-bot added pending::support indicates user is waiting on support from triage engineers and removed pending::feedback indicates we are waiting on feedback from the user labels Mar 1, 2024
@travishathaway
Copy link
Contributor

Hi @milongo,

I think we have narrowed in on what the problem is:

conda run -n test ./test.py -vvv

This will cause conda to spit out debugging information. This is not the expected behavior because these options should be passed to the script and not conda.

I still cannot reproduce your original invocation though (conda run -n test -v ./test.py -vv).

I would recommend that we use this issue to fix the problem that we can both recreate.

@travishathaway travishathaway added backlog issue has been triaged but has not been earmarked for any upcoming release and removed pending::support indicates user is waiting on support from triage engineers labels Mar 4, 2024
@milongo
Copy link
Author

milongo commented Mar 4, 2024

That makes sense to me! I must have made a mistake at first when trying to write the instructions to reproduce my bug.

@analog-cbarber
Copy link
Contributor

Another way this bug can manifest is if you use conda run containing an argument starting with -v it appears that the base conda command will incorrect attempt to parse that argument. For instance, we have a script that runs pytest using conda run:

$ conda run -n myenv pytest -vs tests
usage: conda [-v] [--no-plugins]
conda: error: argument -v/--verbose: ignored explicit argument 's'

This used to work (at least as of 23.3.1). It still works fine using mamba run.

This makes conda run unreliable

@travishathaway travishathaway added the severity::1 blocker; broken functionality with no workaround label Apr 29, 2024
@jezdez
Copy link
Member

jezdez commented Apr 29, 2024

@kenodegard I think you might know best how this is triggered, I'm guessing because of the preparsing?

@jaimergp
Copy link
Contributor

We should implement -- as a separator, which currently fails with:

$ conda run -n base -- pytest -vs
/var/folders/1b/z374sygs1s96t_xxxv0hr3lr0000gn/T/tmp10g1142s: line 3: --: command not found

ERROR conda.cli.main_run:execute(124): `conda run -- pytest -vs` failed. (See above for error)

This SO answer has some extra details. Maybe we should split on -- if present.

@kenodegard
Copy link
Contributor

@jaimergp beat me to it, yes it's the pre-parser and we need to implement -- support to resolve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog issue has been triaged but has not been earmarked for any upcoming release severity::1 blocker; broken functionality with no workaround source::community catch-all for issues filed by community members type::bug describes erroneous operation, use severity::* to classify the type
Projects
Status: 🆕 New
Development

No branches or pull requests

7 participants