Wulf / create-rust-app

Set up a modern rust+react web app by running one command.

Home Page:https://create-rust-app.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cargo fullstack fails due to errors compiling git-ref

roblperry opened this issue · comments

After creating a new project using create-rust-app 9.0.0 running cargo fullstack results in build failures.

% cargo fullstack
   Compiling git-ref v0.22.0
   Compiling git-glob v0.5.4
   Compiling rustix v0.36.8
   Compiling async-channel v1.8.0
   Compiling aws-config v0.14.0
   Compiling diesel_migrations v2.0.0
   Compiling async-graphql v3.0.38
   Compiling actix-multipart v0.4.0
   Compiling actix-web-actors v4.2.0
   Compiling cargo_toml v0.14.1
   Compiling actix-web-httpauth v0.8.0
   Compiling Inflector v0.11.4
   Compiling dotenv v0.15.0
   Compiling voter_validator_2 v0.1.0 (/Users/rlperry/Clients/Lodestone/voter_validator_2)
error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/rustix-0.36.8/src/lib.rs:99:26
   |
99 | #![cfg_attr(rustc_attrs, feature(rustc_attrs))]
   |                          ^^^^^^^^^^^^^^^^^^^^

error[E0282]: type annotations needed
   --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-glob-0.5.4/src/wildmatch.rs:248:62
    |
248 | ...                   let class = &pattern.as_ref()[p_idx + 2..closing_bracket_idx - 1];
    |                                            ^^^^^^
    |
help: try using a fully qualified path to specify the expected types
    |
248 |                                         let class = &<BStr as AsRef<T>>::as_ref(pattern)[p_idx + 2..closing_bracket_idx - 1];
    |                                                      +++++++++++++++++++++++++++       ~

For more information about this error, try `rustc --explain E0282`.
error: could not compile `git-glob` due to previous error
warning: build failed, waiting for other jobs to finish...
For more information about this error, try `rustc --explain E0554`.
error: could not compile `rustix` due to previous error
error[E0277]: the trait bound `BStr: AsRef<[_; 0]>` is not satisfied
  --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.22.0/src/store/packed/find.rs:95:35
   |
95 |                 .map(|(_rest, r)| r.name.as_bstr().as_ref())
   |                                   ^^^^^^^^^^^^^^^^ ------ required by a bound introduced by this call
   |                                   |
   |                                   the trait `AsRef<[_; 0]>` is not implemented for `BStr`
   |
   = help: the following other types implement trait `AsRef<T>`:
             <BStr as AsRef<BStr>>
             <BStr as AsRef<[u8]>>

error[E0277]: the trait bound `BStr: AsRef<[_; 0]>` is not satisfied
  --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.22.0/src/store/packed/find.rs:91:33
   |
91 |         a.binary_search_by_key(&full_name.as_ref(), |b: &u8| {
   |                                 ^^^^^^^^^ ------ required by a bound introduced by this call
   |                                 |
   |                                 the trait `AsRef<[_; 0]>` is not implemented for `BStr`
   |
   = help: the following other types implement trait `AsRef<T>`:
             <BStr as AsRef<BStr>>
             <BStr as AsRef<[u8]>>

error[E0283]: type annotations needed
    --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.22.0/src/fullname.rs:109:43
     |
109  |             if let Some(shortened) = name.strip_prefix(category.prefix().as_ref()) {
     |                                           ^^^^^^^^^^^^ -------------------------- type must be known at this point
     |                                           |
     |                                           cannot infer type of the type parameter `P` declared on the associated function `strip_prefix`
     |
     = note: cannot satisfy `_: core::slice::SlicePattern`
note: required by a bound in `core::slice::<impl [T]>::strip_prefix`
    --> /Users/rlperry/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/mod.rs:2284:28
     |
2284 |     pub fn strip_prefix<P: SlicePattern<Item = T> + ?Sized>(&self, prefix: &P) -> Option<&[T]>
     |                            ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::slice::<impl [T]>::strip_prefix`
help: consider specifying the generic argument
     |
109  |             if let Some(shortened) = name.strip_prefix::<P>(category.prefix().as_ref()) {
     |                                                       +++++

error[E0283]: type annotations needed
   --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.22.0/src/fullname.rs:109:43
    |
109 |             if let Some(shortened) = name.strip_prefix(category.prefix().as_ref()) {
    |                                           ^^^^^^^^^^^^                   ------ type must be known at this point
    |                                           |
    |                                           cannot infer type of the type parameter `P` declared on the associated function `strip_prefix`
    |
    = note: multiple `impl`s satisfying `BStr: AsRef<_>` found in the `bstr` crate:
            - impl AsRef<BStr> for BStr;
            - impl AsRef<[u8]> for BStr;
help: consider specifying the generic argument
    |
109 |             if let Some(shortened) = name.strip_prefix::<P>(category.prefix().as_ref()) {
    |                                                       +++++

error[E0283]: type annotations needed
   --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.22.0/src/fullname.rs:132:46
    |
132 |         } else if let Some(shortened) = name.strip_prefix(Category::MainPseudoRef.prefix().as_ref()) {
    |                                              ^^^^^^^^^^^^                                  ------ type must be known at this point
    |                                              |
    |                                              cannot infer type of the type parameter `P` declared on the associated function `strip_prefix`
    |
    = note: multiple `impl`s satisfying `BStr: AsRef<_>` found in the `bstr` crate:
            - impl AsRef<BStr> for BStr;
            - impl AsRef<[u8]> for BStr;
help: consider specifying the generic argument
    |
132 |         } else if let Some(shortened) = name.strip_prefix::<P>(Category::MainPseudoRef.prefix().as_ref()) {
    |                                                          +++++

error[E0283]: type annotations needed
   --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.22.0/src/fullname.rs:139:18
    |
139 |             name.strip_prefix(Category::LinkedPseudoRef { name: "".into() }.prefix().as_ref())
    |                  ^^^^^^^^^^^^                                                        ------ type must be known at this point
    |                  |
    |                  cannot infer type of the type parameter `P` declared on the associated function `strip_prefix`
    |
    = note: multiple `impl`s satisfying `BStr: AsRef<_>` found in the `bstr` crate:
            - impl AsRef<BStr> for BStr;
            - impl AsRef<[u8]> for BStr;
help: consider specifying the generic argument
    |
139 |             name.strip_prefix::<P>(Category::LinkedPseudoRef { name: "".into() }.prefix().as_ref())
    |                              +++++

error[E0283]: type annotations needed
    --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.22.0/src/raw.rs:76:18
     |
76   |                 .strip_prefix(namespace.0.as_bstr().as_ref())
     |                  ^^^^^^^^^^^^ ------------------------------ type must be known at this point
     |                  |
     |                  cannot infer type of the type parameter `P` declared on the associated function `strip_prefix`
     |
     = note: cannot satisfy `_: core::slice::SlicePattern`
note: required by a bound in `core::slice::<impl [T]>::strip_prefix`
    --> /Users/rlperry/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/mod.rs:2284:28
     |
2284 |     pub fn strip_prefix<P: SlicePattern<Item = T> + ?Sized>(&self, prefix: &P) -> Option<&[T]>
     |                            ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `core::slice::<impl [T]>::strip_prefix`
help: consider specifying the generic argument
     |
76   |                 .strip_prefix::<P>(namespace.0.as_bstr().as_ref())
     |                              +++++

error[E0283]: type annotations needed
  --> /Users/rlperry/.cargo/registry/src/github.com-1ecc6299db9ec823/git-ref-0.22.0/src/raw.rs:76:18
   |
76 |                 .strip_prefix(namespace.0.as_bstr().as_ref())
   |                  ^^^^^^^^^^^^                       ------ type must be known at this point
   |                  |
   |                  cannot infer type of the type parameter `P` declared on the associated function `strip_prefix`
   |
   = note: multiple `impl`s satisfying `BStr: AsRef<_>` found in the `bstr` crate:
           - impl AsRef<BStr> for BStr;
           - impl AsRef<[u8]> for BStr;
help: consider specifying the generic argument
   |
76 |                 .strip_prefix::<P>(namespace.0.as_bstr().as_ref())
   |                              +++++

Some errors have detailed explanations: E0277, E0283.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `git-ref` due to 8 previous errors

does this issue also occur on a newly generated project?

Okay just tried it, it does indeed fail on a newly generated project.

steps to reproduce:

  • create a new project
    create-rust-app create test_project
  • cd into new project
    cd test_project
  • attempt to compile it
    cargo fullstack

you'll then get these errors

this makes it clear I need to fast track the CI improvements proposed in #103 so that such errors can be caught beforehand.

Sorry, I should have done steps to reproduce.

No worries, but I'm in class right now, so can you do me a favor and try to see if you can isolate the bug to a specific plugin?

I think the problem is plugin_dev:

Tracing through cargo.lock:

watchexec -> ignore-files -> git-config -> git-ref

Looking in Cargo.toml of create-rust-app

plugin_dev = ["backend_axum", "cargo_toml", "open", "reqwest", "anyhow", "clearscreen", "watchexec", "cargo_metadata", "diesel_migrations", "futures-util"]

It is watchexec that needs fixed. I'm testing via

[patch.crates-io]
ignore-files = { path = "/bla_bla_bla/watchexec/crates/ignore-files" }

But, I still don't have my hello world working and would like to see what I have work before I inflict my "solution" on the watchexec folks. My holdup is probably not your problem. Looks like newbie stuff. However, I am having to run cargo +nightly fullstack instead of just cargo fullstack for a separate issue.

BTW, the changes I believe the watchexec folks need to make looks like this.

% git diff
diff --git a/crates/ignore-files/Cargo.toml b/crates/ignore-files/Cargo.toml
index fdc15e5..8393eed 100644
--- a/crates/ignore-files/Cargo.toml
+++ b/crates/ignore-files/Cargo.toml
@@ -16,7 +16,7 @@ edition = "2021"
 
 [dependencies]
 futures = "0.3.21"
-git-config = "0.14.0"
+gix-config = "0.16.0"
 ignore = "0.4.18"
 miette = "5.3.0"
 thiserror = "1.0.31"
diff --git a/crates/ignore-files/src/discover.rs b/crates/ignore-files/src/discover.rs
index a158d56..f5a248a 100644
--- a/crates/ignore-files/src/discover.rs
+++ b/crates/ignore-files/src/discover.rs
@@ -5,7 +5,7 @@ use std::{
        path::{Path, PathBuf},
 };
 
-use git_config::{path::interpolate::Context as InterpolateContext, File, Path as GitPath};
+use gix_config::{path::interpolate::Context as InterpolateContext, File, Path as GitPath};
 use project_origins::ProjectType;
 use tokio::fs::{canonicalize, metadata, read_dir};
 use tracing::{trace, trace_span};
@@ -48,7 +48,7 @@ const PATH_SEPARATOR: &str = ";";
 ///
 /// ## Async
 ///
-/// This future is not `Send` due to [`git_config`] internals.
+/// This future is not `Send` due to [`gix_config`] internals.
 #[allow(clippy::future_not_send)]
 pub async fn from_origin(path: impl AsRef<Path> + Send) -> (Vec<IgnoreFile>, Vec<Error>) {
        let base = path.as_ref().to_owned();
@@ -199,7 +199,7 @@ pub async fn from_origin(path: impl AsRef<Path> + Send) -> (Vec<IgnoreFile>, Vec
 ///
 /// ## Async
 ///
-/// This future is not `Send` due to [`git_config`] internals.
+/// This future is not `Send` due to [`gix_config`] internals.
 #[allow(clippy::future_not_send)]
 pub async fn from_environment(appname: Option<&str>) -> (Vec<IgnoreFile>, Vec<Error>) {
        let mut files = Vec::new();

I gotta take care of some other times, but if I get hello world going, I'll report and error and offer a PR to the watchexec folks.

Hmmm.... watchexec only failed to build if one does a cargo update.

That surprises me a bit. I would have expected the cargo.lock in watchexec to have been used when building watchexec inside of project created by create-rust-app, but apparently not. That would seem to mean that library developers really have to go out of their way to ensure that their lib will continue to build correctly in downstream applications.

commented

Thanks for looking into this @roblperry and for forwarding this to the watchexec repo. I've noticed someone else also came to the same conclusion here

Grrr... how the heck did I miss that? I did look for it.

Now that you have pointed it out to me, @Wulf , I see that execwatch is not yet accempting it :(

Since I've already created a PR, I can just add to the generated Cargo.toml:

[patch.crates-io]
ignore-files = { git = "https://github.com/roblperry/watchexec.git" }

until watchexec is fixed. Obviously, any other readers are welcome to do so as well. Most especially, if you're new around here, as I am, and just want to see how create-rust-app works.

are there any steps we can take as maintainers to patch this on our end @Wulf ?

it seems the upstream issue was fixed recently, but those fixes are yet to be put into a release

Upstream fox should be shipping this weekend

I believe our issues here are fixed as of watchexec release 2.2.0

commented

Fixed