zboxfs / zbox

Zero-details, privacy-focused in-app file system.
https://zbox.io/fs/
Apache License 2.0
1.54k stars 76 forks source link

Unable to build on Windows 10 using MSVC toolchain #38

Closed amiraeva closed 5 years ago

amiraeva commented 5 years ago

I tried using this in a toy project in Windows and I got this error when trying to build both the latest release on crates.io and the master branch:

PS > cargo build --features libsodium-bundled

error: failed to run custom build command for `zbox v0.7.1 (R:\zbox_master)`
Caused by:
  process didn't exit successfully: `R:/cargo_build/debug\build\zbox-4db8f77a6c10c304\build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: FileNotFound', src\libcore\result.rs:999:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

The relevant part of the backtrace (line numbers reference master branch as of today):

  10: core::result::unwrap_failed<zip::result::ZipError>
             at /rustc/3a5d62bd5675ddd406a5b93d630ba1ddced91777\src\libcore\macros.rs:18
  11: core::result::Result<zip::read::ZipFile, zip::result::ZipError>::unwrap<zip::read::ZipFile,zip::result::ZipError>
             at /rustc/3a5d62bd5675ddd406a5b93d630ba1ddced91777\src\libcore\result.rs:800
  12: build_script_build::download_and_install_libsodium
             at .\build.rs:361
  13: build_script_build::main
             at .\build.rs:26
  14: std::rt::lang_start::{{closure}}<()>
             at /rustc/3a5d62bd5675ddd406a5b93d630ba1ddced91777\src\libstd\rt.rs:64
  15: std::rt::lang_start_internal::{{closure}}
             at /rustc/3a5d62bd5675ddd406a5b93d630ba1ddced91777\/src\libstd\rt.rs:49

The offending line is:

#[cfg(target_arch = "x86_64")]
let mut lib = zip
        .by_name("x64/Release/v142/static/libsodium.lib")
        .unwrap();

I forked the repo, and fixed this issue - in doing so I encountered another issue in which it would only compile if cargo ran in a shell with all the MSVC variables (x64 Native Tools Command Prompt for VS 2019). In my fork I fixed this as well by compiling liblz4 using the cc crate instead of directly invoking cl.

I'm new to contributing so I'm not too familiar with opening a pull request, but I'll give it a shot.