Skip to content

(Sub)dependency issues preventing compilation of pchain_compile #10

@fabricwave

Description

@fabricwave

Background

@ZUOYANGDING found cargo install pchain_compile will not compile due to a sub-dependency issue affecting gix's compilation.

While investigating this issue, I found a new issue on cargo_toml version requirement, blocking the compilation as well.

Overall reproduction steps

cargo uninstall pchain_compile

cargo install pchain_compile

Context (Environment)

Ubuntu 22.04 LTS.

1. Dependency issue : Cargo failed to select a version for cargo_toml

Expected Behavior

pchain_compile will compile and install successfully.

Current Behavior

cargo install pchain_compile
    Updating crates.io index
  Installing pchain_compile v0.4.3
    Updating crates.io index
error: failed to compile `pchain_compile v0.4.3`, intermediate artifacts can be found at `/tmp/cargo-install`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Caused by:
  failed to select a version for the requirement `cargo_toml = "^0.11.5"`
  candidate versions found which didn't match: 0.20.4, 0.20.3, 0.20.2, ...
  location searched: crates.io index
  required by package `pchain_compile v0.4.3`
  if you are looking for the prerelease package it needs to be specified explicitly

Possible cause

A new yanking of cargo_toml v0.11.3-v0.11.8 from crates.io on August 14, 2024. The yank caused the Cargo to be unable to find a version matching the SemVer requirement specified in pchain_compile v0.4.3 - cargo.toml.

cargo_toml = "0.11.5"

Possible solution

Two suggested solutions.

  1. Use cargo install pchain_compile --locked, I think this allows yanked versions to be used.
  2. Upgrade to a non-yanked version, i.e., 0.20.4, which is one of the stable version available for cargo_toml library as of writing.

2. Subdependency issue: gix dependency fail to compile after bstr update

Expected Behavior

pchain_compile will compile and install successfully.

Current Behavior

error[E0283]: type annotations needed
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-url-0.18.0/src/lib.rs:105:54
    |
105 |             let path = gix_path::from_bstr(self.path.as_ref());
    |                                                      ^^^^^^
    |
    = note: multiple `impl`s satisfying `BString: AsRef<_>` found in the `bstr` crate:
            - impl AsRef<BStr> for BString;
            - impl AsRef<[u8]> for BString;
help: try using a fully qualified path to specify the expected types
    |
105 |             let path = gix_path::from_bstr(<BString as AsRef<T>>::as_ref(&self.path));
    |                                            +++++++++++++++++++++++++++++++         ~

error[E0283]: type annotations needed
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-url-0.18.0/src/lib.rs:105:24
    |
105 |             let path = gix_path::from_bstr(self.path.as_ref());
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for reference `&_`
    |
    = note: multiple `impl`s satisfying `Cow<'_, BStr>: From<&_>` found in the `bstr` crate:
            - impl<'a> From<&'a BStr> for Cow<'a, BStr>;
            - impl<'a> From<&'a BString> for Cow<'a, BStr>;
    = note: required for `&_` to implement `Into<Cow<'_, BStr>>`
note: required by a bound in `from_bstr`
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-path-0.8.4/src/convert.rs:126:34
    |
126 | pub fn from_bstr<'a>(input: impl Into<Cow<'a, BStr>>) -> Cow<'a, Path> {
    |                                  ^^^^^^^^^^^^^^^^^^^ required by this bound in `from_bstr`

Possible cause

bstr - Issue #187, has a comment that it broke gix build on bstr v1.9.2.

upgraded cargo to bstr 1.9.2 and it broke the build of gix

Quote from dev:

The issue looks to be the result of using ambiguous as_ref(). That is, an as_ref() whose inference relies on the fact that there is only one trait implementation to choose from. If new trait implementations are added, then inference fails and a compile error occurs.

This issue likely caused gix, to fail to compile.

Possible solution (credits to @ZUOYANGDING)

  1. Specify a fixed bstr version in pchain_compile's cargo.toml, that should override the bstr version requirement specified by gix.
bstr = "=1.6.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions