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

run as a normal user, chef gem install should install gems to a writable location #11

Closed
jtimberman opened this issue Apr 15, 2014 · 11 comments
Labels
Type: Enhancement Adds new functionality.
Milestone

Comments

@jtimberman
Copy link
Contributor

It would be nice if, as a normal user, I could install gems for Chef without requiring root access. This is of course supported by RubyGems itself, but apparently not with chef gem.

Attempting to install a "Chef Gem" requires root access because it attempts to write to /opt.

% chef gem install knife-ec2
Fetching: formatador-0.2.4.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.

Setting $GEM_HOME doesn't help, unfortunately.

% GEM_HOME=/Users/jtimberman/.gem/ruby/2.1.0 chef gem install knife-ec2
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.

My Chef Gem Environment:

% chef gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.1
  - RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [x86_64-darwin13.0]
  - INSTALLATION DIRECTORY: /opt/chefdk/embedded/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /opt/chefdk/embedded/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/chefdk/embedded/bin
  - SPEC CACHE DIRECTORY: /Users/jtimberman/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-13
  - GEM PATHS:
     - /opt/chefdk/embedded/lib/ruby/gems/2.1.0
     - /Users/jtimberman/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://rubygems.org/"]
     - "gem" => "--no-rdoc --no-ri"
     - :benchmark => false
  - REMOTE SOURCES:
     - http://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/local/sbin
     - /bin
     - /sbin
     - /usr/bin
     - /usr/sbin
     - /usr/X11R6/bin
     - /Users/jtimberman/bin
@glensc
Copy link

glensc commented Apr 16, 2014

each bin wrappers have this code:

ENV["GEM_HOME"] = ENV["GEM_PATH"] = nil unless ENV["APPBUNDLER_ALLOW_RVM"] == "true"

so it may help to set APPBUNDLER_ALLOW_RVM=true and then override $GEM_HOME

@glensc
Copy link

glensc commented Apr 16, 2014

and the above seems to be related to appbundler: https://github.com/opscode/appbundler#rvm

@danielsdeleo
Copy link
Contributor

Yeah, the binaries need to be rvm resistant, and APPBUNDLER_ALLOW_RVM=true is just a hack we use for travis (which uses rvm). But this should be pretty easy to do. Probably best to put user-installed gems in your home directory somewhere.

@schisamo
Copy link
Contributor

We should consider writing gems to something like ~/.chefdk.d/gems. This is similar to how Vagrant works:

➜  ls -la ~/.vagrant.d/gems/
total 0
drwxr-xr-x   8 schisamo  staff  272 Mar 11 13:55 .
drwxr-xr-x  12 schisamo  staff  408 Apr 22 14:06 ..
drwxr-xr-x   7 schisamo  staff  238 Mar 17 06:39 build_info
drwxr-xr-x   7 schisamo  staff  238 Mar 17 06:39 cache
drwxr-xr-x   2 schisamo  staff   68 Mar 11 13:55 doc
drwxr-xr-x   7 schisamo  staff  238 Mar 17 06:39 gems
drwxr-xr-x   3 schisamo  staff  102 Mar 11 13:53 ruby
drwxr-xr-x   7 schisamo  staff  238 Mar 17 06:39 specifications

A ~/.chefdk.d directory would also give us a staging area for other required directories/assets.

@danielsdeleo
Copy link
Contributor

@schisamo working on that right now

@schisamo
Copy link
Contributor

@danielsdeleo

@smith
Copy link
Contributor

smith commented Apr 22, 2014

Would it make sense to just use ~/.chef/gems?

@danielsdeleo
Copy link
Contributor

Merged a fix to omnibus-chef: chef-boneyard/omnibus-chef@af1f058 This will be fixed in the next chefdk release.

@jtimberman
Copy link
Contributor Author

@danielsdeleo - ❤️

@danielsdeleo danielsdeleo added this to the 0.1.0 milestone Apr 29, 2014
@aalmenar
Copy link

This exactly happens again in version 0.8.0 on OSX El Capitan

@tonytonyjan
Copy link
Contributor

I occurred the same problem when use kitchen, it tries to write /opt/chefdk/embedded/lib/ruby/gems/2.1.0 instead of .chefdk/gem/ruby/2.1.0.

$ kitchen init
   identical  .kitchen.yml
   identical  chefignore
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.

My environment:

$ sw_vers -productVersion
10.11.2
$ chef gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.8
  - RUBY VERSION: 2.1.6 (2015-04-13 patchlevel 336) [x86_64-darwin12.0]
  - INSTALLATION DIRECTORY: /opt/chefdk/embedded/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /opt/chefdk/embedded/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/chefdk/embedded/bin
  - SPEC CACHE DIRECTORY: /Users/tonytonyjan/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /opt/chefdk/embedded/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /opt/chefdk/embedded/lib/ruby/gems/2.1.0
     - /Users/tonytonyjan/.chefdk/gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "-N"
     - "update" => "-N"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/tonytonyjan/.pyenv/shims
     - /Users/tonytonyjan/.rbenv/shims
     - /Users/tonytonyjan/.pyenv/shims
     - /Users/tonytonyjan/.rbenv/shims
     - /Users/tonytonyjan/bin
     - /Users/tonytonyjan/.pyenv/shims
     - /Users/tonytonyjan/.rbenv/shims
     - /usr/local/sbin
     - ./node_modules/.bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin
     - /usr/texbin

@thommay thommay added Type: Enhancement Adds new functionality. and removed Enhancement labels Feb 1, 2017
@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
Type: Enhancement Adds new functionality.
Development

No branches or pull requests

8 participants