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

Re: [PATCH v2 5/8] meson: fix lookup of shell on MINGW64

From
Justin Tobler <jltobler@gmail.com>
Date
Jul 8, 2025, 20:44 UTC
Message-ID
<jrpk2ydgoc7o2yj5nyr73gvgfjkyjkyqkfunu7showh7uvfuoj@bqiwcidm6gbk>
In-Reply-To
<20250708-b4-pks-meson-cleanups-v2-5-94ac53cd4b95@pks.im>
On 25/07/08 09:57AM, Patrick Steinhardt wrote:
Show 12 quoted lines
> In 4cba20fbdc6 (meson: prefer shell at "/bin/sh", 2025-04-25) we have
> addressed an issue where the shell path embedded into Git was looked up
> via PATH, which easily led to unportable shell paths other than the
> usual "/bin/sh" location. The fix was to simply add '/bin' to the search
> path explicitly, which made us prefer that directory over the PATH-based
> lookup.
> 
> This fix causes issues on MINGW64 though, which uses Windows-style
> paths. "/bin" is not an absolute Windows-style path, but Meson expects
> the directories to be absolute. This leads to the following error:
> 
>     meson.build:248:15: ERROR: Search directory /bin is not an absolute path.

Ok so the specifed `dirs` takes higher precedence over searching the $PATH and appending `/bin` was how we ensured `/bin/sh` was checked first. The problem is that for MINGW64, `/bin` is not a valid absolute path and results in the above mention error.

> Fix this by instead searching for both '/bin/sh' and 'sh', which also
> causes us to prefer '/bin/sh' over a PATH-based lookup. Meson does
> accept that path alright on MINGW64, even though it's not an absolute
> Windows-style path, either.

To avoid this problem, we instead search for `/bin/sh` directly. By specifying `/bin/sh` first, we maintain the same preference without affecting MINGW64. Makes sense.

