When I require the vision gem, I get an warning that the :vision key already exists:
irb(main):001:0> require "google/cloud/vision"
Key :vision already exists. It will be replaced. at /Users/ajhamilton/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/google-cloud-vision-0.29.0/lib/google-cloud-vision.rb:116:in `<top (required)>'
=> true
Do you have something else going on in your environment? I don't see this behavior.
$ gem install google-cloud-vision
Fetching: google-cloud-env-1.0.1.gem (100%)
Successfully installed google-cloud-env-1.0.1
Fetching: google-cloud-core-1.2.0.gem (100%)
Successfully installed google-cloud-core-1.2.0
Fetching: google-cloud-vision-0.29.0.gem (100%)
Successfully installed google-cloud-vision-0.29.0
3 gems installed
$ ruby -e 'puts require "google/cloud/vision"'
true
$ irb
irb(main):001:0> require "google/cloud/vision"
=> true
Could you give me more details on what I should look for in the environment? I don't work in ruby very often.
Can you use my steps to reproduce the warning? Does it give you a warning on just your dev computer or does it give warning everywhere?
Looks like I had 0.28.0 and 0.29.0 installed. I uninstalled both and reinstalled 0.29.0 and it fixed the problem.
Interesting! I'll look into this.
So this looks to be due to how we are discovering google-cloud-* gems for the auto-load feature. We currently have:
# Auto-load all Google Cloud service gems.
Gem.find_files("google-cloud-*.rb").each do |google_cloud_service|
require google_cloud_service
end
This code uses Gem.find_files, which works fine, except it will load for every installed gem it finds. If multiple versions of a gem are installed then each version's configuration will get loaded. (This isn't a problem when using Bundler, since the available gems are restricted to what is resolvable through the Gemfile.)
To avoid loading all versions for a gem, Ruby 2.1 added Gem.find_latest_files which only finds files from the latest version of the gem.
I'm working on a PR for this now. Thanks for opening the issue @alixhami!