Unable to install plugin hostmanager in vagrant in

2020-07-11 09:09发布

问题:

Not able to install plugin its showing the below error...

C:\devbox>vagrant plugin install 'vagrant-hostmanager' The directory where plugins are installed (the Vagrant home directory) has a space in it. On Windows, there is a bug in Ruby when compiling plugins into directories with spaces. Please move your Vagrant home directory to a path without spaces and try again.

回答1:

Ruby (language used by Vagrant) has "issues" with directory names that contain spaces.

Vagrant will use an environment variable (supplied by windows) to tell it where your user directory is (so it can decide where to put your "home" directory). But you might have a space in your user name (I do) which causes a problem for ruby (which is doing the work to install the plugin).

The solution is to move your project to a project directory you choose that doesn't have any spaces in the directory name. Then, use an environment variable called VAGRANT_HOME and set it to a specified directory. The plugin installation procedure will check for the existence of this variable and use it if it exists instead of locating a home directory within the windows current user directory.

I created a folder called home within C:\Hashicorp\Vagrant and used that (C:\Hashicorp\Vagrant\home).

Setting windows environment variables is not hard (rather trivial actually) - you can find out how here: http://www.computerhope.com/issues/ch000549.htm

You'll have to do a restart to your system for it to take effect (it all worked after a reboot for me).



回答2:

I've found a slight variation to the @Reinsbrains answer. In order to have a home directory without spaces within its name. I created a junction to my user/home directory. In my case I decided to go with a Linux style structure, but any location would work. In an admin command prompt:

mkdir c:\home
mklink /j c:\home\maarten "c:\users\Maarten Bicknese"

Next set the VAGRANT_HOME environment variable to the newly created junction.

setx VAGRANT_HOME c:\home\maarten

Fire up a new command prompt and you're good to go!