# meson build: datadir missing?

4 messages from 2025-03-03 to 2025-03-05. Participants: Steffen Nurpmeso, Patrick Steinhardt.
Thread: https://gitlist.dev/t/63051

## Steffen Nurpmeso, 2025-03-03 20:33

Subject: meson build: datadir missing?
Message-ID: <20250303203320.lP10PHC5@steffen%sdaoden.eu>
URL: https://gitlist.dev/e/20250303203320.lP10PHC5%40steffen%25sdaoden.eu

```
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

He then said

  Try setting

    [init]
      templatedir = /usr/share/git-core/templates

  in your gitconfig.

which made me wonder since that is the default, so i looked and
saw his change to switch to meson back in January.  (What a pity,
i liked the make system; only that it requires GNU make, but
well..).  I then said (it is a web ui, sorry):

  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..)

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

  Ok i overwrite the default with the real default in my config, thanks again.


While here, since a couple of months maybe i get a problem on my
spare notebook when i sync the filesystem (btrfs).
To reproduce:

  #?0|kent:~# mount /media/btrfs-master/
  #?0|kent:/media/btrfs-master# cd crux/kent/root
  #?0|kent:/media/btrfs-master/crux/kent/root# chroot .

^(we are now chroot(1)ed to the same what is /, actually.)

  #?0|kent:/# cd root/
  #?0|kent:~# git co kent
  git: ../git-2.48.1/exec-cmd.c:50: system_prefix: Assertion `executable_dirname' failed.
  Aborted

It will work if i do /usr/bin/git, effectively the same binary.
However, this does not apply "normally":

  #?0|kent:~# cd /
  #?0|kent:/# chroot .
  #?0|kent:/# cd root
  #?0|kent:~# git co kent
  M       hosts/iwd.network/.known_network.freq
  Switched to branch 'kent'
  #?0|kent:~# git co master
  M       hosts/iwd.network/.known_network.freq
  Switched to branch 'master'

Whatever the actual logic is, it seems a bit odd, and furthermore,
and most of all, the above assertion is not a real help to solve
the problem at hand, some kind of hint to a solution would be
tremendous!

Thanks for git, and ciao!

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

```

## Patrick Steinhardt, 2025-03-04 07:08

Subject: Re: meson build: datadir missing?
Message-ID: <Z8am0ZmkJ7QD13_g@pks.im>
URL: https://gitlist.dev/e/Z8am0ZmkJ7QD13_g%40pks.im
In-Reply-To: <20250303203320.lP10PHC5@steffen%sdaoden.eu>

```
On Mon, Mar 03, 2025 at 09:33:20PM +0100, Steffen Nurpmeso wrote:
> 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.

>   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

```

## Steffen Nurpmeso, 2025-03-04 18:16

Subject: Re: meson build: datadir missing?
Message-ID: <20250304181636.CEUTB9ed@steffen%sdaoden.eu>
URL: https://gitlist.dev/e/20250304181636.CEUTB9ed%40steffen%25sdaoden.eu
In-Reply-To: <Z8am0ZmkJ7QD13_g@pks.im>

```
Hello Patrick Steinhardt,

Patrick Steinhardt wrote in
 <Z8am0ZmkJ7QD13_g@pks.im>:
 |On Mon, Mar 03, 2025 at 09:33:20PM +0100, Steffen Nurpmeso wrote:
 |> 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.
 |
 |>   hi. thanks, i see now (after looking around). it is a fallout of \
 |>   switching to meson, that build system seems incomplete
 ...
 |>   but that "datadir" does not happen to be set at all it seems; is \
 ...
 |"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

Thanks for all the effort!

 |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.

I will pass this information through, thank you.

 |>   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.

Sure.  I just did not know about the meson stuff until this issue
arose, lots of things seem to happen this year regarding it, there
is a massive flux etc etc.  I did not want to piss somewhere,
sorry.

 |[1]: https://git.crux.nu/ports/opt/src/branch/3.7/git/Pkgfile
 |
 |Patrick
 --End of <Z8am0ZmkJ7QD13_g@pks.im>

Thanks for git!

Ciao, and greetings,

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

```

## Patrick Steinhardt, 2025-03-05 07:19

Subject: Re: meson build: datadir missing?
Message-ID: <Z8f6_3nJ9ld4kC6p@pks.im>
URL: https://gitlist.dev/e/Z8f6_3nJ9ld4kC6p%40pks.im
In-Reply-To: <20250304181636.CEUTB9ed@steffen%sdaoden.eu>

```
On Tue, Mar 04, 2025 at 07:16:36PM +0100, Steffen Nurpmeso wrote:
> Patrick Steinhardt wrote in
>  |>   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.
> 
> Sure.  I just did not know about the meson stuff until this issue
> arose, lots of things seem to happen this year regarding it, there
> is a massive flux etc etc.  I did not want to piss somewhere,
> sorry.

No need to be sorry, I wasn't offended by anything.

Patrick

```
