rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.34k stars 2.33k forks source link

`cargo package --list --manifest-path` in a workspace prints only Cargo.lock on macos #10478

Open konstin opened 2 years ago

konstin commented 2 years ago

Problem

While cargo cargo package --list itself works on all platforms and cargo package --list --manifest-path works on linux and windows, cargo package --list --manifest-path on mac in a workspace prints only Cargo.lock

I've made a reproducer where you can see the results for the three platforms in github actions: https://github.com/PyO3/maturin/runs/5535598729?check_suite_focus=true

Steps

cd /tmp
git clone https://github.com/RazrFalcon/resvg
cd resvg
cargo package --list
cd 
cargo package --list --manifest-path /tmp/resvg/Cargo.toml

Possible Solution(s)

No response

Notes

No response

Version

`rustc 1.59.0 (9d1b2106e 2022-02-23)` and `cargo 1.59.0 (49d8809dc 2022-02-10)`
weihanglo commented 2 years ago

I believe the root cause is that on macOS /tmp symlinks to /private/tmp, but Cargo does not handle symlinks and path canonicalization well for many places.

Repository::workdir() from git2 resolves the symlink whereas Package::manifest_path() does not. That results in a failure from if let Ok(status) = repo.status_file(path).

https://github.com/rust-lang/cargo/blob/b816d82ee94acd4d6be588c0f0cd299701c55457/src/cargo/ops/cargo_package.rs#L405-L430

Although Cargo is a bit conservative on symlink resolving (see this), personally I feel like in this particular case it might be worth doing that. See https://github.com/rust-lang/cargo/issues/10478#issuecomment-1066985734

messense commented 2 years ago

Here is a cargo debug log

