Search code examples
rubymacosvagrantvirtualboxvagrantfile

Operation not permitted with vagrant init


I'm trying to install and configure Vagrant but I cannot create a test directory with vagrant init.

I use :

  • OS Sierra 10.12.4
  • Vagrant
  • Virtualbox

My Vagrant version :

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

My Virtualbox version :

# vboxmanage --version
5.1.22r115126

My Ruby version :

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

When I add Vagrant test box and create test directory :

$ 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>'

I don't understand why the command isn't permitted. I'm not sure whether it's coming from ruby.

Thank you in advance for your help.


Solution

  • As it looks you have created your Vagrantfile under /usr/bin/. This is a bad idea

    The Vagrantfile should be at the root of your project directory, this should be under your /Users/<name>/<.../project/...> folder

    The /user/bin folder is reserver for root so you will not have right to write in this folder and just end up with bad configuration if you continue working from there