Vagrant创建大量垃圾配置文件和目录
我正在使用Wagrant和Docker作为供应商 每当我使用任何命令启动Vagrant创建大量垃圾配置文件和目录,vagrant,Vagrant,我正在使用Wagrant和Docker作为供应商 每当我使用任何命令启动vagrant时,目录都会填充四个文件,前缀为“vagrant”,例如“vagrant20150902-10813-1p2j0fh”,以及一个前缀为“d”的目录,例如“d20150902-10813-14u60qc” 这两个都不会自动删除,因此在重新启动几次后,我的pwd会被一组文件和目录弄得乱七八糟,内容完全相同: 有人遇到过这样的麻烦吗?同步文件夹可能有问题 文件内容 流浪者%date%-%id%-%rand1%(例
vagrant
时,目录都会填充四个文件,前缀为“vagrant”,例如“vagrant20150902-10813-1p2j0fh”,以及一个前缀为“d”的目录,例如“d20150902-10813-14u60qc”
这两个都不会自动删除,因此在重新启动几次后,我的pwd会被一组文件和目录弄得乱七八糟,内容完全相同:
有人遇到过这样的麻烦吗?同步文件夹可能有问题
文件内容
流浪者%date%-%id%-%rand1%(例如“流浪者20150902-12033-1j2np7i”)和流浪者%date%-%id%-%rand2%(例如“流浪者20150902-12033-v7vbh4”)为空
流浪者%date%-%id%-%rand2%2(例如“流浪者20150902-12033-v7vbh42”)看起来像一个文件:
source "https://rubygems.org"
source "http://gems.hashicorp.com"
gem "vagrant", "= 1.7.2"
group :plugins do
gem "vagrant-share", nil, {}
end
vagrant%date%-%id%-%rand2%2.lock(例如“vagrant 20150902-12033-v7vbh42.lock”)看起来像Gemfile.lock:
GEM
remote: https://rubygems.org/
remote: http://gems.hashicorp.com/
specs:
akami (1.2.2)
gyoku (>= 0.4.0)
nokogiri
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
childprocess (0.5.5)
ffi (~> 1.0, >= 1.0.11)
erubis (2.7.0)
ffi (1.9.6)
gssapi (1.0.3)
ffi (>= 1.0.1)
...
PLATFORMS
ruby
DEPENDENCIES
vagrant (= 1.7.2)
vagrant-share
目录d%date%-%id%-%rand3%(例如“d20150902-12033-1gkuid5”)包含单个相同的文件配置:
编辑:项目Gemfile和Gemfile.lock都不包含gem'vagrant',我是从.deb包安装的。流浪版本是1.7.4
更新
这看起来很奇怪。我把问题归咎于调用Wagrant::Bundle#deinit:
at_exit(&Vagrant::Bundler.instance.method(:deinit))
该方法在源代码中的外观:
def deinit
File.unlink(ENV["BUNDLE_APP_CONFIG"]) rescue nil
File.unlink(ENV["BUNDLE_CONFIG"]) rescue nil
File.unlink(ENV["GEMFILE"]) rescue nil
end
它尝试取消链接ENV[“BUNDLE\u APP\u CONFIG”]
,这是一个目录,导致一个错误,该错误随后被静默。此外,ENV[“GEMFILE”]
未定义(ENV[“BUNDLE\u GEMFILE”]
was),因此此行也会导致抑制错误
目前,我必须在Vagrant bin中覆盖Vagrant::Bundle#deinit
:
Vagrant::Bundler.class_eval do
def deinit
file1 = ENV["BUNDLE_CONFIG"][0..-2]
file2 = ENV["BUNDLE_GEMFILE"][0..-2]
gemfile_lock = "#{ENV["BUNDLE_GEMFILE"]}.lock"
FileUtils.rm_rf(ENV["BUNDLE_APP_CONFIG"])
File.unlink(ENV["BUNDLE_CONFIG"], ENV["BUNDLE_GEMFILE"], file1, file2, gemfile_lock)
end
end
# Schedule the cleanup of things
at_exit(&Vagrant::Bundler.instance.method(:deinit))
一定有更干净的方法,可惜我还没找到
Upd2:导致这些更改的问题,以及提交。也许我缺少了一些标志或环境变量
Upd3:在
Vagrant::Bundler.class_eval do
def deinit
file1 = ENV["BUNDLE_CONFIG"][0..-2]
file2 = ENV["BUNDLE_GEMFILE"][0..-2]
gemfile_lock = "#{ENV["BUNDLE_GEMFILE"]}.lock"
FileUtils.rm_rf(ENV["BUNDLE_APP_CONFIG"])
File.unlink(ENV["BUNDLE_CONFIG"], ENV["BUNDLE_GEMFILE"], file1, file2, gemfile_lock)
end
end
# Schedule the cleanup of things
at_exit(&Vagrant::Bundler.instance.method(:deinit))