Rust-Web-Development / code

Code for the book "Rust Web Development"
196 stars 51 forks source link

Current repo fails to build on Windows+nightly due to multiple causes #6

Open CaseyBaileyPDX opened 1 year ago

CaseyBaileyPDX commented 1 year ago

This is largely documentation for others encountering these issues, but I'm happy to provide a PR addressing them if that is preferred?

1) The Windows NTAPI crate has a current bug that impacts at least the final Ch11 code - discussion here Edit - this seems to exist not only in nightly, but also stable

2) Vendored OpenSSL fails to build - this happens because the current vendor build script uses Perl which doesn't produce Windows-compatible paths.

a-bakos commented 1 year ago

@CaseyBaileyPDX - This is also for documentation purposes. For your second point, here's another solution or a different approach, although slightly more effort.

Like you said, this error is coming from the openssl-sys crate (for reference, see the full error message at the end of my comment). "The build is failing because the Perl implementation being used does not produce Windows-like paths".

What does that mean exactly?

In my case, my Git Bash (which I'm using inside IntelliJ) is using a newer version of Perl (v5.36) that is not, at the time, compatible with the current openssl-sys crate. What worked for me was to install Strawberry Perl (a Windows distro of Perl) that currently comes with v5.32. Then I had to repoint my Git Bash to use this version instead of v5.36. And I also had to add a crate to my main Cargo.toml file and here's why: openssl = { version = "0.10", features = ["vendored"] }

To update Git paths to use a different Perl version:


And for reference, the full error message that started popping up during compilation while working through chapter 9:

error: failed to run custom build command for `openssl-sys v0.9.87`

Caused by:
  process didn't exit successfully: `C:\Git\rustwebdev\target\debug\build\openssl-sys-d492c4714352904f\build-script-main` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset
  running "perl" "./Configure" "--prefix=C:\\Git\\rustwebdev\\target\\debug\\build\\openssl-sys-c54c8971777a8736\\out\\openssl-build\\install" "--openssldir=SYS$MANAGER:[OPENSSL]" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-engine" "no-asm" "VC-WIN64A"
  Configuring OpenSSL version 1.1.1t (0x1010114fL) for VC-WIN64A
  Using os-specific seed configuration

  --- stderr

  ******************************************************************************
  This perl implementation doesn't produce Windows like paths (with backward
  slash directory separators).  Please use an implementation that matches your
  building platform.

  This Perl version: 5.36.0 for x86_64-msys-thread-multi
  ******************************************************************************
  thread 'main' panicked at '

  Error configuring OpenSSL build:
      Command: "perl" "./Configure" "--prefix=C:\\Git\\rustwebdev\\target\\debug\\build\\openssl-sys-c54c8971777a8736\\out\\openssl-build\\install" "--openssldir=SYS$MANAGER:[OPENSSL]" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-engine" "no-asm" "VC-WIN64A"
      Exit status: exit code: 127