Skip to content

Commit

Permalink
Merge pull request #4068 from NREL/issue_4067
Browse files Browse the repository at this point in the history
Unset ruby envs in openstudio_cli.rb
  • Loading branch information
tijcolem authored Sep 21, 2020
2 parents 063b2ca + c71989c commit 023ff90
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/cli/openstudio_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ def split_main_and_subcommand(argv, command_list)
# parse the main args, those that come before the sub command
def parse_main_args(main_args)

# Unset RUBY ENVs if previously set (e.g. rvm sets these in shell)

ENV.delete('GEM_HOME') if ENV['GEM_HOME']
ENV.delete('GEM_PATH') if ENV['GEM_PATH']
ENV.delete('BUNDLE_GEMFILE') if ENV['BUNDLE_GEMFILE']
ENV.delete('BUNDLE_PATH') if ENV['BUNDLE_PATH']
ENV.delete('BUNDLE_WITHOUT') if ENV['BUNDLE_WITHOUT']

$logger.debug "Parsing main_args #{main_args}"

# verbose already handled
Expand Down Expand Up @@ -361,9 +369,6 @@ def parse_main_args(main_args)
remove_indices.reverse_each {|i| main_args.delete_at(i)}

if !new_path.empty?
if ENV['GEM_PATH']
new_path << ENV['GEM_PATH'].to_s
end

new_path = new_path.join(File::PATH_SEPARATOR)

Expand Down Expand Up @@ -396,11 +401,6 @@ def parse_main_args(main_args)
ENV['BUNDLE_GEMFILE'] = gemfile
use_bundler = true

elsif ENV['BUNDLE_GEMFILE']
# no argument but env var is set
$logger.info "ENV['BUNDLE_GEMFILE'] set to '#{ENV['BUNDLE_GEMFILE']}'"
use_bundler = true

end

if main_args.include? '--bundle_path'
Expand All @@ -413,10 +413,6 @@ def parse_main_args(main_args)
$logger.info "Setting BUNDLE_PATH to #{bundle_path}"
ENV['BUNDLE_PATH'] = bundle_path

elsif ENV['BUNDLE_PATH']
# no argument but env var is set
$logger.info "ENV['BUNDLE_PATH'] set to '#{ENV['BUNDLE_PATH']}'"

elsif use_bundler
# bundle was requested but bundle_path was not provided
$logger.warn "Bundle activated but ENV['BUNDLE_PATH'] is not set"
Expand All @@ -436,10 +432,6 @@ def parse_main_args(main_args)
$logger.info "Setting BUNDLE_WITHOUT to #{bundle_without}"
ENV['BUNDLE_WITHOUT'] = bundle_without

elsif ENV['BUNDLE_WITHOUT']
# no argument but env var is set
$logger.info "ENV['BUNDLE_WITHOUT'] set to '#{ENV['BUNDLE_WITHOUT']}'"

elsif use_bundler
# bundle was requested but bundle_path was not provided
$logger.info "Bundle activated but ENV['BUNDLE_WITHOUT'] is not set"
Expand Down

0 comments on commit 023ff90

Please sign in to comment.