vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

config.vagrant.plugins source does not resolve correctly

Open polarissunshine opened this issue 1 year ago • 1 comments

Vagrant version = Vagrant 2.4.1 Host Machine = Windows 10

I have a local .gem plugin for my project. The plugin works. I would like to add it as required plugin in the Vagrantfile. Due to the structure of the project I want the gem file in a directory up from the Vagrantfile, so other Vagrantfiles can also access the plugin gem. So I would like do:

config.vagrant.plugins = {"own-plugin" => {"version" => "0.1.0", "sources" => "../own-plugin-0.1.0.gem"}}

But I get this error

Install local plugins (Y/N) [N]: Y
Installing the 'own-plugin' plugin. This can take a few minutes...
Vagrant failed to initialize at a very early stage:

Vagrant failed to properly resolve required dependencies. These
errors can commonly be caused by misconfigured plugin installations
or transient network issues. The reported error is:

Unable to resolve dependency: user requested 'own-plugin (= 0.1.0)'

But all of this work.

config.vagrant.plugins = {"own-plugin" => {"version" => "0.1.0", "sources" => "own-plugin-0.1.0.gem"}}
vagrant plugin install ..\own-plugin-0.1.0.gem
vagrant plugin install ..\own-plugin-0.1.0.gem --local

I'm not sure why moving the gem file one directory up does not work with the config.vagrant.plugins.

I also tried to pass in the absolute path to the gem in the Vagrantfile, but that does not work either. Any workarounds or solution?

polarissunshine avatar Mar 08 '24 15:03 polarissunshine

Hello!

This should work if the path to your gem is provided like

config.vagrant.plugins = ["../own-plugin-0.1.0.gem"]

which is how vagrant plugin install works in your above example. The sources keyword is expected to be a source url where the gem can be downloaded from, like https://rubygems.org/. I believe that when the gem was located in the same directory as the Vagrantfile, the bundler was able to find it without attempting to use the source keyword, which is why it succeeded. It looks like the documentation could be clearer, so apologies for the confusion!

allisonlarson avatar Mar 04 '25 22:03 allisonlarson