git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: meson build: datadir missing?

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 4, 2025, 07:08 UTC
Message-ID
<Z8am0ZmkJ7QD13_g@pks.im>
In-Reply-To
<20250303203320.lP10PHC5@steffen%sdaoden.eu>
On Mon, Mar 03, 2025 at 09:33:20PM +0100, Steffen Nurpmeso wrote:
Show 10 quoted lines
> Hello again after a long time.
> 
> I opened
> 
>   https://git.crux.nu/ports/opt/issues/18
> 
> at my linux distro ([ports/opt] git: creates incomplete repos),
> because hook etc directories were missing:
> 
>   warning: templates not found in /share/git-core/templates
Okay.
Show 5 quoted lines
>   hi. thanks, i see now (after looking around). it is a fallout of switching to meson, that build system seems incomplete
> 
>   master:meson.build: '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
> 
>   but that "datadir" does not happen to be set at all it seems; is this known upstream? (Hamano does not like me either, so i will not do that..)

"datadir" is set, as it is a default option provided by Meson itself, and can be configured with `meson setup --datadir`. I've also double-checked the logic how we set the template directory path, but it does seem to be correct: our Makefile sets up a path relative to the prefix, and we do the exact same here. Double-checking on my machine also confirmed that this works as expected:

    $ meson setup /tmp/build --prefix=/tmp/prefix
    $ meson install -C /tmp/build
    $ touch /tmp/prefix/share/git-core/templates/foobar
    $ /tmp/prefix/bin/git git init /tmp/repo
    $ ls /tmp/repo/.git
    config  description  foobar  HEAD  hooks  info  objects  refs  reftable

So I had a closer look at the recipe that Crux uses for building Git [1]. As it turns out, the issue isn't the prefix or datadir, but that Crux enables `-Druntime_prefix=true`:

    $ meson setup /tmp/build --prefix=/tmp/prefix -Druntime_prefix=true
    $ meson install -C /tmp/build
    $ /tmp/prefix/bin/git git init /tmp/repo
    warning: templates not found in /share/git-core/templates

This is a bug that has already been fixed via bd262d07b65 (meson: fix exec path with enabled runtime prefix, 2025-02-26). I'd recommend to backport this fix or disable the runtime prefix.

>   Only wondering why this happens at all, and is not covered by its tests, really.

Things like this are somewhat hard to test for as they require a proper installation.

[1]: https://git.crux.nu/ports/opt/src/branch/3.7/git/Pkgfile
Patrick
Previous: Steffen NurpmesoNext: Steffen Nurpmeso
Message 2 of 4 in “meson build: datadir missing?”
  1. Steffen NurpmesoMar 3, 2025
  2. Patrick SteinhardtMar 4, 2025
  3. Steffen NurpmesoMar 4, 2025
  4. Patrick SteinhardtMar 5, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.