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

--frozen is not equivalent to specifying both --locked and --offline #15239

Open
wegylexy opened this issue Feb 27, 2025 · 2 comments
Open

--frozen is not equivalent to specifying both --locked and --offline #15239

wegylexy opened this issue Feb 27, 2025 · 2 comments
Labels
A-offline Area: offline mode C-bug Category: bug S-needs-team-input Status: Needs input from team on whether/how to proceed.

Comments

@wegylexy
Copy link

Problem

This fails:

cargo install --path . --frozen
0.389   Installing myapp v0.1.0 (/app)
0.472     Updating crates.io index
0.493 error: attempting to make an HTTP request, but --frozen was specified

This works:

cargo install --path . --locked --offline

Steps

FROM rust:alpine AS deps
WORKDIR /app
RUN apk add --no-cache build-base openssl-dev
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && \
    echo "fn main() {}" > src/main.rs && \
    cargo build --release && \
    rm -rf src

FROM deps AS build
COPY src src
RUN cargo install --path . --frozen

FROM alpine:latest AS publish
COPY --from=build /usr/local/cargo/bin/myapp /usr/local/bin/
ENTRYPOINT [ "myapp" ]
docker build -t myapp .

Possible Solution(s)

Specify both --locked and --offline instead of --frozen.

Notes

Environment is Docker Desktop on WSL2

Version

cargo 1.85.0 (d73d2caf9 2024-12-31)
release: 1.85.0
commit-hash: d73d2caf9e41a39daf2a8d6ce60ec80bf354d2a7
commit-date: 2024-12-31
host: x86_64-unknown-linux-musl
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Alpine Linux 3.21.3 [64-bit]
@wegylexy wegylexy added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Feb 27, 2025
@epage
Copy link
Contributor

epage commented Feb 27, 2025

Hmm, some places call offline() and frozen() directly while others call network_allowed. Similar for locked() and frozen() vs lock_update_allowed.

Sometimes, this is for more specific error messages,

Other places, we don't have them paired

@epage epage added A-offline Area: offline mode S-needs-team-input Status: Needs input from team on whether/how to proceed. and removed Command-install S-triage Status: This issue is waiting on initial triage. labels Feb 27, 2025
@epage
Copy link
Contributor

epage commented Feb 27, 2025

From my naive perspective, I would assume each of those calls should be updated for handling both --offline and --frozen. To ensure correctness going forward, I'd go so far as removing GlobalContext::{frozen, offline, locked} and instead have a GobalContext::{offline_flag, locked_flag} as the only time to differentiate seems like it should be when reporting errors.

That so many of these missed calls exists makes me wonder if something there is intentional and would be interested in hearing from someone with more background on when these were added for why they diverge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-offline Area: offline mode C-bug Category: bug S-needs-team-input Status: Needs input from team on whether/how to proceed.
Projects
None yet
Development

No branches or pull requests

2 participants