Fix up local gem plugin installation when not published remotely
This commit is contained in:
parent
ea13988367
commit
6e40d46c50
|
@ -140,19 +140,14 @@ module Vagrant
|
|||
# @param [String] path Path to a local gem file.
|
||||
# @return [Gem::Specification]
|
||||
def install_local(path)
|
||||
installer = Gem::Installer.at(path,
|
||||
ignore_dependencies: true,
|
||||
install_dir: plugin_gem_path.to_s
|
||||
)
|
||||
installer.install
|
||||
new_spec = installer.spec
|
||||
plugin_source = Gem::Source::SpecificFile.new(path)
|
||||
plugin_info = {
|
||||
new_spec.name => {
|
||||
'gem_version' => new_spec.version.to_s
|
||||
plugin_source.spec.name => {
|
||||
'local_source' => plugin_source
|
||||
}
|
||||
}
|
||||
internal_install(plugin_info, {})
|
||||
new_spec
|
||||
plugin_source.spec
|
||||
end
|
||||
|
||||
# Update updates the given plugins, or every plugin if none is given.
|
||||
|
@ -231,6 +226,8 @@ module Vagrant
|
|||
|
||||
update = {} unless update.is_a?(Hash)
|
||||
|
||||
installer_set = Gem::Resolver::InstallerSet.new(:both)
|
||||
|
||||
# Generate all required plugin deps
|
||||
plugin_deps = plugins.map do |name, info|
|
||||
if update == true || (update[:gems].respond_to?(:include?) && update[:gems].include?(name))
|
||||
|
@ -238,6 +235,9 @@ module Vagrant
|
|||
else
|
||||
gem_version = info['gem_version'].to_s.empty? ? '> 0' : info['gem_version']
|
||||
end
|
||||
if plugin_source = info.delete("local_source")
|
||||
installer_set.add_local(plugin_source.spec.name, plugin_source.spec, plugin_source)
|
||||
end
|
||||
Gem::Dependency.new(name, gem_version)
|
||||
end
|
||||
|
||||
|
@ -254,7 +254,7 @@ module Vagrant
|
|||
request_set.import(existing_deps)
|
||||
|
||||
# Generate the required solution set for new plugins
|
||||
solution = request_set.resolve(Gem::Resolver::InstallerSet.new(:both))
|
||||
solution = request_set.resolve(installer_set)
|
||||
|
||||
# If any items in the solution set are local but not activated, turn them on
|
||||
solution.each do |activation_request|
|
||||
|
|
|
@ -47,7 +47,6 @@ module Vagrant
|
|||
local_spec = Vagrant::Bundler.instance.install_local(name)
|
||||
name = local_spec.name
|
||||
opts[:version] = local_spec.version.to_s
|
||||
local = true
|
||||
end
|
||||
|
||||
plugins = installed_plugins
|
||||
|
@ -57,21 +56,24 @@ module Vagrant
|
|||
"sources" => opts[:sources],
|
||||
}
|
||||
|
||||
result = nil
|
||||
install_lambda = lambda do
|
||||
Vagrant::Bundler.instance.install(plugins, local).each do |spec|
|
||||
next if spec.name != name
|
||||
next if result && result.version >= spec.version
|
||||
result = spec
|
||||
if local_spec.nil?
|
||||
result = nil
|
||||
install_lambda = lambda do
|
||||
Vagrant::Bundler.instance.install(plugins, local).each do |spec|
|
||||
next if spec.name != name
|
||||
next if result && result.version >= spec.version
|
||||
result = spec
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if opts[:verbose]
|
||||
Vagrant::Bundler.instance.verbose(&install_lambda)
|
||||
if opts[:verbose]
|
||||
Vagrant::Bundler.instance.verbose(&install_lambda)
|
||||
else
|
||||
install_lambda.call
|
||||
end
|
||||
else
|
||||
install_lambda.call
|
||||
result = local_spec
|
||||
end
|
||||
|
||||
# Add the plugin to the state file
|
||||
@user_file.add_plugin(
|
||||
result.name,
|
||||
|
|
Loading…
Reference in New Issue