我之前在vagrant中安装过插件。现在在不同的MacBook上,我试图安装一些我在旧款MacBook上使用的相同插件。
例如,当我尝试安装vagrant-hostmanager时,我收到ruby权限错误:
$ vagrant plugin install vagrant-hostmanager
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing ffi (1.9.8), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.8'` succeeds before bundling.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/opt/vagrant/embedded/bin/ruby extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/vagrant/embedded/bin/ruby
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/opt/vagrant/embedded/lib/ruby/2.0.0/tmpdir.rb:92:in `mktmpdir': parent directory is world writable but not sticky (ArgumentError)
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:510:in `try_link0'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:534:in `try_link'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:427:in `have_devel?'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:433:in `try_do'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:549:in `block in try_compile'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:502:in `with_werror'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:549:in `try_compile'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:1044:in `block in have_header'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:1043:in `have_header'
from extconf.rb:16:in `<main>'
Gem files will remain installed in /Volumes/Passport/vagrant.d/gems/gems/ffi-1.9.8 for inspection.
Results logged to /Volumes/Passport/vagrant.d/gems/gems/ffi-1.9.8/ext/ffi_c/gem_make.out
有一点不同的是,由于我在本地SSD上的空间紧张,我在.bashrc中定义了以下内容:
export VAGRANT_HOME=/Volumes/Passport/vagrant.d
因此,我的盒子文件存储在2TB USB3驱动器上,而不是占用宝贵的SSD空间。
现在我可以使用sudo执行插件安装,但这会成为一个级联问题,因为vagrant up
现在无法在不执行sudo vagrant up
的情况下看到Vagrantfile中的插件。然后VM由root拥有......你可以看到这种级联如何失控。
任何人都知道什么是错的?我怎么解决?
编辑:我发现如果我将VAGRANT_HOME
更改回默认值~/.vagrant.d
,我可以安装插件 - 但是我的框现在位于默认设置无法访问的卷上。显然这是Ruby限制。
TIA!
答案 0 :(得分:4)
好的,我发现了这个问题,但不清楚解决问题的责任在哪里 - 我认为这是OS X上的Ruby错误(至少是Vagrant中嵌入的版本)。
结果Dir.mktmpdir
期望$ TMPDIR变量设置粘滞位。在OS X上,$ TMPDIR变量指向每个用户目录的唯一,如:
/var/folders/yl/y9zbwwm951v3x6p62yn24ckw0000gn/T
使用
更改粘滞位chmod +t $TMPDIR
或者更合适
chmod 700 $TMPDIR
修复此问题。
注意:我不确定我的$ TMPDIR获得777权限的原因或方式,我已检查过其他OS X 10.10安装,并发现$ TMPDIR正确拥有700个权限。
答案 1 :(得分:0)
我怀疑/ Volumes / Passport上的权限可能很奇怪。您可以尝试:
> sudo chown -R `whoami` /Volumes/Passport
> sudo chmod 755 /Volumes/Passport
然后重试您的安装。