rustprooflabs / pgosm-flex

PgOSM Flex provides high quality OpenStreetMap datasets in PostGIS (Postgres) using the osm2pgsql Flex output.
MIT License
101 stars 20 forks source link

Make fails if `/app` directory doesn't exist. #268

Closed petrell9 closed 1 year ago

petrell9 commented 2 years ago

Hi there, thanks for merging my PR. I had some time to play around with the error I was experiencing with Make and think I figured out the cause. I'm not too familiar with Makefiles though so hopefully this issue is enough to reproduce the problem.

What version of PgOSM Flex are you using?

Latest main branch

What operating system, osm2pgsql, and PostgreSQL/PostGIS versions are you using?

My OS is Debian Bullseye

What did you do exactly?

Ran make in the root of the project directory where I cloned the repo. In this case ~/Documents/pgosm-flex

What did you expect to happen?

For make to download the PBF and build the image in the current working directory.

What did happen instead?

As shared previously, I got a permission denied error for my home directory:

image

Looks like the docker image built okay, but the resulting python call failed trying to reference the /app/output directory.

What did you do to try analyzing the problem?

First, I tried a directory outside of my home path in /tmp but that had the same error. I tried with sudo but it failed at the wget step with a directory issue as well (I can't remember the error exactly, I should have screencapped it as well my bad).

Then I moved everything into the /app directory, this too failed again, but it was because of the cached docker image that had already been built. After running docker rm -vf $(docker ps -aq) and docker rmi -f $(docker images -aq) to clear all my cached images, it built successfully and ran fine. (I was using a VM and didn't have any images other than those, so I assume a less destructive command would work just as well)

I think this most intuitive solution for the end user would be to reference the current working directory when building. If that's not possible, maybe an initial test to see if the /app directory exists before attempting to build at all? Also, perhaps the make docker-clean could also clear any cached images built for the project. It was a little confusing when it still didn't work after moving to the /app directory. Again, not too familiar with Makefiles, so not sure what the best approach is tbh. Let me know if you need any more details.

Cheers

rustprooflabs commented 2 years ago

@petrell9 Thank you for reporting this.

The work in the Makefile is really happening in Docker. The Makefile just orchestrates the work. The /app directory referred to in PgOSM Flex is referring to a path inside the Docker container, it is established here. Running make in the project directory should be linking the /app/output path inside Docker to a pgosm-data directory under the project's path. For you that should be the path ~/Documents/pgosm-flex/pgosm-data.

My guess is the Docker process does not have permission under your ~/Documents/pgosm-flex directory. It should auto-create the app/output directory inside Docker, which would be the ~/Documents/pgosm-flex/pgosm-data directory. That's the step that's failing.

Wil you try manually creating the pgosm-data path in the project folder before running make? That might be all it needs. If that doesn't work, it's possible Debian does something different with Docker installation/configuration that's getting in the way.

rustprooflabs commented 1 year ago

I haven't been able to reproduce this. If there are further details that can be provided on how to reproduce, reopen with details and I'll investigate!

Closing for now.