FIX: ensure plugin's gems are in the gem path (#12727)
Let's say you want to use a gem in a plugin that has a dependencie. You would write something like this: ```ruby gem 'dependency-gem', '1.2.3' gem 'amazing-gem', '4.5.6' ``` However, since when we install a plugin gem we install it in the `gems` directory created inside the plugins directory, when it comes the time to install the `amazing-gem`, it won't be able to find the `dependency-gem`. This fixes that issue by adding the `gems` plugins directory to the global gem path. Also fixed a frozen string error when specifying a source.
This commit is contained in:
parent
96a16123d8
commit
c43a7bb23b
|
@ -5,21 +5,24 @@ module PluginGem
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
|
|
||||||
gems_path = File.dirname(path) + "/gems/#{RUBY_VERSION}"
|
gems_path = File.dirname(path) + "/gems/#{RUBY_VERSION}"
|
||||||
|
|
||||||
spec_path = gems_path + "/specifications"
|
spec_path = gems_path + "/specifications"
|
||||||
spec_file = spec_path + "/#{name}-#{version}"
|
|
||||||
|
spec_file = spec_path + "/#{name}-#{version}"
|
||||||
spec_file += "-#{opts[:platform]}" if opts[:platform]
|
spec_file += "-#{opts[:platform]}" if opts[:platform]
|
||||||
spec_file += ".gemspec"
|
spec_file += ".gemspec"
|
||||||
|
|
||||||
unless File.exists? spec_file
|
unless File.exists? spec_file
|
||||||
command = "gem install #{name} -v #{version} -i #{gems_path} --no-document --ignore-dependencies --no-user-install"
|
command = "gem install #{name} -v #{version} -i #{gems_path} --no-document --ignore-dependencies --no-user-install"
|
||||||
if opts[:source]
|
command += " --source #{opts[:source]}" if opts[:source]
|
||||||
command << " --source #{opts[:source]}"
|
|
||||||
end
|
|
||||||
puts command
|
puts command
|
||||||
puts `#{command}`
|
puts `#{command}`
|
||||||
end
|
end
|
||||||
|
|
||||||
if File.exists? spec_file
|
if File.exists? spec_file
|
||||||
spec = Gem::Specification.load spec_file
|
Gem.path << gems_path
|
||||||
spec.activate
|
Gem::Specification.load(spec_file).activate
|
||||||
|
|
||||||
unless opts[:require] == false
|
unless opts[:require] == false
|
||||||
require opts[:require_name] ? opts[:require_name] : name
|
require opts[:require_name] ? opts[:require_name] : name
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue