Autoconf-bundled macro uses /bin/sh, breaking builds that do autoreconf

  • Done
  • quality assurance status badge
Details
One participant
  • W. Kosior
Owner
unassigned
Submitted by
W. Kosior
Severity
normal

Debbugs page

W
W
W. Kosior wrote on 18 Jul 04:43 -0700
(address . bug-guix@gnu.org)
20250718134310.546da258.koszko@koszko.org
Hi Guix,

file `share/autoconf/autoconf/erlang.m4' in Autoconf package contains
definitions allowing configure-time tests using Erlang. The piece of
code responsible for generating a `conftest' script adds a shebang with
`#!/bin/sh':

Toggle snippet (10 lines)
# AC_LANG(Erlang)
# ---------------
AC_LANG_DEFINE([Erlang], [erl], [ERL], [ERLC], [],
[ac_ext=erl
: ${ac_objext=o}
ac_compile='$ERLC $ERLCFLAGS -b beam conftest.$ac_ext >&AS_MESSAGE_LOG_FD && ln -sf conftest.beam conftest.$ac_objext'
ac_link='$ERLC $ERLCFLAGS -b beam conftest.$ac_ext >&AS_MESSAGE_LOG_FD && echo "[#]!/bin/sh" > conftest$ac_exeext && AS_ECHO(["\"$ERL\" -run conftest start -run init stop -noshell"]) >> conftest$ac_exeext && chmod +x conftest$ac_exeext'
])

This could make sense if the Autoconf from Guix were to be used for
generating a `configure' script to be run on other system. But if
a script with `#!/bin/sh' is created during a Guix package build, this
is wrong.

Here's an error I got due to this when working on a recipe for Erlang
HTTP server, Yaws:

Toggle snippet (14 lines)
[...]
checking for ct_run... /gnu/store/briw8s44c7w2lj3qwz3w2x4c0gpgpkn8-erlang-27.3.4/bin/ct_run
checking for erlc... /gnu/store/briw8s44c7w2lj3qwz3w2x4c0gpgpkn8-erlang-27.3.4/bin/erlc
checking for erl... /gnu/store/briw8s44c7w2lj3qwz3w2x4c0gpgpkn8-erlang-27.3.4/bin/erl
checking for Erlang/OTP root directory... configure: error: in `/tmp/guix-build-erlang-yaws-2.2.0.drv-0/source':
configure: error: test Erlang program execution failed
See `config.log' for more details
error: in phase 'configure': uncaught exception:
%exception #<&invoke-error program: "/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash" arguments: ("./configure" "CONFIG_SHELL=/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash" "SHELL=/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash" "--prefix=/gnu/store/12731cvmcwr0f2cgjy87bx6k1cg5nlqb-erlang-yaws-2.2.0" "--enable-fast-install" "--build=x86_64-unknown-linux-gnu" "--enable-deterministic-build") exit-status: 1 term-signal: #f stop-signal: #f>
phase `configure' failed after 4.1 seconds
command "/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash" "./configure" "CONFIG_SHELL=/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash" "SHELL=/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash" "--prefix=/gnu/store/12731cvmcwr0f2cgjy87bx6k1cg5nlqb-erlang-yaws-2.2.0" "--enable-fast-install" "--build=x86_64-unknown-linux-gnu" "--enable-deterministic-build" failed with status 1
build process 4 exited with status 256

Btw, until someone fixes it, here's a hackish workaround for any1 who
hits this issue while working on some Erlang software recipe:

Toggle snippet (20 lines)
;; Copyright 2025 W. Kosior <koszko@koszko.org>
;; SPDX-License-Identifier: CC0-1.0
(add-before 'configure 'hack-to-avoid-/bin/sh
(lambda _
(mkdir-p "/tmp/hack-to-avoid-bin-sh")
(with-output-to-file "/tmp/hack-to-avoid-bin-sh/chmod"
(lambda _
(display "
if [ \"$1\" = +x ] &&
[ -f \"$2\" ] &&
[ \"$(head -1 \"$2\")\" = '#!/bin/sh' ]; then
sed -i 's,^#!/bin/sh,,' \"$2\"
fi
exec $(command -v chown | sed 's,chown$,chmod,') \"$@\"
")
(chmod (current-output-port) #o777)))
(setenv "PATH" (format #f "/tmp/hack-to-avoid-bin-sh:~a"
(getenv "PATH")))))

Best!
Wojtek

--
W. Kosior

PGP fingerprint: E972 7060 E3C5 637C 8A4F 4B42 4BC5 221C 5A79 FD1A
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQTpcnBg48VjfIpPS0JLxSIcWnn9GgUCaHozTgAKCRBLxSIcWnn9
GkmDAQDLOD6mPUsKdG5u2abNppTYikf9gCC5pTmmIw8Bh4DwPwEAwImmDf/ouX8o
K7bmfXthAvGddpVVTX1hDZ5oZLDjtwg=
=QCa4
-----END PGP SIGNATURE-----


W
W
W. Kosior wrote on 18 Jul 07:21 -0700
(address . 79044-close@debbugs.gnu.org)
20250718162129.3830de31.koszko@koszko.org
Oops, I was pretty lame today. In a recipe, this is actually more
simply fixable with

Toggle snippet (5 lines)
(add-before 'configure 'avoid-/bin/sh
(lambda _
(substitute* "configure" (("#!/bin/sh") ""))))

and one package seems to already be doing sth similar. I am not sure
this warrants a bug report, then. Sorry for the nuisance :)

Best,
Wojtek
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQTpcnBg48VjfIpPS0JLxSIcWnn9GgUCaHpYagAKCRBLxSIcWnn9
Gq1OAQCXSqo0LxIy4XRPfdvQseq1T5k9d0/lwsfH9b64GbayVgD/Q6T8jTwkuDmk
qBakHaowianyREdI50zbV7/iBBO/jwU=
=FF2F
-----END PGP SIGNATURE-----


?
Your comment

This issue is archived.

To comment on this conversation send an email to 79044@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 79044
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch