Skip to content
This repository was archived by the owner on Jul 14, 2021. It is now read-only.

Unable to run kitchen init #20

Closed
webmonkey opened this issue Apr 22, 2014 · 8 comments · Fixed by test-kitchen/test-kitchen#416
Closed

Unable to run kitchen init #20

webmonkey opened this issue Apr 22, 2014 · 8 comments · Fixed by test-kitchen/test-kitchen#416
Milestone

Comments

@webmonkey
Copy link

I had already run sudo chef gem install kitchen-vagrant and have seen #15 which could be related.

edit: I'm using Ubuntu 12.04 if that's at all relevant

At first it looked to be using the default OS installed gem command

james.c@jc-hp-laptop:~/Projects/dummy-app$ kitchen init
      create  .kitchen.yml
      create  test/integration/default
         run  gem install kitchen-vagrant from "."
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /var/lib/gems/1.9.1

I modified the path to force the chefdk packaged gem

james.c@jc-hp-laptop:~/Projects/dummy-app$ export PATH=/opt/chefdk/embed
ded/bin:$PATH
james.c@jc-hp-laptop:~/Projects/dummy-app$ kitchen init
   identical  .kitchen.yml
         run  gem install kitchen-vagrant from "."
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.

It still errors but I don't figure why it's trying to re-install when the package is installed already.

james.c@jc-hp-laptop:~/Projects/dummy-app$ chef gem list kitchen-vagrant

*** LOCAL GEMS ***

kitchen-vagrant (0.14.0)

james.c@jc-hp-laptop:~/Projects/dummy-app$ gem list kitchen-vagrant

*** LOCAL GEMS ***

kitchen-vagrant (0.14.0)
@webmonkey
Copy link
Author

workaround: touch Gemfile before running the kitchen init

@sethvargo
Copy link

Why are you running with sudo?

@webmonkey
Copy link
Author

Because my user had no privilege to write to /var/lib/ruby

The problem exhibited itself the same with a non sudo execution with
--user-install

@sethvargo
Copy link

@webmonkey you shouldn't need sudo to run ChefDK - that's one of the purposes. You should just run... You are using the system ruby at that point, which is why you have permission issues.

@danielsdeleo
Copy link
Contributor

@sethvargo we're gonna have to work out something with kitchen to make it either skip the driver install or use a custom command instead of gem to do the install, and also fix #11 for this to work. You have any pointers on how to best fix the TK side of things?

@webmonkey
Copy link
Author

Thanks Seth, I'm very much a newcomer to this.

Following an uninstall of the gem I'm still able to replicate the issue.

james.c@jc-hp-laptop:~$ sudo chef gem uninstall kitchen-vagrant
[sudo] password for james.c: 
Successfully uninstalled kitchen-vagrant-0.14.0
james.c@jc-hp-laptop:~$ chef gem list kitchen-vagrant

*** LOCAL GEMS ***


james.c@jc-hp-laptop:~$ sudo chef gem list kitchen-vagrant

*** LOCAL GEMS ***


james.c@jc-hp-laptop:~$ mkdir -p /tmp/foo
james.c@jc-hp-laptop:~$ cd /tmp/foo/
james.c@jc-hp-laptop:/tmp/foo$ kitchen init
      create  .kitchen.yml
      create  test/integration/default
         run  gem install kitchen-vagrant from "."
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /var/lib/gems/1.9.1
james.c@jc-hp-laptop:/tmp/foo$ touch Gemfile
james.c@jc-hp-laptop:/tmp/foo$ kitchen init
   identical  .kitchen.yml
      append  Gemfile
      append  Gemfile
You must run `bundle install' to fetch any new gems.
james.c@jc-hp-laptop:/tmp/foo$ kitchen list
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ClientError
>>>>>> Message: Could not load the 'vagrant' driver from the load path. Please ensure that your driver is installed as a gem or included in your Gemfile if using Bundler.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

james.c@jc-hp-laptop:/tmp/foo$ chef gem install kitchen-vagrant
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.
james.c@jc-hp-laptop:/tmp/foo$ chef gem install kitchen-vagrant --user-install
WARNING:  You don't have /home/james.c/.gem/ruby/2.1.0/bin in your PATH,
      gem executables will not run.
Successfully installed kitchen-vagrant-0.14.0
Parsing documentation for kitchen-vagrant-0.14.0
Installing ri documentation for kitchen-vagrant-0.14.0
Done installing documentation for kitchen-vagrant after 0 seconds
1 gem installed

@sethvargo
Copy link

Well, that definitely seems like a bug... @danielsdeleo I was able to reproduce. I don't think I should need to use sudo to install gems?

$ chef gem install kitchen-vagrant
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/installer.rb:620:in `verify_gem_home'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/installer.rb:740:in `pre_install_checks'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/installer.rb:213:in `install'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/request_set.rb:136:in `block in install'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/request_set.rb:120:in `each'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/request_set.rb:120:in `install'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/dependency_installer.rb:389:in `install'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:219:in `install_gem'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:263:in `block in install_gems'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:259:in `each'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:259:in `install_gems'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:171:in `execute'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/command.rb:305:in `invoke_with_build_args'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/command_manager.rb:167:in `process_args'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/command_manager.rb:137:in `run'
    /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:54:in `run'
    /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/command/gem.rb:32:in `run'
    /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/command/base.rb:57:in `run_with_default_options'
    /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/cli.rb:83:in `run_subcommands'
    /opt/chefdk/embedded/apps/chef-dk/lib/chef-dk/cli.rb:56:in `run'
    /opt/chefdk/embedded/apps/chef-dk/bin/chef:25:in `<top (required)>'
    /usr/bin/chef:31:in `load'
    /usr/bin/chef:31:in `<main>'

@danielsdeleo
Copy link
Contributor

@sethvargo right, see #11 for the gem permissions issue. The second problem is that ChefDK's gem has to be the first one on your PATH or else kitchen will try to install the driver gem using the wrong gem/ruby combo.

@danielsdeleo danielsdeleo added this to the 0.1.0 milestone Apr 29, 2014
@chef-boneyard chef-boneyard locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants