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
Replace deprecated Bundler.with_clean_env
with with_unbundled_env
#2120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,11 +297,9 @@ def prune_bundler | |
deps, dirs = dependencies_and_files_to_require_after_prune | ||
|
||
log '* Pruning Bundler environment' | ||
home = ENV['GEM_HOME'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought original_env only looked at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any test for this? Or can we write it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #653 looks like no test exists There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try to implement tests for this, but if somebody can help me — I appreciate it, I'm not too familiar with Puma sources and environments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also there are no tests for #1893. And I've found I've added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I've found There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You won't see that output because the Puma tests create new processes whose output is not piped to STDOUT. Take a look at the helpers/integration test code for more info. The test for #1893 is here: https://github.com/puma/puma/pull/1893/files#diff-1a1a7e313ee72a0ca0e8eb22a2524879 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I've found Current results:
I'll try to add correct test for |
||
bundle_gemfile = ENV['BUNDLE_GEMFILE'] | ||
Bundler.with_clean_env do | ||
ENV['GEM_HOME'] = home | ||
ENV['BUNDLE_GEMFILE'] = bundle_gemfile | ||
gem_home = ENV['GEM_HOME'] | ||
Bundler.with_unbundled_env do | ||
ENV['GEM_HOME'] = gem_home | ||
ENV['PUMA_BUNDLER_PRUNED'] = '1' | ||
args = [Gem.ruby, puma_wild_location, '-I', dirs.join(':'), deps.join(',')] + @original_argv | ||
# Ruby 2.0+ defaults to true which breaks socket activation | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
run lambda { |env| [200, {'Content-Type'=>'text/plain'}, [ENV['BUNDLE_GEMFILE'].inspect]] } | ||
run( | ||
lambda do |env| | ||
[ | ||
200, | ||
{'Content-Type'=>'text/plain'}, | ||
[ | ||
[ENV['BUNDLE_GEMFILE'], ENV['GEM_HOME']].inspect | ||
] | ||
] | ||
end | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,12 @@ def test_usr2_restart_preserves_bundler_environment | |
skip_unless_signal_exist? :USR2 | ||
|
||
@tcp_port = UniquePort.call | ||
gem_home = "/home/bundle_env_preservation_test" | ||
bundle_gemfile = "Gemfile.bundle_env_preservation_test" | ||
env = { | ||
"GEM_HOME" => gem_home, | ||
# Intentionally set this to something we wish to keep intact on restarts | ||
"BUNDLE_GEMFILE" => "Gemfile.bundle_env_preservation_test", | ||
"BUNDLE_GEMFILE" => bundle_gemfile, | ||
# Don't allow our (rake test's) original env to interfere with the child process | ||
"BUNDLER_ORIG_BUNDLE_GEMFILE" => nil | ||
} | ||
|
@@ -27,9 +30,11 @@ def test_usr2_restart_preserves_bundler_environment | |
@pid = @server.pid | ||
connection = connect | ||
initial_reply = read_body(connection) | ||
assert_match("Gemfile.bundle_env_preservation_test", initial_reply) | ||
refute_match(bundle_gemfile, initial_reply) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the situation as I understand it:
If there is a way to have both the value preservation of #1893, but without the full path sharing detailed in #2133, then we'd like to have both. Whew! I hope that makes sense. |
||
assert_match(gem_home, initial_reply) | ||
restart_server connection | ||
new_reply = read_body(connection) | ||
assert_match("Gemfile.bundle_env_preservation_test", new_reply) | ||
refute_match(bundle_gemfile, new_reply) | ||
assert_match(gem_home, initial_reply) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your PR fails on Ruby 2.2 because you're install Bundler 2 on Ruby 2.2. Instead, you need to change the Github action so that you're running
gem install bundler -v 1.17.3
when running Ruby 2.2.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 2.2 Rubies have Bundler 1.7.3 installed already. See the 2.2 jobs at:
https://github.com/ruby/setup-ruby/runs/491284436