Skip to content

Commit

Permalink
fix: update the --frozen logic to error when there is no lockfile (#373)
Browse files Browse the repository at this point in the history
closes #371 

Error when there is no lockfile and the `--frozen` option is used.
  • Loading branch information
ruben-arts authored Oct 3, 2023
1 parent f6ce9c7 commit b707386
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
13 changes: 10 additions & 3 deletions docs/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Which gets generated on `pixi add` or when you manually change the `pixi.toml` f

- `--manifest-path`: the path to `pixi.toml`, by default it searches for one in the parent directories.
- `--frozen`: install the environment as defined in the lockfile. Without checking the status of the lockfile.
- `--locked`: only install if lockfile is up-to-date. Conflicts with `--frozen`.
- `--locked`: only install if the `pixi.lock` is up-to-date with the `pixi.toml`[^1]. Conflicts with `--frozen`.

```shell
pixi install
Expand All @@ -81,7 +81,7 @@ You cannot run `pixi run source setup.bash` as `source` is not available in the

- `--manifest-path`: the path to `pixi.toml`, by default it searches for one in the parent directories.
- `--frozen`: install the environment as defined in the lockfile. Without checking the status of the lockfile.
- `--locked`: only install if lockfile is up-to-date. Conflicts with `--frozen`.
- `--locked`: only install if the `pixi.lock` is up-to-date with the `pixi.toml`[^1]. Conflicts with `--frozen`.

```shell
pixi run python
Expand Down Expand Up @@ -167,7 +167,7 @@ To exit the pixi shell, simply run `exit`.

- `--manifest-path`: the path to `pixi.toml`, by default it searches for one in the parent directories.
- `--frozen`: install the environment as defined in the lockfile. Without checking the status of the lockfile.
- `--locked`: only install if lockfile is up-to-date. Conflicts with `--frozen`.
- `--locked`: only install if the `pixi.lock` is up-to-date with the `pixi.toml`[^1]. Conflicts with `--frozen`.

```shell
pixi shell
Expand Down Expand Up @@ -328,3 +328,10 @@ pixi project channel add file:///home/user/local_channel
pixi project channel add https://repo.prefix.dev/conda-forge
pixi project channel add --no-install robostack
```

[^1]: An __up-to-date__ lockfile means that the dependencies in the lockfile are allowed by the dependencies in the manifest file.
For example
- a `pixi.toml` with `python = ">= 3.11"` is up-to-date with a `name: python, version: 3.11.0` in the `pixi.lock`.
- a `pixi.toml` with `python = ">= 3.12"` is **not** up-to-date with a `name: python, version: 3.11.0` in the `pixi.lock`.

Being up-to-date does **not** mean that the lockfile holds the latest version available on the channel for the given dependency.
15 changes: 9 additions & 6 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,18 @@ pub async fn get_up_to_date_prefix(
if frozen && locked {
miette::bail!("Frozen and Locked can't be true at the same time, as using frozen will ignore the locked variable.");
}
let lock_file = load_lock_file(project).await?;
let lock_file = if frozen || lock_file_up_to_date(project, &lock_file)? {
lock_file
} else {
if frozen && !project.lock_file_path().is_file() {
miette::bail!("No lockfile available, can't do a frozen installation.");
}

let mut lock_file = load_lock_file(project).await?;

if !frozen && !lock_file_up_to_date(project, &lock_file)? {
if locked {
miette::bail!("Lockfile not up-to-date with the project");
}
update_lock_file(project, lock_file, None).await?
};
lock_file = update_lock_file(project, lock_file, None).await?
}

// Update the environment
update_prefix(
Expand Down

0 comments on commit b707386

Please sign in to comment.