OPERATING_SYSTEM_DEFAULTS are clobbered by ~/.gemrc

Open
#698 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
ruby
Domain
cli, tooling

Research direction

Start with omnibus/files/rubygems-customization/default/operating_system.rb at the OPERATING_SYSTEM_DEFAULTS assignments, then reproduce the ~/.gemrc case using the provided gem install command. Compare this behavior with the GEM_* variables from chef shell-init. Done means custom ~/.gemrc settings no longer clobber ChefDK's intended user-install behavior.

Written by the indexing model from the issue text.

Description

Aspect: Integration Aspect: UX Triage: Confirmed Type: Bug

Description

Users with custom ~/.gemrc files may clobber the flags set in OPERATING_SYSTEM_DEFAULTS.

In operating_system.rb:6 there are the following two lines:

# Always install and update new gems in "user install mode"
Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["install"] = "--user --no-document"
Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["update"] = "--user --no-document"

This behavior breaks using ChefDK as a plugin to things like rbenv-chefdk and other Ruby switchers.

To see how hard this is debug, look at the efforts I had to go through on docwhat/rbenv-chefdk#3

ChefDK Version

Chef Development Kit Version: 0.15.16
chef-client version: 12.11.18
delivery version: master (444effdf9c81908795e88157f01cd667a6c43b5f)
berks version: 4.3.5
kitchen version: 1.10.0

Platform Version

Any. But I'm testing on OS X

Replication Case

Create a ~/.gemrc file with these lines:

install: --no-document
update:  --no-document

And then, in a shell that has not run chef shell-init run:

% /opt/chefdk/embedded/bin/gem install awesome_print
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.

An easy way to reproduce this setup is to clone this gist and run ./fakehome.sh

Proposed solution

Remove the OPERATING_SYSTEM_DEFAULTS lines and instead add in the GEM_* environment variables from chef shell-init. Leave the user_dir alone, since it is useful.

Dominant language
Go
Stars
156
Forks
116
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from chef/chef-workstation

All issues in chef/chef-workstation

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.