Show 37 quoted lines
> Furthermore, this continues to work alright with cross-files, as well,
> in case one wants to explicitly override the shell path:
> 
>     $ meson setup build
>     ...
>       Runtime executable paths
>         perl       : /nix/store/gy10hw004rl2xfbfq41vnw0yb1w8rvbl-perl-5.40.0/bin/perl
>         python     : /nix/store/sd81bvmch7njdpwx3lkjslixcbj5mivz-python3-3.13.4/bin/python3
>         shell      : /bin/sh
> 
>     $ cat >cross.ini <<-EOF
>     [binaries]
>     sh = '/nix/store/94lg0shvsfc845zy8gnflvpqxxiyijbz-bash-interactive-5.2p37/bin/bash'
>     EOF
> 
>     $ meson setup build --cross-file=cross.ini --wipe
>     ...
>       Runtime executable paths
>         perl       : /nix/store/gy10hw004rl2xfbfq41vnw0yb1w8rvbl-perl-5.40.0/bin/perl
>         python     : /nix/store/sd81bvmch7njdpwx3lkjslixcbj5mivz-python3-3.13.4/bin/python3
>         shell      : /nix/store/94lg0shvsfc845zy8gnflvpqxxiyijbz-bash-interactive-5.2p37/bin/bash
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  meson.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index 4f22d72641e..bef80b118a8 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -245,7 +245,7 @@ time = find_program('time', dirs: program_path, required: get_option('benchmarks
>  # "/bin/sh" over a PATH-based lookup, which provides a working shell on most
>  # supported systems. This path is also the default shell path used by our
>  # Makefile. This lookup can be overridden via `program_path`.
> -target_shell = find_program('sh', dirs: program_path + [ '/bin' ], native: false)
> +target_shell = find_program('/bin/sh', 'sh', dirs: program_path, native: false)
Looks good!
-Justin
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 26 of 46 in “A handful of Meson cleanups and improvements”
  1. 0/8 A handful of Meson cleanups and improvementsPatrick Steinhardt, Jul 3, 2025
  2. 1/8 meson: stop discovering native version of PythonPatrick Steinhardt, Jul 3, 2025
  3. Justin ToblerJul 8, 2025
  4. Patrick SteinhardtJul 9, 2025
  5. 2/8 meson: stop printing 'https' option twice in our summariesPatrick Steinhardt, Jul 3, 2025
  6. 3/8 meson: improve summary of auto-detected featuresPatrick Steinhardt, Jul 3, 2025
  7. Justin ToblerJul 8, 2025
  8. 4/8 meson: clean up unnecessary variablesPatrick Steinhardt, Jul 3, 2025
  9. 5/8 meson: fix lookup of shell on MINGW64Patrick Steinhardt, Jul 3, 2025
  10. 6/8 meson: fix GIT_EXEC_PATH with overridden -Dlibexecdir=Patrick Steinhardt, Jul 3, 2025
  11. Ramsay JonesJul 3, 2025
  12. Patrick SteinhardtJul 8, 2025
  13. 7/8 meson: update subproject wrappersPatrick Steinhardt, Jul 3, 2025
  14. 8/8 ci: use Meson's new `--slice` optionPatrick Steinhardt, Jul 3, 2025
  15. Junio C HamanoJul 8, 2025
  16. Jeff KingJul 8, 2025
  17. Jeff KingJul 8, 2025
  18. Junio C HamanoJul 8, 2025
  19. Patrick SteinhardtJul 8, 2025
  20. 0/8 A handful of Meson cleanups and improvementsPatrick Steinhardt, Jul 8, 2025
  21. 1/8 meson: stop discovering native version of PythonPatrick Steinhardt, Jul 8, 2025
  22. 2/8 meson: stop printing 'https' option twice in our summariesPatrick Steinhardt, Jul 8, 2025
  23. 3/8 meson: improve summary of auto-detected featuresPatrick Steinhardt, Jul 8, 2025
  24. 4/8 meson: clean up unnecessary variablesPatrick Steinhardt, Jul 8, 2025
  25. 5/8 meson: fix lookup of shell on MINGW64Patrick Steinhardt, Jul 8, 2025
  26. Justin ToblerJul 8, 2025
  27. 6/8 meson: fix GIT_EXEC_PATH with overridden -Dlibexecdir=Patrick Steinhardt, Jul 8, 2025
  28. 7/8 meson: update subproject wrappersPatrick Steinhardt, Jul 8, 2025
  29. 8/8 ci: use Meson's new `--slice` optionPatrick Steinhardt, Jul 8, 2025
  30. 0/8 A handful of Meson cleanups and improvementsPatrick Steinhardt, Jul 9, 2025
  31. 1/8 meson: stop discovering native version of PythonPatrick Steinhardt, Jul 9, 2025
  32. Junio C HamanoJul 9, 2025
  33. Justin ToblerJul 9, 2025
  34. Eli SchwartzJul 9, 2025
  35. Junio C HamanoJul 9, 2025
  36. 2/8 meson: stop printing 'https' option twice in our summariesPatrick Steinhardt, Jul 9, 2025
  37. Junio C HamanoJul 9, 2025
  38. 3/8 meson: improve summary of auto-detected featuresPatrick Steinhardt, Jul 9, 2025
  39. Toon ClaesJul 10, 2025
  40. Junio C HamanoJul 10, 2025
  41. 4/8 meson: clean up unnecessary variablesPatrick Steinhardt, Jul 9, 2025
  42. 5/8 meson: fix lookup of shell on MINGW64Patrick Steinhardt, Jul 9, 2025
  43. 6/8 meson: fix GIT_EXEC_PATH with overridden -Dlibexecdir=Patrick Steinhardt, Jul 9, 2025
  44. 7/8 meson: update subproject wrappersPatrick Steinhardt, Jul 9, 2025
  45. 8/8 ci: use Meson's new `--slice` optionPatrick Steinhardt, Jul 9, 2025
  46. Justin ToblerJul 9, 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.