rails-sqlserver / heroku-buildpack-freetds

This is a Heroku buildpack for vendoring the FreeTDS binaries into your project.
MIT License
10 stars 31 forks source link

Escape env vars as expected #21

Closed bf4 closed 1 year ago

bf4 commented 1 year ago

Escape when writing to profile.d/freetds.sh

Two commits by Josh Clayton

https://github.com/thoughtbot/heroku-buildpack-freetds/commit/9de3231b68115d44795479a20ffd822ba8ed227c

What?

This updates the compile script to ensure environment variables exported within profile.d/freetds.sh are escaped properly in the script rather than evaluated when the script is run.

The previous behavior evaluated certain environment variables that were intended to be prepended to, resulting in incorrect values in e.g. LIBRARY_PATH.

https://github.com/thoughtbot/heroku-buildpack-freetds/commit/6dc7f5887c1e399ce83043065cc51d2f7758ea78

Escape $PATH to ensure dynamic evaluation

What?

This updates the compile script to escape '$' when generating the shell file, ensuring that $PATH is determined dynamically by .profile.d/freetds.sh rather than writing a snapshot of the value to disk by evaluating immediately.

Compare to https://github.com/heroku/heroku-buildpack-activestorage-preview/blob/9056773b88c77ff33ff4900f9bb116c41553d5ed/bin/compile

Closes rails-sqlserver#17

bf4 commented 1 year ago

I haven't tested this change myself, but as a shell script reader it looks fine and I think @joshuaclayton is actively using it, so merging and will see if there's any feedback

markiz commented 1 year ago

Hey, I'm not 100% sure, but I suspect this just broke the buildpack

       Unpacking cached files...
/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e/bin/compile: line 113: grep: command not found

I'm investigating further, though, will post if I have updates

markiz commented 1 year ago

Yup, using the previous commit (4c0f6a41263f2e6c781506565effed97c52efaf4) resolved the issue

Reported here: https://github.com/rails-sqlserver/heroku-buildpack-freetds/issues/23

appoks commented 1 year ago

Hey, I'm not 100% sure, but I suspect this just broke the buildpack

       Unpacking cached files...
/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e/bin/compile: line 113: grep: command not found

I'm investigating further, though, will post if I have updates

I'm having the same issue here.