Last active
August 29, 2015 14:13
-
-
Save talbright/e5339467eaacbbbf84fc to your computer and use it in GitHub Desktop.
What to do when ruby gems use the same require path and conflict...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/elasticsearch_transition.rb | |
# Both elasticsearch-0.4.11 and rubberband-0.1.6 use 'elasticsearch' | |
# in their respective gem lib dirs. This causes the elasticsearch gem | |
# to incorrectly require same named paths from the wrong gem (in this | |
# case from rubberband). That's because rubberband is in the require | |
# path first. | |
# | |
# You have to set require: false in your Gemfile for the | |
# elasticsearch gems. | |
rubberband = $LOAD_PATH.find { |l| l =~ %r{/rubberband-.*?/lib} } | |
$LOAD_PATH.delete(rubberband) | |
require 'elasticsearch' | |
$LOAD_PATH.unshift(rubberband) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Conflicts like this happen when gem files use the same paths in the lib directory.
rubberband-0.1.6
elasticsearch-transport-0.4.11