-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
Add rake runtime dependency for ruby #15203
Conversation
@JasonLunn @haberman @ericsalo Would you mind take a look at this issue when you get a chance? Thank you. |
@ntkme - does this issue reproduce for you under Ruby 3.2 or lower, or only under 3.3? |
Ruby 3.2 and 3.3, but not super old 2.6, so likely something with modern versions of bundler. The key is |
Here is a script for reproduction: # make sure google-protobuf is not already installed at system level
gem uninstall -a google-protobuf
# create an empty directory
mkdir test
cd test
# write a Gemfile
tee Gemfile <<'EOF'
source 'https://rubygems.org'
gem 'google-protobuf'
EOF
# configure a differen bundle installation path
bundle config --local path vendor/bundle
# note: only the platform ruby and platform java gem has this problem
# therefore setting force_ruby_platform for reliable reproduction on any platform
# for a platform that does not have prebuilt native gem (e.g. aarch64-linux) the issue would always happen
bundle config --local force_ruby_platform true
# install and the issue will reproduce
bundle install |
@JasonLunn ^ I provided a script that you can reproduce this reliably on any Ruby version. |
Rubygems actually prints a warning about this when running https://github.com/rubygems/rubygems/blob/v3.2.0/lib/rubygems/specification_policy.rb#L458-L468
|
@JasonLunn Is there anything else you need? I think more users are now hitting this issue. E.g. If you setup GitHub Actions using setup-ruby the first time (no cached gems), it's always going to fail. https://talk.jekyllrb.com/t/build-error-at-setup-ruby-stage-of-build-and-deploy-on-actions/8782 |
cc @acozzette I hope we can get this addressed before v26 is released. |
This is a holdover until google-protobuf merges protocolbuffers/protobuf#15203
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this is the right approach. I think we can all agree that rake
is not needed at runtime, only install time, and this change would promote rake
to a runtime requirement for protobuf
for everyone.
This seems like a bundler
issue rather than an issue with this gem, and workarounds appear to exist. gem install google-protobuf -i vendor/bundle --platform=ruby
seems to work fine. The problem also goes away if the Gemfile
includes gem 'rake'
, right?
@JasonLunn You cannot expect how user install this, and it’s certainly not a bug of bundler, because
Here is an example that it fails with setup-ruby GitHub action just with its default setting: |
Of course this might not be the best fix, as we need rake as dependency only if we need to run rake based extensions, meaning it is only needed for platform ruby and platform java, as it can be prebuilt for native gems. @JasonLunn A better fix would be not use rake tasks here and just rewrite the rake task as part of extconf.rb. Would you mind look into that, as “workaround” isn’t a fix. |
The |
I am not sure what you're suggesting, as there is already an Before you invest in that approach though - can you confirm whether adding |
My point is to rewrite what the rake task does in pure ruby and put it inside
Yes, it works as a workaround. My point is that we should not expect everyone hitting this issue to do the workaround, because it's not a fault of gem or bundler. It is a clear problem that protobuf has incorrect assumption that rake is always available, per warning message given by |
I took a deeper look into this today, and can confirm that this error message is not triggered when using |
That's likely an oversight of rubygems, but the intent and the meaning of the message is clear. |
I've submitted a PR to rubygems to fix the issue that warning is not printed when rake is added as a development dependency. |
Not to nag (okay, this is nagging, sorry), but this is a downstream dependency of Jekyll and this bug breaks the ability to install Jekyll with the current version of Ruby and the current version of Bundler. |
Given the discussion on the rubygems PR, it is pretty clear what the current limitation is, and that rake shall be added. In fact, I think we should just get this merged as rubygems behavior on rake extensions definitely will not change anytime soon. If that still bothers protobuf developers, the way out is basically to remove reliance on |
@ntkme would this problem be fixed then when v26 is released? |
4.26.0.rc.1 was released on the 25th. |
I just tested
|
This is happening because of a bug on Jekyll and latest Ruby: protocolbuffers/protobuf#15203
We have a rake based extension
ext/google/protobuf_c/Rakefile
(added since 3.25.0), which depends onrake
. However, when gem is installed bybundle
command,rake
is not guaranteed to be activated bybundle
(e.g. whenBUNDLE_PATH
is not default and rake is not already installed inBUNDLE_PATH
). Therefore, we have to explicit declare a runtime dependency onrake
for the extension, or otherwise the installation will fail withcan't find gem rake (>= 0.a) with executable rake (Gem::GemNotFoundException)
.Here is a reproduction: