all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to debug a failed build of rust application under cargo-build-system?
@ 2024-02-15 12:43 Tomas Volf
  2024-02-15 13:06 ` woshilapin
  0 siblings, 1 reply; 6+ messages in thread
From: Tomas Volf @ 2024-02-15 12:43 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]

Greetings,

I am trying to package a rust application and the build fails.  I am not sure
how to debug that.  When I try to compile the application using `cargo install',
it does pass and build just fine.  However, when I try to build the application
(imported using the cargo importer) using `guix build', I get this error:

       Compiling tonic v0.10.2
    error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromResidual`)
      --> /tmp/guix-build-netavark-1.10.3.drv-0/netavark-1.10.3/guix-vendor/rust-tonic-0.10.2.tar.gz/src/transport/server/incoming.rs:32:45
       |
    28 | /     async_stream::try_stream! {
    29 | |         tokio::pin!(incoming);
    30 | |
    31 | |         while let Some(item) = incoming.next().await {
    32 | |             yield item.map(ServerIo::new_io)?
       | |                                             ^ cannot use the `?` operator in an async block that returns `()`
    33 | |         }
    34 | |     }
       | |_____- this function should return `Result` or `Option` to accept `?`
       |
       = help: the trait `FromResidual<std::result::Result<Infallible, IE>>` is not implemented for `()`

    For more information about this error, try `rustc --explain E0277`.
    error: could not compile `tonic` (lib) due to previous error

I am not know rust, but this looks like a code error?  If that is the case, I do
not understand why `cargo install' works, since it should be using the same
code.

Could someone nudge me in the right direction regarding how to debug this issue?
I am not really sure where to start.

Thank you and have a nice day,
Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to debug a failed build of rust application under cargo-build-system?
  2024-02-15 12:43 How to debug a failed build of rust application under cargo-build-system? Tomas Volf
@ 2024-02-15 13:06 ` woshilapin
  2024-02-15 13:26   ` Tomas Volf
  0 siblings, 1 reply; 6+ messages in thread
From: woshilapin @ 2024-02-15 13:06 UTC (permalink / raw)
  To: Tomas Volf; +Cc: help-guix

Hi,

It is indeed a code error which looks weird. Are you sure the 2 compilations compile the same source code? How do you invoke `cargo install`? Because if you invoke `cargo install --path .`, then I'm pretty sure it's compiling whatever is on your machine at the current directory. However, any other invocation of `cargo install` might actually pull some source from `crates.io` (the package registry for `cargo`). For example, `cargo install cargo-nextest` will download.
Same applies for `guix build` (I'm a guix very beginner so I might not be the best at this), I'm not sure `guix build` build the current directory. Doesn't it build the `package.scm` which itself describe where to pull the source code?

So, trying a way to be sure that `cargo install` and `guix build` actually build the same source code might a first step. I hope this helps.

Have a nice day.
--
woshilapin

Le jeudi 15 février 2024 à 13:43, Tomas Volf <~@wolfsden.cz> a écrit :

> Greetings,
> 
> I am trying to package a rust application and the build fails. I am not sure
> how to debug that. When I try to compile the application using `cargo install', it does pass and build just fine. However, when I try to build the application (imported using the cargo importer) using` guix build', I get this error:
> 
> Compiling tonic v0.10.2
> error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromResidual`)
> --> /tmp/guix-build-netavark-1.10.3.drv-0/netavark-1.10.3/guix-vendor/rust-tonic-0.10.2.tar.gz/src/transport/server/incoming.rs:32:45
> 
> |
> 28 | / async_stream::try_stream! {
> 29 | | tokio::pin!(incoming);
> 30 | |
> 31 | | while let Some(item) = incoming.next().await {
> 32 | | yield item.map(ServerIo::new_io)?
> | | ^ cannot use the `?` operator in an async block that returns `()`
> 33 | | }
> 34 | | }
> | |_____- this function should return `Result` or `Option` to accept `?`
> |
> = help: the trait `FromResidual<std::result::Result<Infallible, IE>>` is not implemented for `()`
> 
> 
> For more information about this error, try `rustc --explain E0277`.
> error: could not compile `tonic` (lib) due to previous error
> 
> I am not know rust, but this looks like a code error? If that is the case, I do
> not understand why `cargo install' works, since it should be using the same
> code.
> 
> Could someone nudge me in the right direction regarding how to debug this issue?
> I am not really sure where to start.
> 
> Thank you and have a nice day,
> Tomas Volf
> 
> --
> There are only two hard things in Computer Science:
> cache invalidation, naming things and off-by-one errors.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to debug a failed build of rust application under cargo-build-system?
  2024-02-15 13:06 ` woshilapin
@ 2024-02-15 13:26   ` Tomas Volf
  2024-02-15 14:42     ` Nils Landt
  0 siblings, 1 reply; 6+ messages in thread
From: Tomas Volf @ 2024-02-15 13:26 UTC (permalink / raw)
  To: woshilapin; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 3812 bytes --]

On 2024-02-15 13:06:23 +0000, woshilapin wrote:
> Hi,
>
> It is indeed a code error which looks weird. Are you sure the 2 compilations compile the same source code?

Well, technically I am not sure.  I ran the `guix import crate -r netavark' and
used the output from that.  My expectation was that it would walk the
dependencies, and produce the same dependency tree cargo would use.  Is that a
correct expectation?

> How do you invoke `cargo install`?

    cargo install netavark

Which seems to install 1.10.3 version.  That does match my package:

    (name "netavark")
    (version "1.10.3")
    (source
     (origin
       (method url-fetch)
       (uri (crate-uri "netavark" version))
       (file-name (string-append name "-" version ".tar.gz"))
       (sha256
        (base32 "1viyj9xqq9hkcsghrfx7wjmky3hkxfr96952f9favd4zg9ih64yw"))))
    (build-system cargo-build-system)

When I check the failing tonic crate, both (guix package and in output for the
cargo install above) are in 0.10.2 version.

> Because if you invoke `cargo install --path .`, then I'm pretty sure it's compiling whatever is on your machine at the current directory. However, any other invocation of `cargo install` might actually pull some source from `crates.io` (the package registry for `cargo`). For example, `cargo install cargo-nextest` will download.
> Same applies for `guix build` (I'm a guix very beginner so I might not be the best at this), I'm not sure `guix build` build the current directory. Doesn't it build the `package.scm` which itself describe where to pull the source code?
>
> So, trying a way to be sure that `cargo install` and `guix build` actually build the same source code might a first step. I hope this helps.
>
> Have a nice day.
> --
> woshilapin
>
> Le jeudi 15 février 2024 à 13:43, Tomas Volf <~@wolfsden.cz> a écrit :
>
> > Greetings,
> >
> > I am trying to package a rust application and the build fails. I am not sure
> > how to debug that. When I try to compile the application using `cargo install', it does pass and build just fine. However, when I try to build the application (imported using the cargo importer) using` guix build', I get this error:
> >
> > Compiling tonic v0.10.2
> > error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromResidual`)
> > --> /tmp/guix-build-netavark-1.10.3.drv-0/netavark-1.10.3/guix-vendor/rust-tonic-0.10.2.tar.gz/src/transport/server/incoming.rs:32:45
> >
> > |
> > 28 | / async_stream::try_stream! {
> > 29 | | tokio::pin!(incoming);
> > 30 | |
> > 31 | | while let Some(item) = incoming.next().await {
> > 32 | | yield item.map(ServerIo::new_io)?
> > | | ^ cannot use the `?` operator in an async block that returns `()`
> > 33 | | }
> > 34 | | }
> > | |_____- this function should return `Result` or `Option` to accept `?`
> > |
> > = help: the trait `FromResidual<std::result::Result<Infallible, IE>>` is not implemented for `()`
> >
> >
> > For more information about this error, try `rustc --explain E0277`.
> > error: could not compile `tonic` (lib) due to previous error
> >
> > I am not know rust, but this looks like a code error? If that is the case, I do
> > not understand why `cargo install' works, since it should be using the same
> > code.
> >
> > Could someone nudge me in the right direction regarding how to debug this issue?
> > I am not really sure where to start.
> >
> > Thank you and have a nice day,
> > Tomas Volf
> >
> > --
> > There are only two hard things in Computer Science:
> > cache invalidation, naming things and off-by-one errors.

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to debug a failed build of rust application under cargo-build-system?
  2024-02-15 13:26   ` Tomas Volf
@ 2024-02-15 14:42     ` Nils Landt
  2024-02-15 16:23       ` Tomas Volf
  0 siblings, 1 reply; 6+ messages in thread
From: Nils Landt @ 2024-02-15 14:42 UTC (permalink / raw)
  To: Tomas Volf; +Cc: help-guix

> Tomas Volf <~@wolfsden.cz> hat am 15.02.2024 14:26 CET geschrieben:
> 
>  
> On 2024-02-15 13:06:23 +0000, woshilapin wrote:
> > Hi,
> >
> > It is indeed a code error which looks weird. Are you sure the 2 compilations compile the same source code?
> 
> Well, technically I am not sure.  I ran the `guix import crate -r netavark' and
> used the output from that.  My expectation was that it would walk the
> dependencies, and produce the same dependency tree cargo would use.  Is that a
> correct expectation?

Not necessarily correct, no. 
cargo install does not use the lockfile, see https://doc.rust-lang.org/cargo/commands/cargo-install.html#dealing-with-the-lockfile
The cargo-build-system also doesn't use it.
The crate importer also doesn't use it :)

> > > Could someone nudge me in the right direction regarding how to debug this issue?
> > > I am not really sure where to start.

First, I'd try to make sure that guix build rust-tonic works.

This page helped me a lot in getting started: https://guix.gnu.org/manual/en/html_node/Debugging-Build-Failures.html

I tried to reproduce this locally (import and build), building rust-tonic works fine for me.
Funnily enough, I'm running into a completely different error, related to https://github.com/hyperium/tonic/blob/408f46d5f2e1a25547831eb4b064bdeaf3868979/tonic-build/src/lib.rs#L47-L60


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to debug a failed build of rust application under cargo-build-system?
  2024-02-15 14:42     ` Nils Landt
@ 2024-02-15 16:23       ` Tomas Volf
  2024-02-15 18:07         ` Nils Landt
  0 siblings, 1 reply; 6+ messages in thread
From: Tomas Volf @ 2024-02-15 16:23 UTC (permalink / raw)
  To: Nils Landt; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 2039 bytes --]

On 2024-02-15 15:42:51 +0100, Nils Landt wrote:
> > Tomas Volf <~@wolfsden.cz> hat am 15.02.2024 14:26 CET geschrieben:
> >
> >
> > On 2024-02-15 13:06:23 +0000, woshilapin wrote:
> > > Hi,
> > >
> > > It is indeed a code error which looks weird. Are you sure the 2 compilations compile the same source code?
> >
> > Well, technically I am not sure.  I ran the `guix import crate -r netavark' and
> > used the output from that.  My expectation was that it would walk the
> > dependencies, and produce the same dependency tree cargo would use.  Is that a
> > correct expectation?
>
> Not necessarily correct, no.
> cargo install does not use the lockfile, see https://doc.rust-lang.org/cargo/commands/cargo-install.html#dealing-with-the-lockfile
> The cargo-build-system also doesn't use it.
> The crate importer also doesn't use it :)

Oh...  Right, so I managed to track down the difference.  The importer uses
async-stream in 0.3.2 while cargo in 0.3.5.  After updating the packaged version
to 0.3.5, it now compiles, so that is nice.

Wait, it is not.  I assumed that rust is big on the semver.  Should 0.3.2 and
0.3.5 be the same (except bug fixes)? :-O

>
> > > > Could someone nudge me in the right direction regarding how to debug this issue?
> > > > I am not really sure where to start.
>
> First, I'd try to make sure that guix build rust-tonic works.
>
> This page helped me a lot in getting started: https://guix.gnu.org/manual/en/html_node/Debugging-Build-Failures.html
>
> I tried to reproduce this locally (import and build), building rust-tonic works fine for me.
> Funnily enough, I'm running into a completely different error, related to https://github.com/hyperium/tonic/blob/408f46d5f2e1a25547831eb4b064bdeaf3868979/tonic-build/src/lib.rs#L47-L60
>

Yep, you need to provide PROTOC environment variable or patch the source code
(what I do).



But thanks to you I managed to solve this, so thanks :)

Tomas

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to debug a failed build of rust application under cargo-build-system?
  2024-02-15 16:23       ` Tomas Volf
@ 2024-02-15 18:07         ` Nils Landt
  0 siblings, 0 replies; 6+ messages in thread
From: Nils Landt @ 2024-02-15 18:07 UTC (permalink / raw)
  To: Tomas Volf; +Cc: help-guix

> Tomas Volf <~@wolfsden.cz> hat am 15.02.2024 17:23 CET geschrieben:
> 
> Oh...  Right, so I managed to track down the difference.  The importer uses
> async-stream in 0.3.2 while cargo in 0.3.5.  After updating the packaged version
> to 0.3.5, it now compiles, so that is nice.
> 
> Wait, it is not.  I assumed that rust is big on the semver.  Should 0.3.2 and
> 0.3.5 be the same (except bug fixes)? :-O

This was in fact a bug fix in 0.3.3:
https://github.com/tokio-rs/async-stream/blob/master/async-stream/CHANGELOG.md#033

I have been bitten by Guix's "let's disregard patch versions unless it's version 0.0.x" style a few times now.

> But thanks to you I managed to solve this, so thanks :)

Happy to hear you solved it!


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-16 19:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-15 12:43 How to debug a failed build of rust application under cargo-build-system? Tomas Volf
2024-02-15 13:06 ` woshilapin
2024-02-15 13:26   ` Tomas Volf
2024-02-15 14:42     ` Nils Landt
2024-02-15 16:23       ` Tomas Volf
2024-02-15 18:07         ` Nils Landt

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.