vagrant.d在主文件夹外面

我有一个问题,即我的主目录实际上位于远程服务器上,并且在该服务器上的〜/ .vagrant.d中,vagrant的性能大大降低(并且文件服务器备份大小增加)。

那么有没有办法把至less〜/ vagrant.d / box移出主目录?

干杯。

默认情况下,Vagrant使用~/.vagrant.d 。 幸运的是,stream浪者提供了一个名为VAGRANT_HOME的环境variables,您可以在其中设置stream浪家。

只要做到以下几点改变stream浪家(这只适用于当前会议)

export VAGRANT_HOME=/path/to/vagrant

要使其成为永久的,请将其添加到~/.bash_profile (用于loginshell)。

更新VAGRANT_HOME已被添加到文档 – 环境variables

VAGRANT_HOME可以设置为更改Vagrant存储全局状态的目录。 默认情况下,它被设置为~/.vagrant.d 。 Vagrant主目录是存储盒子等东西的地方,所以它实际上可以在磁盘上变得相当大。

VAGRANT_HOME在我的Windows 8.1中不能正常工作。 它改变了我的文件

d:\ HashiCorp \stream浪\embedded\gem\gem\stream浪-1.5.3 \ lib中\stream浪汉\的environment.rb

在线117

 @home_path = Util::Platform.fs_real_path("D:/vagrant/home/") 

像史蒂夫H说,它工作正常。

通过执行将其永久设置在Windows盒子上可能会很有用

 setx VAGRANT_HOME "/d/.vagrant.d/" 

在Windows上更改environment.rb的第17行,位于:
stream浪\embedded\gem\gem\stream浪-1.xxdev \ lib中\stream浪汉\的environment.rb

另一个地方(它读取ENVvariables的根地点)在shared_helpers.rb第71行(vagrant v 1.6.5)中:

  # This returns the path to the ~/.vagrant.d folder where Vagrant's # per-user state is stored. # # @return [Pathname] def self.user_data_path # Use user spcified env var if available path = ENV["VAGRANT_HOME"] # On Windows, we default to the USERPROFILE directory if it # is available. This is more compatible with Cygwin and sharing # the home directory across shells. if !path && ENV["USERPROFILE"] path = "#{ENV["USERPROFILE"]}/.vagrant.d" end # Fallback to the default path ||= "~/.vagrant.d" Pathname.new(path).expand_path end 

无论如何,我认为最好的方法是使用环境variablesVAGRANT_HOME,以防stream浪版本升级。

你可以使用这个function,如:

 disk_path = self.user_data_path().to_s