Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(SDK-331) allow additional gems to be installed #178

Merged
merged 1 commit into from
Jul 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/pdk/cli/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,17 @@ def execute!
end

if context == :module
# `bundle install --path` ignores all "system" installed gems and causes unnecessary package installs
# `bundle install` (without --path) installs into GEM_HOME, which by default is non-user writeable
# To still use the pre-installed packages, but allow folks to install additional gems
# we set GEM_HOME to the user's cachedir, and put all other cache locations onto GEM_PATH
# See https://stackoverflow.com/a/11277228 for background
@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'])
@process.environment['GEM_PATH'] = 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'])

# 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 which bundler`, '..', '..', '..', '..'))
@process.environment['GEM_PATH'] = bundler_gem_path
Expand Down