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

[4.6.2] Regression with conda env create -n NAME #8192

Closed
dhirschfeld opened this issue Jan 31, 2019 · 6 comments
Closed

[4.6.2] Regression with conda env create -n NAME #8192

dhirschfeld opened this issue Jan 31, 2019 · 6 comments
Labels
locked [bot] locked due to inactivity stale::closed [bot] closed after being marked as stale stale [bot] marked as stale due to inactivity

Comments

@dhirschfeld
Copy link
Contributor

When I try the conda env create -n NAME -f environment.yml command with a non-existent yml file (i.e. from the wrong directory) I get an inscrutable SpecNotFound error:

(base) C:\dev\code> conda env create -n py-dev -f quantdev.yml

SpecNotFound: Invalid name, try the format: user/package

(base) C:\dev\code>

It seems this problem has cropped up previously (#5681) and was supposed to have been fixed in #7385 so this appears to be a regression?

@dhirschfeld
Copy link
Contributor Author

dhirschfeld commented Jan 31, 2019

(base) C:\dev\code> conda info

     active environment : base
    active env location : C:\Miniconda3
            shell level : 1
       user config file : C:\Users\dhirschfeld\.condarc
 populated config files : C:\Users\dhirschfeld\.condarc
          conda version : 4.6.2
    conda-build version : 3.17.7
         python version : 3.7.1.final.0
       base environment : C:\Miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          http://conda.anaconda.org/conda-forge/win-64
                          http://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Miniconda3\pkgs
                          C:\Users\dhirschfeld\.conda\pkgs
                          C:\Users\dhirschfeld\AppData\Local\conda\conda\pkgs
       envs directories : C:\Miniconda3\envs
                          C:\Users\dhirschfeld\.conda\envs
                          C:\Users\dhirschfeld\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.6.2 requests/2.21.0 CPython/3.7.1 Windows/7 Windows/6.1.7601
          administrator : True
             netrc file : None
           offline mode : False

@javabrett
Copy link
Contributor

I've spotted some bugs in https://github.com/conda/conda/blob/master/tests/conda_env/test_cli.py which result in regressions such as this not being picked-up.

@msarahan
Copy link
Contributor

Care to detail those bugs? What tests would be good to add?

@javabrett
Copy link
Contributor

The main line of test code I'm concerned about (or at least don't understand) is L90:

elif command is Commands.ENV_CREATE: # CREATE
if prefix :
command_line = "{0} -f {1} {2}".format(command, prefix, " ".join(arguments))
else:
command_line = "{0} {1}".format(command, " ".join(arguments))

... which seems to feed the env name or prefix to conda env create -f ... - should that be -n? Fixing that will require some unrelated test fixes.

Then in:

def test_conda_env_create_no_existent_file(self):
'''
Test `conda env create --file=not_a_file.txt` with a file that does not
exist.
'''
try:
run_env_command(Commands.ENV_CREATE, None, '--file not_a_file.txt')
except Exception as e:
self.assertIsInstance(e, EnvironmentFileNotFound)

... will that fail if the exception is not thrown? Seems like it wants a with pytest.raises. Same for test_conda_env_create_no_file.

In looking at these - calls to:

def detect(**kwargs):
filename = kwargs.get('filename')
remote_definition = kwargs.get('name')

e.g.

def execute(args, parser):
from conda.base.context import context
name = args.remote_definition or args.name
try:
spec = specs.detect(name=name, filename=expand(args.file),
directory=os.getcwd())
env = spec.environment

  • combine env name and remote_definition, making them harder to distinguish in the logic for name
  • pre-default file to environment.yml, making it hard to know whether it has been set

Please comment on whether any/all of the above look like valid concerns.

@javabrett
Copy link
Contributor

Possible initial fix was incomplete, rather than a regression. Note issue is specific to -n NAME being supplied.

$ docker run -it --rm conda/miniconda3 conda --version
conda 4.6.4
$ docker run -it --rm conda/miniconda3 conda env create -f not_a_file.txt

EnvironmentFileNotFound: '/not_a_file.txt' file not found

$ docker run -it --rm conda/miniconda3 conda env create -n named -f not_a_file.txt

SpecNotFound: Invalid name, try the format: user/package

So works as expected for invalid -f, but not if -n also specified.

@github-actions
Copy link

Hi there, thank you for your contribution to Conda!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this issue to remain open please:

  1. Verify that you can still reproduce the issue in the latest version of Conda

  2. Comment that the issue is still reproducible and include:

  • What version of Conda you reproduced the issue on
  • What OS and version you reproduced the issue on
  • What steps you followed to reproduce the issue
  1. It would also be helpful to have the output of the following commands available:
  • conda info
  • conda config --show-sources
  • conda list --show-channel-urls

NOTE: If this issue was closed prematurely, please leave a comment and we will gladly reopen the issue.

In case this issue was originally about a project that is covered by the Anaconda issue tracker (e.g. Anaconda, Miniconda, packages built by Anaconda, Inc. like Anaconda Navigator etc), please reopen the issue there again.

Thanks!

@github-actions github-actions bot added the stale [bot] marked as stale due to inactivity label Feb 26, 2022
@github-actions github-actions bot added the stale::closed [bot] closed after being marked as stale label May 15, 2022
@github-actions github-actions bot added the locked [bot] locked due to inactivity label May 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity stale::closed [bot] closed after being marked as stale stale [bot] marked as stale due to inactivity
Projects
None yet
Development

No branches or pull requests

3 participants