Skip to content

Issue compiling a project with required_ruby_version >= 3.2.0 #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cretz opened this issue Jan 16, 2025 · 3 comments · Fixed by #146
Closed

Issue compiling a project with required_ruby_version >= 3.2.0 #145

cretz opened this issue Jan 16, 2025 · 3 comments · Fixed by #146

Comments

@cretz
Copy link

cretz commented Jan 16, 2025

I was directed here after discussion on https://github.com/oxidize-rb/rb-sys Slack. I am using their tool rb-sys-dock to cross-compile a Rust-based C-extension, and it just delegates most of the compilation to this one. I have upgraded my project's gemspec to have required_ruby_version = '>= 3.2.0' because I no longer want to build for 3.1.0 and I have 3.2.0-specific things. But it is breaking (I did this at temporalio/sdk-ruby#194 before I reverted it to keep at >= 3.1.0 due to this break). The CI action outputted:

+ rb-sys-dock --platform aarch64-linux --directory ./temporalio --ruby-versions 3.2,3.3,3.4 --build
::info::🐳 Building for Ruby requested versions: ["3.2.0", "3.3.5", "3.4.0"]
::warn::⚠️ Could not determine Cargo rb-sys version
::info::🐳 Downloading container "rbsys/aarch64-linux:0.9.108", this might take awhile...
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Could not find compatible versions

Because every version of temporalio depends on Ruby >= 3.2.0
  and Gemfile depends on temporalio >= 0,
  Ruby >= 3.2.0 is required.
So, because current Ruby version is = 3.1.3,
  version solving has failed.
rake aborted!
Gem::MissingSpecError: Could not find 'grpc-tools' (>= 0) among 89 total gem(s)
Checked in 'GEM_PATH=/tmp/home/rb-sys-dock/.gem/ruby/3.1.0:/usr/local/rbenv/versions/3.1.3/lib/ruby/gems/3.1.0' , execute `gem env` for more information
/home/runner/work/sdk-ruby/sdk-ruby/temporalio/Rakefile:31:in `add_protoc_to_path'
/home/runner/work/sdk-ruby/sdk-ruby/temporalio/Rakefile:41:in `<top (required)>'
(See full trace by running task with --trace)

@jbourassa helpfully pointed out that rb-sys-dock just invokes this at https://github.com/oxidize-rb/rb-sys/blob/0efd9519fb0bd3808794895ede73a1cd008fdeb7/gem/exe/rb-sys-dock#L373-L404 and the docker container is fixed to 3.1 at https://github.com/rake-compiler/rake-compiler-dock/blob/c4e7dc390e0757891ad8c7898953f87a35c957dc/Dockerfile.mri.erb#L77C5-L77C17.

Any suggestions on how to build a >= 3.2.0 with rake-compiler-dock/rb-sys-dock?

@flavorjones
Copy link
Collaborator

flavorjones commented Jan 16, 2025

Congratulations on being the first project to try to drop Ruby 3.1 from their precompiled gem! For sure this is a problem that I did not see coming.

In flavorjones/ruby-c-extensions-explained#40 I tested this:

The issue here is that, in the container, the default Ruby version is 3.1! Ugh.

You can work around this in the short-term by removing the min ruby version requirement from the gemspec (unless that determines the value of RUBY_CC_VERSION for rake-compiler? I'm not familiar with how your gem or rb-sys works.). The ruby version requirement will be set properly in the packaged gem's gemspec regardless.

In the meantime, I'll find some time to try to fix this.

flavorjones added a commit that referenced this issue Jan 16, 2025
Because Ruby 3.1 as the default doesn't work if gems want to drop 3.1

Closes #145
@flavorjones
Copy link
Collaborator

Work ongoing at #146, I'd like to play with it a bit so it may be a few days before that branch lands on master and I cut a release.

@flavorjones
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants