heroku / heroku-geo-buildpack

37 stars 2 forks source link

Set {GDAL,GEOS,PROJ4}_LIBRARY_PATH in export too #15

Closed edmorley closed 3 years ago

edmorley commented 4 years ago

Currently the various library PATH env vars are only set at runtime: https://github.com/heroku/heroku-geo-buildpack/blob/333a3f8863774f56a74cb9d955e0df840870a81f/bin/compile#L78-L80

This means if they are required during eg a command run in a Python buildpack post_compile hook, they won't be found. There may be some users relying on this, since they were set for the legacy Python buildpack feature: https://github.com/heroku/heroku-buildpack-python/blob/41f657fbff4dd90efa7705737bc6fee4fba05dba/bin/steps/geo-libs#L52-L57

To resolve this they would need to be added here: https://github.com/heroku/heroku-geo-buildpack/blob/333a3f8863774f56a74cb9d955e0df840870a81f/bin/compile#L64-L70

ideallical commented 3 years ago

I wonder if this is related to my recent Django deploy issue I have on Heroku. I always had these setting in my Django settings file:

GDAL_LIBRARY_PATH = env.str(
    "GDAL_LIBRARY_PATH", default="/app/.heroku/vendor/lib/libgdal.so"
)
GEOS_LIBRARY_PATH = env.str(
    "GEOS_LIBRARY_PATH", default="/app/.heroku/vendor/lib/libgeos_c.so"
)

And as of today I cannot deploy anymore, as I get this error from Heroku:

OSError: /app/.heroku/vendor/lib/libgdal.so: cannot open shared object file: No such file or directory

I tried changing it to the folder names I found in this ticket:

$HOME/.heroku-geo-buildpack/vendor/lib/libgdal.so

but then still get the same error with the new path.

However, when I login with bash, I can confirm that $HOME/.heroku-geo-buildpack/vendor/lib/libgdal.so exists.

edmorley commented 3 years ago

@ideallical Hi :-) Yeah this looks to be related.

The /app/.heroku/vendor/lib/... paths that you use as default values are the old paths used by the legacy Python buildpack feature, so won't work now.

I tried changing it to the folder names I found in this ticket: $HOME/.heroku-geo-buildpack/vendor/lib/libgdal.so

Ah so at build time, the build is run from /tmp/build_*/ and unhelpfully HOME is /app at that point, so the path will be wrong. When you later heroku run bash, the code is at /app so the path will work.

I'll open a PR to fix the env vars not being set at build time.

Though note after #17 fixed #16 the auto-detection may even be enough -- you may not even need to set those paths in Django settings any more.

ideallical commented 3 years ago

Hi @edmorley , thanks for the fast reply.

You're right, after I removed the Django settings (GDAL_LIBRARY_PATH & GDAL_LIBRARY_PATH), the deploy worked again 👍 thank you!

edmorley commented 3 years ago

@ideallical Great! Thank you for confirming :-)