❯ CARGO_LOG=debug cargo package --list --manifest-path /tmp/resvg/Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_root - is root /tmp/resvg/Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_members - /tmp/resvg/c-api/Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_members - /tmp/resvg/Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_members - /tmp/resvg/svgfilters/Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_members - /tmp/resvg/usvg/Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_root - pointer /tmp/resvg/c-api/../Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_root - is root /tmp/resvg/Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_root - pointer /tmp/resvg/svgfilters/../Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::core::workspace] find_root - pointer /tmp/resvg/usvg/../Cargo.toml
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] avoid_patch_ids={}
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer adler v1.0.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer adler32 v1.2.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer arrayref v0.3.6
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer arrayvec v0.5.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer arrayvec v0.7.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer autocfg v1.1.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer base64 v0.13.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer bitflags v1.3.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer bytemuck v1.7.3
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer cfg-if v1.0.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer color_quant v1.1.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer crc32fast v1.3.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer data-url v0.1.1
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer deflate v1.0.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer flate2 v1.0.22
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer float-cmp v0.9.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer fontconfig-parser v0.5.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer fontdb v0.9.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer gif v0.11.3
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer jpeg-decoder v0.2.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer kurbo v0.8.3
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer libc v0.2.119
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer log v0.4.14
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer matches v0.1.9
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer memmap2 v0.5.3
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer miniz_oxide v0.4.4
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer miniz_oxide v0.5.1
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer once_cell v1.9.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer pico-args v0.4.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer png v0.17.3
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer rctree v0.4.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer resvg v0.22.0 (/tmp/resvg)
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer resvg-capi v0.22.0 (/tmp/resvg/c-api)
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer rgb v0.8.31
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer roxmltree v0.14.1
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer rustybuzz v0.5.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer safe_arch v0.5.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer simplecss v0.2.1
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer siphasher v0.3.9
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer smallvec v1.8.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer svgfilters v0.4.0 (/tmp/resvg/svgfilters)
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer svgtypes v0.8.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer tiny-skia v0.6.3
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer ttf-parser v0.15.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer unicode-bidi v0.3.7
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer unicode-bidi-mirroring v0.1.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer unicode-ccc v0.1.2
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer unicode-general-category v0.4.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer unicode-script v0.5.4
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer unicode-vo v0.1.0
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer usvg v0.22.0 (/tmp/resvg/usvg)
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer weezl v0.1.5
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer xmlparser v0.13.3
[2022-03-14T14:08:38Z DEBUG cargo::ops::resolve] attempting to prefer xmlwriter v0.1.0
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/missing  /tmp/resvg/c-api
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] loading source /tmp/resvg/c-api
[2022-03-14T14:08:38Z DEBUG cargo::sources::config] loading: /tmp/resvg/c-api
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/missing  /tmp/resvg
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] loading source /tmp/resvg
[2022-03-14T14:08:38Z DEBUG cargo::sources::config] loading: /tmp/resvg
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/missing  /tmp/resvg/svgfilters
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] loading source /tmp/resvg/svgfilters
[2022-03-14T14:08:38Z DEBUG cargo::sources::config] loading: /tmp/resvg/svgfilters
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/missing  /tmp/resvg/usvg
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] loading source /tmp/resvg/usvg
[2022-03-14T14:08:38Z DEBUG cargo::sources::config] loading: /tmp/resvg/usvg
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver] initial activation: resvg-capi v0.22.0 (/tmp/resvg/c-api)
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/missing  registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] loading source registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::config] loading: registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] skipping update due to locked registry
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "3/l/log"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/locked   /tmp/resvg
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ti/ny/tiny-skia"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/locked   /tmp/resvg/usvg
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver] initial activation: resvg v0.22.0 (/tmp/resvg)
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "3/g/gif"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "jp/eg/jpeg-decoder"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "pi/co/pico-args"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "3/p/png"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "3/r/rgb"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/locked   /tmp/resvg/svgfilters
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "sv/gt/svgtypes"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/locked   /tmp/resvg/usvg
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "on/ce/once_cell"
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver] initial activation: svgfilters v0.4.0 (/tmp/resvg/svgfilters)
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "fl/oa/float-cmp"
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver] initial activation: usvg v0.22.0 (/tmp/resvg/usvg)
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ba/se/base64"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "da/ta/data-url"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "fl/at/flate2"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "fo/nt/fontdb"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ku/rb/kurbo"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "rc/tr/rctree"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ro/xm/roxmltree"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ru/st/rustybuzz"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "si/mp/simplecss"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "si/ph/siphasher"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "tt/f-/ttf-parser"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "un/ic/unicode-bidi"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "un/ic/unicode-script"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "un/ic/unicode-vo"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "xm/lw/xmlwriter"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "cf/g-/cfg-if"
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if resvg v0.22.0 (/tmp/resvg) is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ar/ra/arrayref"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ar/ra/arrayvec"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "by/te/bytemuck"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "sa/fe/safe_arch"
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if usvg v0.22.0 (/tmp/resvg/usvg) is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "co/lo/color_quant"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "we/ez/weezl"
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if log v0.4.14 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "bi/tf/bitflags"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "cr/c3/crc32fast"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "de/fl/deflate"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "mi/ni/miniz_oxide"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if svgfilters v0.4.0 (/tmp/resvg/svgfilters) is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if tiny-skia v0.6.3 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if usvg v0.22.0 (/tmp/resvg/usvg) is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if rgb v0.8.31 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ma/tc/matches"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "li/bc/libc"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if float-cmp v0.9.0 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "me/mm/memmap2"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "fo/nt/fontconfig-parser"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if log v0.4.14 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if pico-args v0.4.2 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "xm/lp/xmlparser"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "sm/al/smallvec"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "un/ic/unicode-bidi-mirroring"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "un/ic/unicode-ccc"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "un/ic/unicode-general-category"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if svgtypes v0.8.0 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if cfg-if v1.0.0 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if png v0.17.3 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ad/le/adler32"
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "ad/le/adler"
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if bytemuck v1.7.3 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if siphasher v0.3.9 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if cfg-if v1.0.0 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if crc32fast v1.3.2 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry::index] fast path for registry cache of "au/to/autocfg"
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if miniz_oxide v0.4.4 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if log v0.4.14 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::registry] load/match    registry `crates-io`
[2022-03-14T14:08:38Z DEBUG cargo::sources::registry] attempting query without update
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if ttf-parser v0.15.0 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if bitflags v1.3.2 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if bytemuck v1.7.3 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if ttf-parser v0.15.0 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if unicode-script v0.5.4 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if log v0.4.14 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if bytemuck v1.7.3 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if cfg-if v1.0.0 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if adler v1.0.2 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if libc v0.2.119 is already activated
[2022-03-14T14:08:38Z DEBUG cargo::core::resolver::context] checking if roxmltree v0.14.1 is already activated
[2022-03-14T14:08:38Z DEBUG globset] built glob set; 0 literals, 1 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
[2022-03-14T14:08:38Z WARN  cargo::sources::path] list_files_git resvg v0.22.0 (/tmp/resvg)
[2022-03-14T14:08:38Z DEBUG cargo::ops::cargo_package] found a git repo at "/private/tmp/resvg/"
Cargo.lock

