Skip to content
This repository has been archived by the owner on Dec 26, 2017. It is now read-only.

Permission denied #237

Closed
heffergm opened this issue Nov 17, 2014 · 23 comments
Closed

Permission denied #237

heffergm opened this issue Nov 17, 2014 · 23 comments

Comments

@heffergm
Copy link

I'm a little mystified by this. I'd been using vagrant-berkshelf 2.x for a while without issue. Having upgraded to 4.0.0, I'm in the following situation:

  • the initial vagrant up proceeds without issue, however if I halt and then restart the box, or try to reprovision it, I get the following error:
Vendoring yum-epel (0.5.1) to /Users/grant/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141117-36310-1or3u6-default/yum-epel

    stderr: /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `initialize': Permission denied @ rb_sysopen - /Users/grant/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141117-36310-1or3u6-default/pelias/.git/objects/02/6d813fd34b114e7deae1eb2c98afed1c1e7f13 (Errno::EACCES)
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `open'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `block in copy_file'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1401:in `open'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1401:in `copy_file'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:483:in `copy_file'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:400:in `block in cp'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1579:in `block in fu_each_src_dest'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1595:in `fu_each_src_dest0'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1577:in `fu_each_src_dest'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/file_syncer.rb:88:in `block in sync'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/file_syncer.rb:71:in `each'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/file_syncer.rb:71:in `sync'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:617:in `block in vendor'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/tmpdir.rb:88:in `mktmpdir'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:577:in `vendor'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:387:in `vendor'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:52:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:27:in `execute!'
    from /opt/chefdk/embedded/apps/berkshelf/bin/berks:5:in `<top (required)>'
    from /opt/chefdk/bin/berks:38:in `load'
    from /opt/chefdk/bin/berks:38:in `<main>'

If I rm -rf /Users/grant/.berkshelf/vagrant-berkshelf, I can run successfully, but again, subsequent attempts will fail.

Any idea what's going on? No commands are being run with sudo or as different users, etc. The perms on the files that I get the access error for are 444, owner/group as I'd expect.

... and it would appear that a chmod -R 755 ~/.berkshelf/vagrant-berkshelf/ resolves the problem.

@sethvargo
Copy link
Contributor

What's your umask?

@heffergm
Copy link
Author

~$ umask
0022

@sethvargo
Copy link
Contributor

Hrm.... This is definitely a permissions issue between the VM and the host, but I'm not really sure why.

@heffergm
Copy link
Author

So the local env is homebrew/rbenv, and I've gotten around chefdk and local gems conflicts by putting /opt/chefdk/bin first in my path, but otherwise nothing springs to mind.

@joelhandwell
Copy link

Recently I updated ChefDK from 0.2 to 0.3.5. and also getting similar error.
I'm running with ChefDK 0.3.5 with vagrant-berkshelf 4.0.0. both on Fedora 20 and Windows 7.
as @heffergm says, after I run chmod -R 755 ~/.berkshelf/vagrant-berkshelf/, I can run vagrant provision --provision-with chef_solo successfully, but after running, if I do vagrant provision --provision-with chef_solo again without chmod -R 755 ~/.berkshelf/vagrant-berkshelf/, I'm getting same error.
I got same error as @heffergm got in Windows 7.
Following is the error I got in fedora, (It's similar but the error says I'm not using ChefDK, though I have installed it with)

[Joel@fedora-vagrant]$ vagrant provision --provision-with chef_solo
==> default: Loading Berkshelf datafile...
...
Vendoring yum-mysql-community (0.1.10) to /home/Joel/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141117-22625-1d34b0l-default/yum-mysql-community

    stderr: /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `initialize': Permission denied @ rb_sysopen - /home/Joel/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141117-22625-1d34b0l-default/uv_apache/.git/objects/01/8f5ba47c1fee9601a966e2a42a56ac755019fa (Errno::EACCES)
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `open'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `block in copy_file'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1401:in `open'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1401:in `copy_file'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:483:in `copy_file'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:400:in `block in cp'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1579:in `block in fu_each_src_dest'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1595:in `fu_each_src_dest0'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1577:in `fu_each_src_dest'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/file_syncer.rb:88:in `block in sync'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/file_syncer.rb:71:in `each'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/file_syncer.rb:71:in `sync'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:617:in `block in vendor'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/tmpdir.rb:88:in `mktmpdir'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:577:in `vendor'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:387:in `vendor'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:52:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:27:in `execute!'
    from /opt/chefdk/embedded/apps/berkshelf/bin/berks:5:in `<top (required)>'
    from /usr/bin/berks:38:in `load'
    from /usr/bin/berks:38:in `<main>'


It appears that you are not using the ChefDK. Please note that Vagrant Berkshelf
works best when used with the ChefDK, and other installation methods are not
officially supported.

Please download and install the latest version of the ChefDK from:

    https://downloads.getchef.com/chef-dk

and follow the installation instructions. Do not forget to add the ChefDK to
your PATH.

@sethvargo
Copy link
Contributor

I see .git in both those stack traces. It's unclear to me why there's a .git directory in there...

@heffergm
Copy link
Author

My project is here if you'd care to give it a look: https://github.com/pelias/vagrant

I'm also using ChefDK 0.3.5 and vagrant-berkshelf 4.0.0.

@joelhandwell
Copy link

the cookbook uv_apache is a wrapper cookbook of apache2 community cookbook. In Berksfile, the wrapper cookbook is seen like this "uv_apache", path: 'cookbooks/uv_apache'. And this cookbook is managed by git in Vagrant shared folder.

@heffergm
Copy link
Author

I went ahead an moved some things, namely nesting the actually cookbook under cookbooks/ rather than having it in the top level, and things work now. I gather the contents of .git was being pulled in by berkshelf and the resultant permissions on those files were not as expected.

@ericcitaire
Copy link

Quick workaround in /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb, add '.git' in sync exclusion :

FileSyncer.sync(scratch, destination, exclude: ['**/metadata.rb', '.git'])

@sethvargo
Copy link
Contributor

This is fixed in Berkshelf as of berkshelf/berkshelf#1342 and will be fixed when a new version of Berkshelf + ChefDK are released.

@brk3
Copy link

brk3 commented Dec 2, 2014

In case it helps anyone, the above workaround didn't work for me, needed:

FileSyncer.sync(scratch, destination, exclude: ['**/metadata.rb', '**/.git'])

@franklinwise
Copy link

This is not an edge case. When can we see a new release of Berkshelf + ChefDK?

@sethvargo
Copy link
Contributor

@franklinwise unfortunately we have no control over the release cycles of ChefDK. Berkshelf is already out and updated.

@franklinwise
Copy link

@sethvargo - understand, thanks

@gionn
Copy link

gionn commented Feb 4, 2015

new Chef-DK 0.4.0 is out but this fix isn't included, isn't it?

@quietcat
Copy link

quietcat commented Feb 4, 2015

It seems to happen when there are git repos in cookbook subfolders. Building on @ericcitaire and @brk3 comments I changed '.git' to '**/.git' in EXCLUDED_VCS_FILES_WHEN_VENDORING = ['.arch-ids', '{arch}', '.bzr', '.bzrignore', '.bzrtags', 'CVS', '.cvsignore', '_darcs', '.git', '.hg', '.hgignore', '.hgrags', 'RCS', 'SCCS', '.svn'].freeze line in /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb

@josacar
Copy link

josacar commented Feb 8, 2015

Same happens to me after upgrading to chefdk 0.4.0

@joaocunha
Copy link

Had the same issue after restarting the computer. The workaround was:

vagrant destroy --force
rm -rf ~/.berkshelf
#@quietcat's change in berksfile.rb
vagrant up

Worth mentioning my vagrant up build was failing due to network errors, so a VPN played a big role.

I wonder if it has to do with restarting without vagrant halt'ing?

@acorncom
Copy link

joelhandwell's script referenced above works for me.

I'm using chefdk 0.4.0, Vagrant 1.7.2 and vagrant-berkshelf 4.0.3

@levmichael3
Copy link

@joaocunha and @quietcat it worked for me as well, thanks!
Instead of deleteing the berkshelf shelf each time and run provision making the '**/.git' change made the trick.

ERROR was about the 'sendmail' community cookbook:

stderr: /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `initialize': Permission denied @ rb_sysopen - /home/****/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150217-4295-1fixznz-default/sendmail/.git/objects/21/ffa1b33b817de42e4f2b20adf69c801594b217 (Errno::EACCES)

@chicobico
Copy link

Thx for the quick fix.
With '**/.git' it works.

@mrjcleaver
Copy link

+1 for @quietcat 's #237 (comment) working

@berkshelf berkshelf locked and limited conversation to collaborators Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests