Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot create /usr/local/rvm/gemsets/global.gems: Directory nonexistent #38

Closed
petitbon opened this issue Sep 14, 2011 · 10 comments
Closed
Assignees
Labels
Bug Something isn't working

Comments

@petitbon
Copy link

I just want to install rvm for a user
but I keep getting: cannot create /usr/local/rvm/gemsets/global.gems: Directory nonexistent

is this the right way to install rvm under the user 'hugo' ? thanks

include_recipe "rvm::user"

node['rvm']['user_installs'] = [
  'hugo' => {
    'default_ruby'  => 'ruby-1.9.2-p290', 
    'rubies'        => ['1.9.2'],
    'rvmrc'         => {
      'rvm_project_rvmrc'             => 1,
      'rvm_gemset_create_on_use_flag' => 1,
      'rvm_pretty_print_flag'         => 1
    },

    'global_gems'   => []
  }
]

node['rvm']['user_global_gems'] = [
  { 'name'    => 'bundler',
    'version' => '1.0.17'
  },
  { 'name'    => 'rake',
    'version' => '0.9.2'
  }
]
@ghost ghost assigned fnichol Sep 19, 2011
@fnichol
Copy link
Contributor

fnichol commented Sep 19, 2011

Right off the top of my head that looks correct. Let me do a quick setup with vagrant to reproduce, there could be some deep down system-wide dependency that I didn't squash. What OS are you working with?

@petitbon
Copy link
Author

ubuntu 10.04

@sadowski
Copy link

I'm having this same problem on Ubuntu 11.04.

In the defaults, default['rvm']['root_path'] is set to "/usr/local/rvm". When the update_global_gems_file method is called in the global_gem provider it does not check to see if this directory exists before trying to write into it.

Should we need to manually create that directory ourselves? What is the correct thing to do in this situation?

Here's the chef-client output with stack trace for your convenience:

