rubyrustrubygems

rb-sys Failed to build on Windows latest: defines.h:43:11: fatal error: 'strings.h' file not found\n")


I have a Tauri project and got a compilation error on Windows's latest runner on GitHub action:

error: failed to run custom build command for `rb-sys v0.9.100`
Caused by:
  process didn't exit successfully: `D:\adesktop\src-tauri\target\release\build\rb-sys-ef992799c55b6db2\build-script-main` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=RUBY
  cargo:rerun-if-env-changed=RBCONFIG_CROSS_COMPILING
  cargo:rerun-if-env-changed=RBCONFIG_RUBY_PROGRAM_VERSION
  cargo:rerun-if-env-changed=RBCONFIG_platform
  cargo:rerun-if-env-changed=RUBY_ROOT
  cargo:rerun-if-env-changed=RUBY_VERSION
  cargo:rerun-if-env-changed=RUBY
  cargo:rerun-if-changed=build\features.rs
  cargo:rerun-if-changed=build\main.rs
  cargo:rerun-if-changed=build\stable_api_config.rs
  cargo:rerun-if-changed=build\version.rs
  cargo:rerun-if-env-changed=RUBY_STATIC
  cargo:rerun-if-env-changed=RBCONFIG_ENABLE_SHARED
  cargo:rerun-if-env-changed=RBCONFIG_rubyhdrdir
  cargo:rerun-if-env-changed=RBCONFIG_rubyarchhdrdir
  cargo:rerun-if-env-changed=RBCONFIG_CPPFLAGS
  cargo:rerun-if-env-changed=RBCONFIG_rubyhdrdir
  #include "ruby/re.h"
  #endif
  #ifdef HAVE_RUBY_REGEX_H
  #include "ruby/regex.h"
  #endif
  #ifdef HAVE_RUBY_RUBY_H
  #include "ruby/ruby.h"
  #endif
  #ifdef HAVE_RUBY_ST_H
  #include "ruby/st.h"
  #endif
  #ifdef HAVE_RUBY_THREAD_H
  #include "ruby/thread.h"
  #endif
  #ifdef HAVE_RUBY_THREAD_NATIVE_H
  #include "ruby/thread_native.h"
  #endif
  #ifdef HAVE_RUBY_UTIL_H
  #include "ruby/util.h"
  #endif
  #ifdef HAVE_RUBY_VERSION_H
  #include "ruby/version.h"
  #endif
  #ifdef HAVE_RUBY_VM_H
  #include "ruby/vm.h"
  #endif
  #ifdef HAVE_RUBY_WIN32_H
  #include "ruby/win32.h"
  #endif
  #ifdef HAVE_RUBY_IO_BUFFER_H
  #include "ruby/io/buffer.h"
  #endif
  struct rb_sys__Opaque__RString { struct RString dummy; };
  struct rb_sys__Opaque__RArray { struct RArray dummy; };
  warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
  warning: unknown warning option '-Wimplicit-fallthrough=0'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option]
  warning: unknown warning option '-Wno-packed-bitfield-compat'; did you mean '-Wno-padded-bitfield'? [-Wunknown-warning-option]
  warning: unknown warning option '-Wsuggest-attribute=format'; did you mean '-Wproperty-attribute-mismatch'? [-Wunknown-warning-option]
  warning: unknown warning option '-Wsuggest-attribute=noreturn' [-Wunknown-warning-option]
  warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
  warning: unknown warning option '-Wimplicit-fallthrough=0'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option]
  warning: unknown warning option '-Wno-packed-bitfield-compat'; did you mean '-Wno-padded-bitfield'? [-Wunknown-warning-option]
  warning: unknown warning option '-Wsuggest-attribute=format'; did you mean '-Wproperty-attribute-mismatch'? [-Wunknown-warning-option]
  warning: unknown warning option '-Wsuggest-attribute=noreturn' [-Wunknown-warning-option]
  C:/hostedtoolcache/windows/Ruby/3.2.2/x64/include/ruby-3.2.0\ruby\defines.h:43:11: fatal error: 'strings.h' file not found
  clang diag: warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
  clang diag: warning: unknown warning option '-Wimplicit-fallthrough=0'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option]
  clang diag: warning: unknown warning option '-Wno-packed-bitfield-compat'; did you mean '-Wno-padded-bitfield'? [-Wunknown-warning-option]
  clang diag: warning: unknown warning option '-Wsuggest-attribute=format'; did you mean '-Wproperty-attribute-mismatch'? [-Wunknown-warning-option]
  clang diag: warning: unknown warning option '-Wsuggest-attribute=noreturn' [-Wunknown-warning-option]
  thread 'main' panicked at C:\Users\runneradmin/.cargo\registry\src\index.crates.io-6f17d22bba15001f\rb-sys-0.9.100\build/main.rs:55:6:
  generate bindings: ClangDiagnostic("C:/hostedtoolcache/windows/Ruby/3.2.2/x64/include/ruby-3.2.0\\ruby\\defines.h:43:11: fatal error: 'strings.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
       Error failed to build app: failed to build app
Error: Command failed with exit code 1: npm run release build

Initially, I thought it was because of a mismatch in the Ruby version, which used version 3.0.0 by setup-ruby action. Now it's the correct ruby, but it still has the same errors.

I have several Cargo.toml files. My main Cargo.toml:

[build-dependencies]
tauri-build = { version = "1.5", features = [] }

[dependencies]
anyhow = "1"
chrono = "0.4.31"
futures = "0.3"
home = "0.5.4"
hound = "3"
log = "^0.4"
once_cell = "1.18.0"
reqwest = { version = "0.12", features = ["json"] }
ringbuf = "0.3"
rodio = "0.19"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
serde_repr = "0.1"
tauri = { version = "1.7.1", features = [] }
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1", features = ["colored"] }
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
url-builder = "0.1.1"
uri-template-system = "=0.1.0"

# Local crates
crate_error_codes = { path = "./../../../lib/crate_error_codes" }
crate_models = { path = "./../../../lib/crate_models" }

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = ["custom-protocol"]
# this feature is used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = ["tauri/custom-protocol"]

crate_error_codes:

[package]
name = "crate_error_codes"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_repr = "0.1"
tsync = "1"
magnus = { version = "0.6.2" }
strum = "0.26"
strum_macros = "0.26"

crate_models:

[package]
name = "crate_models"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_repr = "0.1"
tsync = "1"

Any clue?


Solution

  • This is due to magnus, which I no longer use in my project. So, the solution for me was to remove it, and the build worked like a charm.