mitchellh/vagrant — Issue #642: Permission denied - /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/keys/vagrant (Errno::EACCES)
Author: Dieterbe
Created: 2012-01-17 16:44:27+00:00
State: open

Hi, new vagrant|ruby user here, bear with me.
so the homepage says:

```
$ gem install vagrant
$ vagrant box add base http://files.vagrantup.com/lucid32.box
$ vagrant init
$ vagrant up
```
the first command fails as regular user, some googling reveals the "solution" when this happens for any gem is to install it as root.

```
17:30:33 dieter@Gi ~ gem install vagrant
Fetching: vagrant-0.8.10.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/lib/ruby/gems/1.9.1 directory.
17:31:32 dieter@Gi ~ sudo gem install vagrant
Fetching: archive-tar-minitar-0.5.2.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: net-ssh-2.1.4.gem (100%)
Fetching: net-scp-1.0.4.gem (100%)
Fetching: i18n-0.6.0.gem (100%)
Fetching: ffi-1.0.11.gem (100%)
Building native extensions. This could take a while...
Fetching: virtualbox-0.9.2.gem (100%)
Fetching: vagrant-0.8.10.gem (100%)
Successfully installed archive-tar-minitar-0.5.2
Successfully installed erubis-2.7.0
Successfully installed net-ssh-2.1.4
Successfully installed net-scp-1.0.4
Successfully installed i18n-0.6.0
Successfully installed ffi-1.0.11
Successfully installed virtualbox-0.9.2
Successfully installed vagrant-0.8.10
8 gems installed
Installing ri documentation for archive-tar-minitar-0.5.2...
Installing ri documentation for erubis-2.7.0...
Installing ri documentation for net-ssh-2.1.4...
unable to convert "\xE7" from ASCII-8BIT to UTF-8 for lib/net/ssh/authentication/pageant.rb, skipping
Installing ri documentation for net-scp-1.0.4...
Installing ri documentation for i18n-0.6.0...
Installing ri documentation for ffi-1.0.11...
Installing ri documentation for virtualbox-0.9.2...
Installing ri documentation for vagrant-0.8.10...
Installing RDoc documentation for archive-tar-minitar-0.5.2...
Installing RDoc documentation for erubis-2.7.0...
Installing RDoc documentation for net-ssh-2.1.4...
unable to convert "\xE7" from ASCII-8BIT to UTF-8 for lib/net/ssh/authentication/pageant.rb, skipping
Installing RDoc documentation for net-scp-1.0.4...
Installing RDoc documentation for i18n-0.6.0...
Installing RDoc documentation for ffi-1.0.11...
Installing RDoc documentation for virtualbox-0.9.2...
Installing RDoc documentation for vagrant-0.8.10...
```

the 2 next steps work fine:

```
17:32:40 dieter@Gi ~ vagrant box add base http://files.vagrantup.com/lucid32.box
[vagrant] Creating home directory since it doesn't exist: /home/dieter/.vagrant.d
[vagrant] Creating home directory since it doesn't exist: /home/dieter/.vagrant.d/tmp
[vagrant] Creating home directory since it doesn't exist: /home/dieter/.vagrant.d/boxes
[vagrant] Creating home directory since it doesn't exist: /home/dieter/.vagrant.d/logs
[vagrant] Downloading with Vagrant::Downloaders::HTTP...
[vagrant] Downloading box: http://files.vagrantup.com/lucid32.box
[vagrant] Extracting box...
[vagrant] Verifying box...
[vagrant] Cleaning up downloaded box...
vagrant box add base http://files.vagrantup.com/lucid32.box 19.39s user 3.09s system 50% cpu 44.697 total
17:33:10 dieter@Gi ~ vagrant init
create Vagrantfile
```

However, `vagrant up` fails because it doesn't have read permissions on a file.

```
17:35:15 dieter@Gi ~ vagrant up
[default] Importing base box 'base'...
[default] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.

Guest Additions Version: 4.1.0
VirtualBox Version: 4.1.8_OSE
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- ssh: 22 => 2222 (adapter 1)
[default] Creating shared folders metadata...
[default] Running any VM customizations...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] Forcing shutdown of VM...
[default] Destroying VM and associated drives...
/usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/key_factory.rb:38:in `read': Permission denied - /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/keys/vagrant (Errno::EACCES)
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/key_factory.rb:38:in `load_private_key'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/key_manager.rb:137:in `sign'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/methods/publickey.rb:62:in `authenticate_with'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/methods/publickey.rb:20:in `block in authenticate'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/key_manager.rb:117:in `block in each_identity'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/key_manager.rb:114:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/key_manager.rb:114:in `each_identity'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/methods/publickey.rb:19:in `authenticate'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/session.rb:73:in `block in authenticate'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/session.rb:65:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/authentication/session.rb:65:in `authenticate'
from /usr/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh.rb:187:in `start'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/ssh.rb:79:in `block in execute'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/util/retryable.rb:14:in `retryable'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/ssh.rb:78:in `execute'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/ssh.rb:118:in `block in up?'
from /usr/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/ssh.rb:117:in `up?'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/boot.rb:29:in `block in wait_for_boot'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/boot.rb:28:in `times'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/boot.rb:28:in `wait_for_boot'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/boot.rb:15:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/modify.rb:32:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/customize.rb:21:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/network.rb:24:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/host_name.rb:10:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/share_folders.rb:15:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/clear_shared_folders.rb:22:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/nfs.rb:39:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/provision.rb:17:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/forward_ports.rb:95:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/clear_forwarded_ports.rb:21:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/clean_machine_folder.rb:17:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/check_guest_additions.rb:33:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/match_mac_address.rb:21:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/import.rb:26:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/vm/check_box.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/warden.rb:30:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action/builder.rb:120:in `call'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action.rb:134:in `block (2 levels) in run'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/util/busy.rb:19:in `busy'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action.rb:134:in `block in run'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/environment.rb:364:in `block in lock'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/environment.rb:354:in `open'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/environment.rb:354:in `lock'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/action.rb:133:in `run'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/vm.rb:140:in `up'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/command/up.rb:13:in `block in execute'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/command/up.rb:8:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/command/up.rb:8:in `execute'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/lib/vagrant/cli.rb:45:in `block in register'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
from /usr/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
from /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/bin/vagrant:26:in `'
from /usr/bin/vagrant:19:in `load'
from /usr/bin/vagrant:19:in `

'
```

to clarify:

```
17:41:44 dieter@Gi ~ ls -alh /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/keys/vagrant
-rw------- 1 root root 1.7K Jan 17 17:26 /usr/lib/ruby/gems/1.9.1/gems/vagrant-0.8.10/keys/vagrant
```

how to fix? why are the permissions so restrictive?