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
ActiveRecord errors while handling error without Bundler #32830
Comments
If not using Bundler and the specified adapter gem does not exist, `rubygems` raises `Gem::MissingSpecError`. `Gem::MissingSpecError` inherits `LoadError`, but the argument of `initialize` is different. https://github.com/rubygems/rubygems/blob/9054079ce8a1ad05dd206a3562339b74712c7fc6/lib/rubygems/errors.rb#L27..L31 As a result, `ArugmentError` occurs when re-raising the exception. Although it is possible to check the error class and specify appropriate arguments for each of them, I think that it is sufficient to just raise `LoadError`. Together, when using Bundler, fixed that gem which error occurred could not be checked correctly. Fixes rails#32830.
This issue has been automatically marked as stale because it has not been commented on for at least three months. |
|
I don't seem to have a reopen button. |
❤️s for @rafaelfranca!! |
Fixed by #34557. |
Synopsis
When running ActiveRecord, it tries to require the adapter. When requiring the adapter fails, it catches the error message and tries to reraise it with a helpful error explaining that you need to install the gem. When Bundler is loaded, it calls the methods that Bundler monkey patches, which raises a
Gem::LoadError
, and everything works. However, without Bundler, the non-monkey patched version is called, which raises aGem::MissingSpecError
. These aren't compatible because they are initialized differently:So, when ActiveRecord tries to reraise it (here), it explodes.
I've also reported this to Bundler here. There's a bit more analysis there, I'd reproduce it here, but my cat is interfering with my typing.
Steps to reproduce
Invoke
bash run.sh
from this gist.Expected behavior
An error with the message "Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile."
Actual behavior
An error with the message "wrong number of arguments (given 1, expected 2)"
System configuration
ActiveRecord version: 5.2.0
Ruby version: 2.5.0
Rubygems version: 2.7.6
Rubygems version: 1.16.1
The text was updated successfully, but these errors were encountered: