conda / conda-lock

Lightweight lockfile for conda environments
https://conda.github.io/conda-lock/
Other
489 stars 103 forks source link

Attempt to parse the `install` filename as a version 2 lock even when it does not end in `conda-lock.yml` #464

Closed costrouc closed 1 year ago

costrouc commented 1 year ago

Checklist

What is the idea?

When I was using conda-lock I wanted to control the filename that conda-lock lock ... produces and used environment.yml.lock. I ran into an error when trying to run conda-lock install .... environment.yml.lock.

    do_validate_platform(lockfile_contents)
  File "/home/costrouc/.conda/lib/python3.9/site-packages/conda_lock/conda_lock.py", line 180, in do_validate_platform
    platform_lockfile = extract_platform(lockfile)
  File "/home/costrouc/.conda/lib/python3.9/site-packages/conda_lock/conda_lock.py", line 161, in extract_platform
    raise RuntimeError("Cannot find platform in lockfile.")
RuntimeError: Cannot find platform in lockfile.

This happens because if the lockfile filename does not currently end in conda-lock.yml is parses it as a v1 explicit filename.

What should happen?

Attempt to parse the lockfile as a version 2 yaml file even when the extension is not environment.yml.lock.

Additional Context

Was at Scipy when I ran into this issue and was talking with @mariusvniekerk about it. Realistically this is a user error but I think this is a confusing issue to run into.

maresb commented 1 year ago

Thanks for the suggestion, I agree. Would you like to open a PR?

costrouc commented 1 year ago

@maresb yeah would be happy to open one. Will likely be later this week! (Hope that I remember 🤞)