Look like if let Ok(status) = repo.status_file(path) did not fail? My bad, found a git repo at "/private/tmp/resvg/" comes from https://github.com/rust-lang/cargo/blob/b816d82ee94acd4d6be588c0f0cd299701c55457/src/cargo/ops/cargo_package.rs#L404

messense commented 2 years ago

Actually we run cargo package --list --allow-dirty in maturin: https://github.com/PyO3/maturin/blob/95090d027aeca1fae80c0c9fe19ae18f803db8a3/src/source_distribution.rs#L134

so I think the code in check_repo_state function referenced by @weihanglo isn't even runned.

Add a println!("{:?}", src_files); after https://github.com/rust-lang/cargo/blob/b816d82ee94acd4d6be588c0f0cd299701c55457/src/cargo/ops/cargo_package.rs#L97 prints: [].

messense commented 2 years ago

I think the culprit is this code https://github.com/rust-lang/cargo/blob/b816d82ee94acd4d6be588c0f0cd299701c55457/src/cargo/sources/path.rs#L293-L298

for example, when file_path = /private/tmp/resvg/version-bump.md and pkg_path = /tmp/resvg, apparently file_path is canonicalized while pkg_path isn't.

weihanglo commented 2 years ago

@messense you're right. What I found is the result, not the cause. Sorry about the misleading.

BTW, I found it by making cargo package verbose.

$ cd / && cargo package --list --manifest-path /tmp/a-project/Cargo.toml --verbose
warning: No (git) Cargo.toml found at `/tmp/a-project/Cargo.toml` in workdir `/private/tmp/a-project/`
Cargo.lock
messense commented 2 years ago
diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs
index ab1a6180c..b2b6ce586 100644
--- a/src/cargo/ops/cargo_package.rs
+++ b/src/cargo/ops/cargo_package.rs
@@ -204,7 +204,7 @@ fn build_ar_list(
     vcs_info: Option<VcsInfo>,
 ) -> CargoResult<Vec<ArchiveFile>> {
     let mut result = Vec::new();
-    let root = pkg.root();
+    let root = pkg.root().canonicalize()?;
     for src_file in src_files {
         let rel_path = src_file.strip_prefix(&root)?.to_path_buf();
         check_filename(&rel_path, &mut ws.config().shell())?;
diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs
index c0cdd79a9..a61204bfc 100644
--- a/src/cargo/sources/path.rs
+++ b/src/cargo/sources/path.rs
@@ -107,7 +107,8 @@ impl<'cfg> PathSource<'cfg> {
     }

     fn _list_files(&self, pkg: &Package) -> CargoResult<Vec<PathBuf>> {
-        let root = pkg.root();
+        let root = pkg.root().canonicalize()?;
+        let root = root.as_ref();
         let no_include_option = pkg.manifest().include().is_empty();
         let git_repo = if no_include_option {
             self.discover_git_repo(root)?
@@ -229,7 +230,8 @@ impl<'cfg> PathSource<'cfg> {
         let root = repo
             .workdir()
             .ok_or_else(|| anyhow::format_err!("can't list files on a bare repository"))?;
-        let pkg_path = pkg.root();
+        let pkg_path = pkg.root().canonicalize()?;
+        let pkg_path: &Path = pkg_path.as_ref();

         let mut ret = Vec::<PathBuf>::new();

So this patch fixes the problem, but I'm not sure it is the right fix since pkg.root() is used in a lot of places.