From bb7c7293951e4bf7a9b616e10f889f1016d0cd05 Mon Sep 17 00:00:00 2001 From: Jesse Scott Date: Fri, 14 Jul 2017 11:31:33 -0700 Subject: [PATCH] (FIXUP) Resolve conflation of cachedir concepts --- lib/pdk/cli/exec.rb | 9 ++++++--- lib/pdk/util.rb | 9 ++++++--- lib/pdk/util/bundler.rb | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/pdk/cli/exec.rb b/lib/pdk/cli/exec.rb index 65813255c..73273b7a8 100644 --- a/lib/pdk/cli/exec.rb +++ b/lib/pdk/cli/exec.rb @@ -104,10 +104,13 @@ def execute! end if context == :module - # Subprocesses use their own set of gems which are managed by pdk or installed with the package. - @process.environment['GEM_HOME'] = File.join(PDK::Util.cachedir, 'ruby', RbConfig::CONFIG['ruby_version']) + if PDK::Util.package_install? + # Subprocesses use their own set of gems which are managed by pdk or installed with the package. + @process.environment['GEM_HOME'] = File.join(PDK::Util.package_cachedir, 'ruby', RbConfig::CONFIG['ruby_version']) + else + # Subprocesses use their own set of gems which are managed by pdk or installed with the package. + @process.environment['GEM_HOME'] = File.join(PDK::Util.cachedir, 'ruby', RbConfig::CONFIG['ruby_version']) - if PDK::Util.gem_install? # This allows the subprocess to find the 'bundler' gem, which isn't in the cachedir above for gem installs. # bundler_gem_path = File.absolute_path(File.join(Gem.loaded_specs['bundler'].gem_dir, '..', '..', '..', '..', '..')) bundler_gem_path = File.absolute_path(File.join(`bundle show bundler`, '..', '..')) diff --git a/lib/pdk/util.rb b/lib/pdk/util.rb index 886f7d368..419e8f0e1 100644 --- a/lib/pdk/util.rb +++ b/lib/pdk/util.rb @@ -70,13 +70,16 @@ def pdk_package_basedir end module_function :pdk_package_basedir + def package_cachedir + File.join(pdk_package_basedir, 'share', 'cache') + end + module_function :package_cachedir + # Returns the fully qualified path to a per-user PDK cachedir. # # @return [String] Fully qualified path to per-user PDK cachedir. def cachedir - if package_install? - File.join(pdk_package_basedir, 'share', 'cache') - elsif Gem.win_platform? + if Gem.win_platform? File.join(ENV['LOCALAPPDATA'], 'PDK', 'cache') else File.join(Dir.home, '.pdk', 'cache') diff --git a/lib/pdk/util/bundler.rb b/lib/pdk/util/bundler.rb index f0f2f44c2..827ac624c 100644 --- a/lib/pdk/util/bundler.rb +++ b/lib/pdk/util/bundler.rb @@ -146,7 +146,7 @@ def gemfile_lock end def bundle_cachedir - @bundle_cachedir ||= File.join(PDK::Util.cachedir) + @bundle_cachedir ||= PDK::Util.package_install? ? PDK::Util.package_cachedir : File.join(PDK::Util.cachedir) end end end