[Fri, 30 Sep 2011 20:36:11 +0000] INFO: Processing template[/etc/rvmrc] action create (rvm::user_install line 135)
[Fri, 30 Sep 2011 20:36:11 +0000] INFO: template[/etc/rvmrc] backed up to /var/chef/backup/etc/rvmrc.chef-20110930203611
[Fri, 30 Sep 2011 20:36:11 +0000] INFO: template[/etc/rvmrc] mode changed to 644
[Fri, 30 Sep 2011 20:36:11 +0000] INFO: template[/etc/rvmrc] updated content
[Fri, 30 Sep 2011 20:36:11 +0000] INFO: Processing execute[install system-wide RVM] action run (rvm::user_install line 69)
[Fri, 30 Sep 2011 20:36:11 +0000] INFO: Processing execute[upgrade system-wide RVM to none] action run (rvm::user_install line 105)
[Fri, 30 Sep 2011 20:36:11 +0000] INFO: Processing rvm_default_ruby[ruby-1.8.7-p352] action create (rvm::user line 163)
[Fri, 30 Sep 2011 20:36:12 +0000] INFO: Processing rvm_global_gem[bundler] action install (rvm::user line 169)
[Fri, 30 Sep 2011 20:36:12 +0000] INFO: Processing execute[Add bundler to /usr/local/rvm/gemsets/global.gems] action run (/var/chef/cache/cookbooks/rvm/providers/global_gem.rb line 102)
[Fri, 30 Sep 2011 20:36:12 +0000] ERROR: execute[Add bundler to /usr/local/rvm/gemsets/global.gems] (/var/chef/cache/cookbooks/rvm/providers/global_gem.rb line 102) has had an error
[Fri, 30 Sep 2011 20:36:12 +0000] ERROR: rvm_global_gem[bundler] (rvm::user line 169) has had an error
[Fri, 30 Sep 2011 20:36:12 +0000] ERROR: rvm_global_gem[bundler] (/var/chef/cache/cookbooks/rvm/libraries/chef_rvm_recipe_helpers.rb:169:in `install_rubies') had an error:
rvm_global_gem[bundler] (rvm::user line 169) had an error: execute[Add bundler to /usr/local/rvm/gemsets/global.gems] (/var/chef/cache/cookbooks/rvm/providers/global_gem.rb line 102) had an error: Expected process to exit with [0], but received '2'
---- Begin output of echo "bundler" >> "/usr/local/rvm/gemsets/global.gems" ----
STDOUT: 
STDERR: sh: cannot create /usr/local/rvm/gemsets/global.gems: Directory nonexistent
---- End output of echo "bundler" >> "/usr/local/rvm/gemsets/global.gems" ----
Ran echo "bundler" >> "/usr/local/rvm/gemsets/global.gems" returned 2
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/shell_out.rb:207:in `invalid!'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/shell_out.rb:193:in `error!'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/mixin/shell_out.rb:36:in `shell_out!'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/provider/execute.rb:58:in `action_run'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:437:in `send'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:437:in `run_action'
/var/chef/cache/cookbooks/rvm/providers/global_gem.rb:117:in `update_global_gems_file'
/var/chef/cache/cookbooks/rvm/providers/global_gem.rb:30:in `class_from_file'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/provider.rb:104:in `instance_eval'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/provider.rb:104:in `action_install'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:437:in `send'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:437:in `run_action'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/runner.rb:45:in `run_action'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/runner.rb:81:in `converge'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/runner.rb:81:in `each'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/runner.rb:81:in `converge'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource_collection.rb:94
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource_collection.rb:92:in `execute_each_resource'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/runner.rb:76:in `converge'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/client.rb:312:in `converge'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/client.rb:160:in `run'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:239:in `run_application'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in `loop'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in `run_application'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application.rb:67:in `run'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-client:26
/usr/bin/chef-client:19:in `load'
/usr/bin/chef-client:19
[Fri, 30 Sep 2011 20:36:12 +0000] ERROR: Running exception handlers
[Fri, 30 Sep 2011 20:36:12 +0000] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[Fri, 30 Sep 2011 20:36:12 +0000] ERROR: Exception handlers complete
[Fri, 30 Sep 2011 20:36:12 +0000] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[Fri, 30 Sep 2011 20:36:12 +0000] FATAL: Chef::Exceptions::ShellCommandFailed: rvm_global_gem[bundler] (rvm::user line 169) had an error: execute[Add bundler to /usr/local/rvm/gemsets/global.gems] (/var/chef/cache/cookbooks/rvm/providers/global_gem.rb line 102) had an error: Expected process to exit with [0], but received '2'
---- Begin output of echo "bundler" >> "/usr/local/rvm/gemsets/global.gems" ----
STDOUT: 
STDERR: sh: cannot create /usr/local/rvm/gemsets/global.gems: Directory nonexistent
---- End output of echo "bundler" >> "/usr/local/rvm/gemsets/global.gems" ----
Ran echo "bundler" >> "/usr/local/rvm/gemsets/global.gems" returned 2

@sadowski
Copy link

One more quick note: manually creating that directory with
sudo mkdir -p /usr/local/rvm/gemsets
solved the problem.

@sadowski
Copy link

sadowski commented Oct 3, 2011

I created a patch for this issue here: #41

@fnichol
Copy link
Contributor

fnichol commented Oct 5, 2011

Ugh, this is totally a documentation error! @petitbon can you try this tweak:

include_recipe "rvm::user"

node['rvm']['user_installs'] = [
  { 'user' => 'hugo',
    'default_ruby'  => 'ruby-1.9.2-p290', 
    'rubies'        => ['1.9.2'],
    'rvmrc'         => {
      'rvm_project_rvmrc'             => 1,
      'rvm_gemset_create_on_use_flag' => 1,
      'rvm_pretty_print_flag'         => 1
    },

    'global_gems'   => []
  }
]

node['rvm']['user_global_gems'] = [
  { 'name'    => 'bundler',
    'version' => '1.0.17'
  },
  { 'name'    => 'rake',
    'version' => '0.9.2'
  }
]

I had intended node['rvm']['user_installs'] to be an array of hashes (each hash representing a user install), but it looks like the README gives this Array/Hash hybrid in the example usage.

@sadowski, it looks like when following the (incorrect) README formated metadata gets used the user isn't found in recipe[user] so the installation is half reverted back to a system-wide install (hence the error about requiring a system-wide directory). If you're able to test your Vagrantfile/metadata to confirm I should be able to close off your pull request.

Apologies to all!

@sadowski
Copy link

sadowski commented Oct 6, 2011

I agree that a user install shouldn't need to create any system directories, so feel free to close off my pull request.

However, I don't think it should try to do a system-wide install if a user install is requested. It's probably better to just fail gracefully at that point. Maybe check the required parameters of the node['rvm']['user_installs'] before starting and raise an error if it looks wrong?

Thanks!

@fnichol
Copy link
Contributor

fnichol commented Oct 6, 2011

@sadowski I totally agree about the unnecessary system-wide install. The default behavior of all the LWRPs is to assume system-wide when a user attribute is not passed in. When the (improperly formatted) metadata hash was being parsed, no user key was found leading to a blank attribute value for user in the rvm_environment LWRP. This could be something I could guard against in the user/user_install recipes, but you're correct: the user installs should never touch files and directories outside a user's home directory. That way you could run user recipes as a non-root user (I do this to setup my mac workstations)

@fnichol
Copy link
Contributor

fnichol commented Oct 15, 2011

I think we've beat this one into submissions, thanks to all for your feedback.

@fnichol fnichol closed this as completed Oct 15, 2011
phlipper pushed a commit to newleaders/chef-rvm that referenced this issue Feb 1, 2012
@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants