Error E0310 - I'm a complete beginner

Hi guys.
I'm completely new to Rust and anything other than Python. So please excuse me for any small errors i might commit.

So I've found a repository on GitHub that I wanted to use, but it had no description on how to install it.

I've asked CoPilot AI, and it turns out this repository was written in Rust. I don't know NOTHING about rust, so I did my research and asked more to the CoPilot, it told me to compile it using the "cargo build" command.

After having installed RustUp and Visual Studio, i hit the "cargo build" command and it's returning me an Error E0310.

Does anyone know what to do at this point ?

Here is the error message in terminal :

Thanks.

TL;DR: Try cargo update -p rustc-serialize

The project you're trying to use is using rustc-serialize, which is a deprecated crate. The specific version it's using was released 7 years ago, and since then the compiler emits a new error to fix a soundness issue in the language. A new patch version of rustc-serialize was released to fix this error.

1 Like

You've got some awful advice from the "AI". The rustc-serialize is very very outdated and has been deprecated for many years.

In most cases Rust uses serde-based packages for serialisation.

Before adding any packages, check https://lib.rs search.

2 Likes

Hi. I tried your solution and it solved the Error E0310. But now i get this error : what you think i should do ?

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> C:\Users\Katya.cargo\registry\src\index.crates.io-6f17d22bba15001f\socket2-0.3.12\src\sockaddr.rs:176:9
|
176 | mem::transmute::<SocketAddrV4, sockaddr_in>(v4);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: SocketAddrV4 (48 bits)
= note: target type: SOCKADDR_IN (128 bits)

Compiling backtrace v0.3.49
For more information about this error, try rustc --explain E0512.
error: could not compile socket2 (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

Thank you a lot but now I have a different error, can you look at my other reply to this post please?
Much thanks.

Is there a reason that you're trying to use a version of socket2 from 4 years ago, instead of a current version?

Pointing us to the repository you're trying to build is likely to be helpful here - you've had one dependency that's 7 years old, and buggy, and now you've found another dependency that's 4 years old, and also contains a bug.

5 Likes

Hey. I really don't know what is socket2, I'm not intentionally making it harder for you guys i swear. I'm just trying to execute "cargo run" command but first i need to successfully execute "cargo build" which returns me the error E0512 right now.

I will send you the repository once I'm back home. I just checked github and it's not there anymore. I had it downloaded back in 2020 and there is no Readme.md in this one.

1 Like

Assuming you just want to build this for one-off use (rather than wanting to keep it working into the future), it might be easier to downgrade your compiler to one that matches the 2020 date for the repo.

Something like:

rustup toolchain install 1.41.0
cargo +1.41.0 build

to use 1.41.0 from January 2020, instead of a more recent compiler.

2 Likes

Don't use that AI. It has been trained on some low-quality outdated data, and is giving you garbage information that is worse than useless. You will not get anything done this way, and with such actively bad advice it's going to be harder than having no advice at all.

Reverting back to unsupported Rust 1.41 is horribly bad idea that will make everything even worse, and cause you even more problems with libraries: 98% of currently maintained Rust libraries will not work with that old version of Rust. Nobody needs to use that version, except your garbage-generating clueless AI that wants you to use an old buggy deprecated version of a library you don't need.

4 Likes

That's the problem, an old repo with no installation instructions is going to be difficult to use at the best of times. Much harder when it's in a language ecosystem you're unfamiliar with.

Basically what is happening here is that this code has "bit rotted". Without knowing what the repo is, it appears that it hasn't been maintained and it no longer works.

This is sadly fairly normal with a lot of software (that doesn't get maintained). While rust has strong backwards compatibility guarantees, newer versions of the compiler will fix problems in ways that need some minor fixes occasionally.

It's not as bad as python 2-3 by any means, these fixes are straight forward (if you know how) individually. You'll find lots of these have accumulated in the last 7 years or more (rust is only about 10 years old!)

It's a bit like jumping from python 3.8 or 3.9 straight to 3.12, somethings are going to break.

In terms of the specifics, these are compiler errors intended for the author of the code. It's normal for these to be a bit difficult to comprehend to anyone who's not familiar with the code that it is complaining about.

Fixing one error will likely reveal another error further on in the compilation, as you've already seen.

These errors are actually a good thing though: rust isn't "broken" it's catching bugs that would normally arise when running the code. And we love the compiler for that :slight_smile:

2 Likes

Hi here's the repository. (We transfer link)

1 Like

I did follow your commands, no error while executing these commands but i get the same error E0512 upon executing "cargo build"

I'm sorry :pensive: i didn't know the ai was this garbage. My research didn't bring me handy results either..

The repo URL is more appropriate, something starting https://github.com/

2 Likes

OK, so this establishes that you're not working with something that's never compiled; when you use a compiler of the same age (roughly) as the code, it compiles, and therefore you're not attempting to debug something that never worked. This makes it simpler, because you're now merely having to update the places where it has always had latent bugs that are now detected by the compiler, instead of having to fix something that might never have built at all.

You'll now need to work on the Rust source itself to update old dependencies to ones that don't have bugs. This is not completely trivial, and it's made very hard by the lack of access to the code for anyone other you (WeTransfer tells me that I need to accept some terms of service that I'm not happy with in order to get to the code).

I would recommend following @drmason13 's advice - put the code in a public github.com repository, and send us a link to that. Your next step, given the error is going to be to run cargo update -p socket2 and see if that fixes it - but continuing to help needs us to have access to the code.

Hi. I've uploaded it to github now.

Can you extract the files from the ZIP, and upload the files instead of a .ZIP? You're making it very hard for anyone to help you, since it's hard to see the files as intended in a web browser if you just upload a ZIP file.

1 Like

I'm so sorry I'm such a dumbass. I uploaded the contents of the zip now. I don't even know how to create folders in github so I created empty files entitled "A" to create folders, ignore those two "A" files inside the folders please.

Looking at that, you could probably get to a point where it compiles and is ready for you to work on by simply running cargo update. There's a lot of things that are outdated in the Cargo.lock, and cargo update will bring them all to a SemVer-compatible later version, hopefully fixing your issues (as main.rs itself is relatively simple)

1 Like

That's it ! Thank you a lot, i finally executed the cargo build command successfully. I mean, partly.

Now having fixed the previous errors I ran the command "cargo run", it returned this error :

error: process didn't exit successfully: target\debug\bip39-solver-gpu.exe (exit code: 101)

Well, it did create an .exe file. But i cannot open it, it just shuts down the second i open it, tried running it with administrative privileges but no luck either.

Anyone knows what's next ? Thank you.