oxidize-rb / rb-sys

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

Why does the linux-musl platform cross compile have a dependency on rubygems 3.3.22? #400

Open kingsleyh opened 3 months ago

kingsleyh commented 3 months ago

Hi,

In my Github actions workflow when I cross compile with x86_64-linux-musl platform specified in my matrix using oxidize-rb/cross-gem-action@main it produces a gem that has a dependency on ruby gems 3.3.22

None of the other platform gems that are built have this dependency. In my app it uses ruby 2.7.8 with rubygems 3.1.6 - so the bundle install fails on the remote server with:

dedup_csv-0.1.8-x86_64-linux-musl requires rubygems version >= 3.3.22, which is
incompatible with the current version, 3.1.6

Is there a way to not have this dependency on rubygems 3.3.22?

my gihtub actions workflow:

https://github.com/kingsleyh/dedup_csv/blob/main/.github/workflows/gem.yml

ianks commented 3 months ago

You should use modify your gemspec to use ext/mygem/extconf.rb instead of Cargo.toml (and add rb_sys ~> 0.9 as a gemspec dep. Then you can remove any required_rubygems_version constraint.

https://github.com/kingsleyh/dedup_csv/blob/7dd6bd321af62a0e00e4cc7e6526a05c8a59aaaf/dedup_csv.gemspec#L28C2-L28C49

kingsleyh commented 3 months ago

Ah thanks - I will try that

kingsleyh commented 3 months ago

hmm even though I have no required_rubygems_version in my gemspec even after changing to use extconf.rb and adding rb_sys as a gemspec dependency - the musl gem produced now has a runtime dependency on rb_sys but it still has a rubygems dependency of 3.3.22 - if I don't build the musl gem at all then the remote server picks the linux one instead of the musl and it works. It's only the musl gem that has this rubygems dependency - maybe its related to the way it's built in docker?

https://rubygems.org/gems/dedup_csv/versions/0.1.12-x86_64-linux-musl

ianks commented 3 months ago

Use RbSys::ExtensionTask instead of Rake::ExtensionTask, that should do it