Skip to content

Fix logic for running without --file sources #231

@riccardoporreca

Description

@riccardoporreca

Running w/o sources for dependencies is allowed by design (and would use the sources from the lockfile).

However, the CLI interface checks the existence of an environment.y(a)ml file for such cases, as this is the default:

https://github.com/conda-incubator/conda-lock/blob/7d9bd6d67d59fdd30d92a2ace3ee344aafa6a2b1/conda_lock/conda_lock.py#L1134-L1143

How to reproduce

# environment-foo.yml
channels:
- conda-forge
dependencies:
- python=3.8.12
- numpy=1.22.3
platforms:
- win-64
conda-lock -f environment-foo.yml --lockfile conda-lock.yml
# Locking dependencies for ['win-64']...
# INFO:conda_lock.conda_solver:win-64 using specs ['python 3.8.12.*', 'numpy 1.22.3.*']

Running with lock-file only shows the help because no environment.y(a)ml exists:

conda-lock --lockfile conda-lock.yml
# Usage: conda-lock lock [OPTIONS]
# [...]

If we just create an empty environment.yml, the CLI gets past the check above and the rest behaves as expected

conda-lock --lockfile conda-lock.yml
# Locking dependencies for ['win-64']...
# INFO:conda_lock.conda_solver:win-64 using specs ['python 3.8.12.*', 'numpy 1.22.3.*']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions