vagrant init不允许操作

时间:2017-05-22 08:29:25

标签: ruby macos vagrant virtualbox vagrantfile

我尝试安装和配置Vagrant但我无法使用vagrant init创建测试目录。

我用:

  • OS Sierra 10.12.4
  • 流浪
  • VirtualBox的

My Vagrant版本:

# vagrant version
Installed Version: 1.9.5
Latest Version: 1.9.5
You're running an up-to-date version of Vagrant!

我的Virtualbox版本:

# vboxmanage --version
5.1.22r115126

我的Ruby版本:

$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

当我添加Vagrant测试框并创建测试目录时:

$ vagrant box add precise64 http://files.vagrantup.com/precise64.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'precise64' (v0) for provider: 
    box: Downloading: http://files.vagrantup.com/precise64.box
==> box: Successfully added box 'precise64' (v0) for 'virtualbox'!
$ vagrant init precise64
/opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/init/command.rb:69:in `initialize': Operation not permitted @ rb_sysopen - /usr/bin/Vagrantfile (Errno::EPERM)
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/init/command.rb:69:in `open'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/init/command.rb:69:in `open'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/init/command.rb:69:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/cli.rb:42:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:308:in `cli'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/bin/vagrant:138:in `<main>'

我不明白为什么命令不被允许。我不确定它是否来自红宝石。

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

看起来您已在/usr/bin/下创建了Vagrantfile。这是一个坏主意

Vagrantfile应位于项目目录的根目录下,这应位于/Users/<name>/<.../project/...>文件夹

/user/bin文件夹是root用户的reserver,因此如果你继续在那里工作,你将没有权利写入这个文件夹并且最终会出现错误的配置