Skip to content

Commit

Permalink
Merge pull request #153 from scotje/fixup_cachedir_usage
Browse files Browse the repository at this point in the history
(FIXUP) Resolve conflation of cachedir concepts
  • Loading branch information
bmjen committed Jul 14, 2017
2 parents 6088f6c + bb7c729 commit f81c94f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 6 additions & 3 deletions lib/pdk/cli/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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`, '..', '..'))
Expand Down
9 changes: 6 additions & 3 deletions lib/pdk/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/util/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f81c94f

Please sign in to comment.