I'm using heroku to develop a django backend. I would like to enable geoDjango to use spatial feature with my models. I followed all the steps that are describe on the django and heroku docs but I'm still getting an error when I want to run manage.py migrate or other request and command on the server:
OSError: /app/.heroku/vendor/lib: cannot open shared object file: No such file or directory
I did check with bash if it was true and yes there no lib directory in my vendor. I don't know a lot about buildpacks and config on heroku so I don't know where to start to fix this error. Here is my buildspack:
And in my .buildpacks I tried to put:
https://github.com/cyberdelia/heroku-geo-buildpack.git#e1b845b
https://github.com/heroku/heroku-buildpack-python.git
I also tried different forks that were not able to build at all...
I did put the paths in my settings:
GEOS_LIBRARY_PATH = os.environ.get('GEOS_LIBRARY_PATH')
GDAL_LIBRARY_PATH = os.environ.get('GDAL_LIBRARY_PATH')
I'm a bit lost so help would be greatly appreciated
EDIT: So I tried to downgrade my stack to heroku-16 (it was heroku-18) and it build but when I want to migrate it show me a new error message:
OSError: /app/.heroku/vendor/lib: cannot read file data: Is a directory
And when I try to follow this tutorial I can't even build and get this:
-----> geos/gdal/proj app detected
Using geos version: <?xml version="1.0" encoding="UTF-8"?>
Using gdal version: <?xml version="1.0" encoding="UTF-8"?>
Using proj version: <?xml version="1.0" encoding="UTF-8"?>
/app/tmp/buildpacks/3174f4234c5151450fcaba5f50a050126498959c8209a7a6057230bfb29be2eaef3ae0098ab726ef807728f7b4792e31db50a2b89636ae181d9e71b03f2f83c1/bin/compile: line 82: [: too many arguments
/app/tmp/buildpacks/3174f4234c5151450fcaba5f50a050126498959c8209a7a6057230bfb29be2eaef3ae0098ab726ef807728f7b4792e31db50a2b89636ae181d9e71b03f2f83c1/bin/compile: line 88: [: too many arguments
/app/tmp/buildpacks/3174f4234c5151450fcaba5f50a050126498959c8209a7a6057230bfb29be2eaef3ae0098ab726ef807728f7b4792e31db50a2b89636ae181d9e71b03f2f83c1/bin/compile: line 94: [: too many arguments
cp: target '/tmp/build_a7cfd7a56646fe632a93fc752b8ee03d/.heroku/vendor/lib/.' is not a directory
! Push rejected, failed to compile geos/gdal/proj app.
! Push failed
So I finally managed to find a solution, I had setup two variable in my settings.py as it was said in different tutorial and on the official doc:
GEOS_LIBRARY_PATH = os.getenv('GEOS_LIBRARY_PATH')
GDAL_LIBRARY_PATH = os.getenv('GDAL_LIBRARY_PATH')
But I don't know why those variable happend to be:
/app/.heroku/vendor/lib
And that's why it didn't work, so my solution is just to hardcode my paths for heroku:
GEOS_LIBRARY_PATH = '/app/.heroku/vendor/lib/libgeos_c.so' if os.environ.get('ENV') == 'HEROKU' else os.getenv('GEOS_LIBRARY_PATH')
GDAL_LIBRARY_PATH = '/app/.heroku/vendor/lib/libgdal.so' if os.environ.get('ENV') == 'HEROKU' else os.getenv('GDAL_LIBRARY_PATH')
Be careful, you really need to put the "_c" to "libgeos_c.so" otherwise it's not working.
I hope it helps