Last active
August 29, 2015 14:27
-
-
Save alyssais/92458871bbd691d8d374 to your computer and use it in GitHub Desktop.
A very hacky way to require gems from outside a bundler environment
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
require 'shellwords' | |
def require_external_gem(name) | |
return require name unless defined? Bundler | |
dir = Bundler.with_clean_env do | |
`echo #{name.shellescape} | ruby -e \ | |
'puts Gem::Specification.find_by_name(STDIN.read.chomp).gem_dir'`.chomp | |
end | |
$: << File.join(dir, "lib") | |
require name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment