$SNAPCRAFT_PROJECT_DIR is sometimes empty

I see sometimes that $SNAPCRAFT_PROJECT_DIR is empty.

Found this when I had cp abc.py $SNAPCRAFT_PROJECT_DIR in one of the parts. cp failed complaining cp: missing destination file operand after ‘abc.py’

1 Like

Other SNAPCRAFT environment variables like SNAPCRAFT_STAGE and SNAPCRAFT_PRIME work though.

Also my colleague does not see the issue of $SNAPCRAFT_PROJECT_DIR when he builds same code.

Anyone else has a workaround for this? When we use $SNAPCRAFT_PROJECT_DIR in override-build: it is always empty.
Other environment variables work just fine.

We are using Snapcraft version 4.4.4 on Ubuntu 18.04.

What base are you using? That environment variable was introduced for builds that use bases.

I just built a gadget snap w/o any base for a test. So that could explain the problem.
Is that documented anywhere?

You can probably set a build-base for this. The only documentation I know of does reference bases with the envvar https://snapcraft.io/docs/t/using-parts/11324. If you know of any other or think it could be either improved, feel free to do so or just describe what could be improved (once we know where you picked up on the use of this env var). @degville can probably help out too.

2 Likes