imsnif / bandwhich

Terminal bandwidth utilization tool
MIT License
10.12k stars 298 forks source link

Windows Error installation #269

Closed directormac closed 1 year ago

directormac commented 1 year ago

current stable rust version it would be best if we had a scoop package like other tools made in rust!

`error[E0793]: reference to packed field is unaligned --> C:\Users\Administrator.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2783:52 2783 tick_count.QuadPart_mut() = read_volatile(&(USER_SHARED_DATA).u.TickCountQuad); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
 = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned --> C:\Users\Administrator.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2807:25 2807 ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
 = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)

For more information about this error, try rustc --explain E0793. error: could not compile ntapi (lib) due to 2 previous errors warning: build failed, waiting for other jobs to finish... error: failed to compile bandwhich v0.20.0, intermediate artifacts can be found at `C:\Users\ADMINI~1\AppData\Local\Temp\cargo-installE7HHMG``

maxim-devpronet commented 1 year ago

As a workaround, here is what you can do:

  1. clone the repo

  2. in the root of the repo, create a file named "rust-toolchain" with such content: " [toolchain] channel = "1.68" " That will use the toolchain that allows the unaligned data.

  3. In the build.rs change the link to the pcap sdk file to (line 19): https://npcap.com/dist/npcap-sdk-1.05.zip

Because now it downloads HTTP redirect page now, the link has to be updated.

  1. Run "cargo build" and you find the bin in the target/debug/ folder.
cyqsimon commented 1 year ago

Fixed in #273. See also #275.

sohang3112 commented 1 year ago

Fixed in #273. See also #275.

@cyqsimon I'm still having this issue while doing cargo install bandwhich in Windows 11. I'm using latest Rust version rustc 1.74.0-nightly.

cyqsimon commented 1 year ago

Fixed in #273. See also #275.

@cyqsimon I'm still having this issue while doing cargo install bandwhich in Windows 11. I'm using latest Rust version rustc 1.74.0-nightly.

cargo install pulls the latest release from crates.io, which hasn't yet been updated.

I'm in the middle of updating the CD pipeline to automate everything, after which a new release will be published. Meanwhile you can try compiling main branch.