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

fix: update the --frozen logic to error when there is no lockfile #373

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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