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

Exclude LD_LIBRARY_PATH and PYTHONHOME when invoking subprocesses #1565

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ RSpec/Focus:

RSpec/MultipleExpectations:
Enabled: false

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInHashLiteral:
edmorley marked this conversation as resolved.
Show resolved Hide resolved
EnforcedStyleForMultiline: consistent_comma
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Excluded `LD_LIBRARY_PATH` and `PYTHONHOME` app config vars when invoking subprocesses during the build. ([#1565](https://github.com/heroku/heroku-buildpack-python/pull/1565))

## [v248] - 2024-04-09

Expand Down
15 changes: 14 additions & 1 deletion spec/hatchet/django_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

require_relative '../spec_helper'

# Tests that broken user-provided env vars don't take precedence over those set by this buildpack
# and break running Python. This is particularly important when using shared builds of Python,
# since they rely upon `LD_LIBRARY_PATH` being correct. This list of env vars is based on those
# that used to be set to different values by `bin/release` in very old versions of the buildpack:
# https://github.com/heroku/heroku-buildpack-python/blob/27abdfe7d7ad104dabceb45641415251e965671c/bin/release#L11-L18
BROKEN_CONFIG_VARS = {
LD_LIBRARY_PATH: '/invalid-path',
LIBRARY_PATH: '/invalid-path',
PATH: '/invalid-path',
PYTHONHOME: '/invalid-path',
PYTHONPATH: '/invalid-path',
}.freeze

RSpec.describe 'Django support' do
describe 'collectstatic' do
context 'when building a Django project' do
let(:app) { Hatchet::Runner.new('python-getting-started') }
let(:app) { Hatchet::Runner.new('python-getting-started', config: BROKEN_CONFIG_VARS) }

it 'runs collectstatic' do
app.deploy do |app|
Expand Down
2 changes: 1 addition & 1 deletion spec/hatchet/profile_d_scripts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
'PYTHONHOME=/this-should-be-overridden',
'PYTHONPATH=/this-should-be-preserved',
'PYTHONUNBUFFERED=this-should-be-overridden',
'WEB_CONCURRENCY=this-should-be-preserved'
'WEB_CONCURRENCY=this-should-be-preserved',
]
app.run_multi(list_envs_cmd, heroku: { env: user_env_vars.join(';'), type: 'example-worker' }) do |output, _|
expect(output).to eq(<<~OUTPUT)
Expand Down
2 changes: 1 addition & 1 deletion vendor/buildpack-stdlib_v8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ _env_blacklist() {
if [ -n "$regex" ]; then
regex="|$regex"
fi
echo "^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH$regex)$"
echo "^(PATH|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH|LD_LIBRARY_PATH|PYTHONHOME$regex)$"
}

# Usage: $ export-env ENV_DIR WHITELIST BLACKLIST
Expand Down