balena-os / wifi-connect

Easy WiFi setup for Linux devices from your mobile phone or laptop
Apache License 2.0
1.29k stars 360 forks source link

Difficulties building #401

Open plafer opened 3 years ago

plafer commented 3 years ago

I tried 2 different ways to build, and both failed. What am I doing wrong?

On Ubuntu 20.04, x86_64.

Try 1

$ cargo build
...
error[E0713]: borrow may still be in use when destructor runs
--> /home/plafer/.cargo/registry/src/github.com-1ecc6299db9ec823/url-1.7.0/src/form_urlencoded.rs:261:40
|
259 | impl<'a> Target for ::UrlQuery<'a> {
    |      -- lifetime `'a` defined here
260 |     fn as_mut_string(&mut self) -> &mut String { &mut self.url.serialization }
261 |     fn finish(self) -> &'a mut ::Url { self.url }
      |                                        ^^^^^^^^ - here, drop of `self` needs exclusive access to `*self.url`, because the type `UrlQuery<'_>` implements the `Drop` trait
  |                                        |
  |                                        returning this value requires that `*self.url` is borrowed for `'a`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0713`.
error: could not compile `url`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Try 2

$ ./scripts/local-build.sh x86_64-unknown-linux-gnu amd64
...
error: failed to parse lock file at: /work/Cargo.lock

Caused by:
invalid serialized PackageId for key `package.dependencies`
plafer commented 3 years ago

Running cargo update updated the culprit: url from 1.7.0 to 1.7.2.

HenrikWittemeier commented 3 years ago

@plafer I had the same issue on Alpine. Installing dbus helped me. I found this Issue https://github.com/greshake/i3status-rust/issues/194 so maybe that helps you.

tm-sanjay commented 1 year ago

deleting the Cargo.lock helped me

MBerka commented 10 months ago

All of the previous solutions looked relevant at different points. Conclusion: must run cargo update before building and also have a recent version of cargo in the system that is running the build. I had 1.74 on my machine but scripts/local-build.sh runs an old Docker image with cargo 0.24. There is no release of the image in the last 6 years but it was possible to enter the image and (since regular rustup update did not affect the cargo version there) reinstall Rust.

docker run -it -v $PWD:/work majorz/rust-amd64:rust-1.24.1 bash
rustup self uninstall
curl https://sh.rustup.rs/ -sSf | sh
cargo --version # cargo 1.74.1 (ecb9851af 2023-10-18).
rustup target add x86_64-unknown-linux-gnu
cargo build --release --target=/x86_64-unknown-linux-gnu

local-build.sh does not seem worth much as-is. For anyone seeing this, I recommend sticking to basic cargo build and trying the last two lines on your host to build the desired target.

hupster commented 9 months ago

I have made myself this build script for cross building for arm64 on Debian Bullseye. It doesn't use docker. Perhaps it is of use to someone. https://github.com/hupster/wifi-connect-build