oxidize-rb / rb-sys

Easily build Ruby native extensions in Rust
https://oxidize-rb.github.io/rb-sys/
Apache License 2.0
222 stars 34 forks source link

Build failure since `v0.9.88` on Ruby 3.2 / Windows-2022 #340

Closed Stranger6667 closed 5 months ago

Stranger6667 commented 6 months ago

As https://github.com/oxidize-rb/rb-sys/commit/04e0634ccec33751420abe6c3cac4f6b1cc5dd36 landed, I noticed that builds of css-inline started failing. As far as I understand, it might have exposed some underlying problems there, however with v0.9.87, the build was successful, and the tests passed. Even though I use rb-sys via magnus, it is not 100% clear whether it should be addressed in css-inline, magnus, or rb-sys. Posting it here to start the discussion, let me know if I can provide any additional information:

error: failed to run custom build command for `rb-sys v0.9.90`

Caused by:
  process didn't exit successfully: `D:\a\css-inline\css-inline\bindings\ruby\tmp\x64-mingw-ucrt\css_inline\3.2.3\target\release\build\rb-sys-9dddd15e6b5bb505\build-script-main` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=RUBY
  cargo:rerun-if-env-changed=RBCONFIG_CROSS_COMPILING

  --- stderr
  thread 'main' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rb-sys-build-0.9.90\src\rb_config.rs:86:21:
  non-zero exit status while dumping RbConfig: Output { status: ExitStatus(ExitStatus(1)), stdout: "", stderr: "C:/hostedtoolcache/windows/Ruby/3.2.3/x64/lib/ruby/3.2.0/pathname.rb:532:in `relative_path_from': different prefix: \"D:/\" and \"C:/Users/runneradmin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rb-sys-0.9.90\" (ArgumentError)\r\n\tfrom D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/definition.rb:361:in `ensure_equivalent_gemfile_and_lockfile'\r\n\tfrom D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/runtime.rb:13:in `setup'\r\n\tfrom D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler.rb:171:in `setup'\r\n\tfrom D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/setup.rb:23:in `block in <top (required)>'\r\n\tfrom D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/ui/shell.rb:[159](https://github.com/Stranger6667/css-inline/actions/runs/8226567794/job/22493190285#step:6:160):in `with_level'\r\n\tfrom D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/ui/shell.rb:111:in `silence'\r\n\tfrom D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/setup.rb:23:in `<top (required)>'\r\n\tfrom -e:in `require'\r\n" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
make: *** [Makefile:565: target/release/css_inline.dll] Error 101
rake aborted!
Command failed with status (2): [make.exe...]
D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/rake-compiler-1.2.3/lib/rake/extensiontask.rb:201:in `block (2 levels) in define_compile_tasks'
D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/rake-compiler-1.2.3/lib/rake/extensiontask.rb:200:in `block in define_compile_tasks'
D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Tasks: TOP => test => compile => compile:x64-mingw-ucrt => compile:css_inline:x64-mingw-ucrt => copy:css_inline:x64-mingw-ucrt:3.2.3 => tmp/x64-mingw-ucrt/css_inline/3.2.3/css_inline.so
(See full trace by running task with --trace)
mkdir -p lib/css_inline
mkdir -p tmp/x64-mingw-ucrt/css_inline/3.2.3
cd tmp/x64-mingw-ucrt/css_inline/3.2.3
cd -
cd tmp/x64-mingw-ucrt/css_inline/3.2.3
ianks commented 5 months ago

Hmmm... this seems to be the relevant part:

C:/hostedtoolcache/windows/Ruby/3.2.3/x64/lib/ruby/3.2.0/pathname.rb:532:in `relative_path_from': different prefix: "D:/" and "C:/Users/runneradmin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rb-sys-0.9.90" (ArgumentError)
        from D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/definition.rb:361:in `ensure_equivalent_gemfile_and_lockfile'
        from D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/runtime.rb:13:in `setup'
        from D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler.rb:171:in `setup'
        from D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/setup.rb:23:in `block in <top (required)>'
        from D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/ui/shell.rb:159:in `with_level'
        from D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/ui/shell.rb:111:in `silence'
        from D:/a/css-inline/css-inline/bindings/ruby/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/setup.rb:23:in `<top (required)>'
        from -e:in `require'

It seems like when trying to get the rbconfig info, bundler is choking. Something about the C:/ and D:/ windows volumes. I must admit, I'm pretty stumped on this one.

ianks commented 5 months ago

It seems like bundler cache is getting restored to D:/, but Ruby install is in C:/, causing Pathname#relative_path_from to choke. At first glance, it seems like a bundler issue. Can you try to update bundler and see if that helps?

bundler update --bundler

I'm hoping there is an upstream issue that was resolved since v2.4.10

Stranger6667 commented 5 months ago

Hi @ianks

Indeed, updating bundler resolves the issue! Thank you very much!