From 9fbe00f1fa477ff0607c2c203c70052732e06a07 Mon Sep 17 00:00:00 2001 From: Serdar Sutay Date: Thu, 4 Sep 2014 18:47:55 +0300 Subject: [PATCH] Merge pull request #229 from opscode/sersut/rubygems-cust-fix Preserve the old style rubygems customization for non-windows platforms. --- config/software/rubygems-customization.rb | 7 ++++-- .../default/operating_system.rb | 22 +++++++++++++++++++ .../{ => windows}/operating_system.rb | 0 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 files/rubygems_customization/default/operating_system.rb rename files/rubygems_customization/{ => windows}/operating_system.rb (100%) diff --git a/config/software/rubygems-customization.rb b/config/software/rubygems-customization.rb index 941423dd3..c9883e585 100644 --- a/config/software/rubygems-customization.rb +++ b/config/software/rubygems-customization.rb @@ -44,7 +44,11 @@ sitelibdir_cmd.gsub!('/', '\\') if platform == "windows" block do - source_customization_file = File.join(project.files_path, "rubygems_customization", "operating_system.rb") + source_customization_file = if platform == 'windows' + File.join(project.files_path, "rubygems_customization", "windows", "operating_system.rb") + else + File.join(project.files_path, "rubygems_customization", "default", "operating_system.rb") + end embedded_ruby_site_dir = "" Bundler.with_clean_env do embedded_ruby_site_dir = %x{#{sitelibdir_cmd}}.strip @@ -64,4 +68,3 @@ FileUtils.cp source_customization_file, destination end end - diff --git a/files/rubygems_customization/default/operating_system.rb b/files/rubygems_customization/default/operating_system.rb new file mode 100644 index 000000000..d2fd4b5c0 --- /dev/null +++ b/files/rubygems_customization/default/operating_system.rb @@ -0,0 +1,22 @@ +## Rubygems Customization ## +# Customize rubygems install behavior and locations to keep user gems isolated +# from the stuff we bundle with omnibus and any other ruby installations on the +# system. + +# Always install and update new gems in "user install mode" +Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["install"] = "--user" +Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["update"] = "--user" + +module Gem + + ## + # Override user_dir to live inside of ~/.chefdk + + def self.user_dir + parts = [Gem.user_home, '.chefdk', 'gem', ruby_engine] + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + File.join parts + end + +end + diff --git a/files/rubygems_customization/operating_system.rb b/files/rubygems_customization/windows/operating_system.rb similarity index 100% rename from files/rubygems_customization/operating_system.rb rename to files/rubygems_customization/windows/operating_system.rb