ERROR: Current directory is not a meson build directory

My app builds successfully using the command below:

flatpak run org.flatpak.Builder --force-clean --sandbox --user --install --install-deps-from=flathub --ccache --mirror-screenshots-url=https://dl.flathub.org/media/ --repo=repo builddir <manifest>

And I try to generate PO template using the command below:

flatpak run --command=meson --filesystem=host org.gnome.Sdk compile -C builddir  <app-name>.pot

However, I keep getting the error below. Not sure what could be the problem.

ERROR: Current directory is not a meson build directory: `path/to/builddir`.
Please specify a valid build dir or change the working directory to it.
It is also possible that the build directory was generated with an old
meson version. Please regenerate it in this case.

If you’re trying the second command with the same builddir as in the builder command then the error is correct:
It’s not a builddir but the result dir of the application (containing the install destination of your apllication & some metadata).

Put anything you want to create at build time into the manifest, e.g. build-commands or post-install, see Flatpak Builder Command Reference - Flatpak documentation

1 Like

If someone else comes across this thread in the future after encountering the same error, the most likely reason is that the directory generated after building a flatpak app is indeed not a meson directory as @cxrvh pointed out.

Unfortunately, things can be overwhelming for newbies when dealing with tools such as flatpak, flatpak builder, meson, ninja etc simultaneously.

For the particular problem above, I solved it by initializing a build directory( I guess you can call it the meson build directory) using the command below.

flatpak run --command=meson --filesystem=host org.gnome.Sdk build-dir

NOTE: The directory name should be different from the directory generated while building the project

And then used the command below to generate the POT file.

flatpak run --command=meson --filesystem=host org.gnome.Sdk compile -C build-dir foo.pot

The last bit of the above command, foo.pot should be the same as the name passed to i18n.gettext method in the meson.build file.

i18n.gettext('foo', preset: 'glib')

Reference:

UPDATE:

The last bit should’ve been foo-pot not foo.pot. Otherwise, you will get the error below:

ERROR: Can’t invoke target foo.pot: target not found

This topic was automatically closed after 2 days. New replies are no longer allowed.