rust-osdev / uefi-rs

Rust wrapper for UEFI.
https://rust-osdev.com/uefi-book
Mozilla Public License 2.0
1.23k stars 154 forks source link

Failed to build test-runner isolated. #262

Closed CraftyDH closed 2 years ago

CraftyDH commented 2 years ago

Failed to build test-runner isolated from the main repo.

I modified cargo.toml to use the git versions of uefi and uefi-services instead of a local path.

ie:

[dependencies]
uefi = { path = "..", features = ['exts'] }
uefi-services = { path = "../uefi-services" }

was changed to

[dependencies]
uefi = { git = "https://github.com/rust-osdev/uefi-rs", features = ['exts'] }
uefi-services = { git = "https://github.com/rust-osdev/uefi-rs" }

However the following errors were generated. Is their any reason for why this change should not work?

Build log

C:/uefi-rs/uefi-test-runner> cargo +nightly build --target x86_64-unknown-uefi
   Compiling uefi-test-runner v0.2.0 (C:\Users\Daniel\Documents\GitHub\uefi-rs\uefi-test-runner)
error[E0308]: mismatched types
  --> uefi-test-runner\src\main.rs:26:25
   |
26 |     uefi_services::init(&mut st).expect_success("Failed to initialize utilities");
   |                         ^^^^^^^ expected struct `uefi::table::system::SystemTable`, found struct `uefi::table::SystemTable`
   |
   = note: expected mutable reference `&mut uefi::table::system::SystemTable<uefi::table::system::Boot>`
              found mutable reference `&mut uefi::table::SystemTable<uefi::table::Boot>`
   = note: perhaps two different versions of crate `uefi` are being used?

error[E0599]: no method named `expect_success` found for enum `Result` in the current scope
  --> uefi-test-runner\src\main.rs:26:34
   |
26 |     uefi_services::init(&mut st).expect_success("Failed to initialize utilities");
   |                                  ^^^^^^^^^^^^^^ method not found in `Result<uefi::result::completion::Completion<()>, uefi::result::error::Error>`r>`
   |
  ::: C:\Users\Daniel\Documents\GitHub\uefi-rs\src\result\mod.rs:44:8
   |
44 |     fn expect_success(self, msg: &str) -> Output;
   |        -------------- the method is available for `Result<uefi::result::completion::Completion<()>, uefi::result::error::Error>` here
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
14 | use uefi::result::ResultExt;
   |

Some errors have detailed explanations: E0308, E0599.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `uefi-test-runner` due to 2 previous errors
GabrielMajeri commented 2 years ago

Using the cargo tree reveals that in this scenario you end up with two instances of the uefi-rs crate in the dependency tree:

The solution is to use some Cargo overrides instead to make sure you replace uefi package with the Git version all along the dependency tree.

CraftyDH commented 2 years ago

Thanks @GabrielMajeri that worked.