Skip to content

rustPlatform.buildRustPackage: lockFile does not escape git branches as expected #371692

@baloo

Description

@baloo

Describe the bug

When cargo uses lockfile v4 (rust-lang/cargo#12852), the Cargo.lock will escape the branches names like:

[[package]]
name = "async-signature"
version = "0.6.0-pre.4"
source = "git+https://github.com/baloo/traits.git?branch=baloo%2Fasync-signature%2Fprehash-signer#7eec720f512a8e51710a9c938cbe2af6cf5c5f7b"
dependencies = [
 "signature",
]

This is only displayed when the branch names needs to be escaped (works fine with main/master/etc)

The escape seems to cause the cargo build not to pickup replaced sources correctly.

Steps To Reproduce

A reproducer is available in https://github.com/baloo/cargolock-repro

nix-build should showcase the error.

Expected behavior

Provide the dependency fetched by git to the build

Screenshots

these 2 derivations will be built:
  /nix/store/z8v8wc2rkbbi9sdijf1yjiw6lh7cz100-cargo-vendor-dir.drv
  /nix/store/jkwqs9zd1x78d2i19dqydq8nr4mg9brf-gitlockreproducer.drv
building '/nix/store/z8v8wc2rkbbi9sdijf1yjiw6lh7cz100-cargo-vendor-dir.drv'...
building '/nix/store/jkwqs9zd1x78d2i19dqydq8nr4mg9brf-gitlockreproducer.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/513bb2xfxhy7ysdgf9vq5n9xwy99bc0a-cargoimport
source root is cargoimport
Executing cargoSetupPostUnpackHook
Finished cargoSetupPostUnpackHook
Running phase: patchPhase
Executing cargoSetupPostPatchHook
Validating consistency between /build/cargoimport/Cargo.lock and /build/cargo-vendor-dir/Cargo.lock
Finished cargoSetupPostPatchHook
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
Running phase: buildPhase
Executing cargoBuildHook
cargoBuildHook flags: -j 16 --target x86_64-unknown-linux-gnu --offline --profile release
error: failed to load source for dependency `async-signature`

Caused by:
  Unable to update https://github.com/baloo/traits.git?branch=baloo%2Fasync-signature%2Fprehash-signer#7eec720f

Caused by:
  can't checkout from 'https://github.com/baloo/traits.git': you are in the offline mode (--offline)

Additional context

Metadata

Notify maintainers

@zowoq @winterqt @figsoda


Note for maintainers: Please tag this issue in your PR.


Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: rustGeneral-purpose programming language emphasizing performance, type safety, and concurrency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions