-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Failure/Error: require 'json-schema-rspec', cannot load such file -- multi_json #448
Comments
This problem has popped up in one of our projects as well since yesterday. We use ruby 2.5.5 in that project. Not sure yet why it started appearing. |
It is likely that this issue happens because the gem multi_json is present on your system. The test |
@lionelperrin: Agreed. Ultimately, this library is using Gem::Specification to determine if multi_json is available to be used. That check is incorrect, as you've noted. While the gem may be installed, Bundler may not make it available to the running application, based on the application's Gemfile. Because this check is wrong, the application errors when multi_json is not available via the Gemfile (not checked here). |
We've encountered the same issue when upgrading rubygems to 3.2.X. I have (several versions of) |
FYI @nbibler this was caused by a bug in rubygems - the fix has been released in 3.2.5 (and 3.2.6 is now also available) upgrade with |
Thanks @owst! |
In Ruby 2.7.2, Rubygems 3.2.0, and Bundler 2.2.0, the multi_json check fails in projects which do not have a multi_json dependency in their dependency tree.
https://github.com/ruby-json-schema/json-schema/blob/2f95d53d62428d603601a1346d6e12a70e7a505d/lib/json-schema.rb#L3-L4
When executed under Bundler, the application Rubygems are isolated to only those in the dependency tree. The Rubygems check performed above (
Gem::Specification::find_all_by_name('multi_json').any?
) returnstrue
even though the Rubygem is not available to the application to load (requiring it results in aLoadError
).Rather than asking Rubygems if the library exists, it is more common to simply attempt to load the library and handle a
LoadError
. See Rails, for examples.The text was updated successfully, but these errors were encountered: