Opened 12 months ago

Last modified 10 months ago

#72151 assigned defect

neomutt @20240329 -doc: Error: No usable pkg-config

Reported by: kprussing (Keith) Owned by: l2dy (Zero King)
Priority: Normal Milestone:
Component: ports Version: 2.10.5
Keywords: Cc: mascguy (Christopher Nielsen)
Port: neomutt

Description

Trying to install fails at the configuration step.

% sudo port -v install neomutt -doc
<snip>
Error: No usable pkg-config
Try: 'configure --help' for options
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_mail_neomutt/neomutt/work/neomutt-20240329" && ./configure --prefix=/opt/local --disable-doc --with-ncurses=/opt/local --with-nls=/opt/local --lz4 --with-ssl=/opt/local --with-zlib=/opt/local --zstd --gpgme --with-idn2=/opt/local 
Exit code: 1
Error: Failed to configure neomutt: consult /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_mail_neomutt/neomutt/work/neomutt-20240329/config.log
Error: Failed to configure neomutt: configure failure: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_mail_neomutt/neomutt/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port neomutt failed

Looking in the config.log (full version attached) in the working directory I find:

Invoked as: ./configure --prefix=/opt/local --disable-doc --with-ncurses=/opt/local --with-nls=/opt/local --lz4 --with-ssl=/opt/local --with-zlib=/opt/local --zstd --gpgme --with-idn2=/opt/local
Tclsh: /usr/bin/tclsh
Failed: /usr/bin/clang -c -std=c99 -g0 -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -arch arm64 -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk conftest__.c -o conftest__.o
conftest__.c:1:10: fatal error: 'minix/config.h' file not found
    1 | #include <minix/config.h>
      |          ^~~~~~~~~~~~~~~~
1 error generated.
child process exited abnormally
============
The failed code was:
#include <minix/config.h>
int main(void) {

return 0;
}

Additional information:

% sw_vers
ProductName:		macOS
ProductVersion:		15.3.1
BuildVersion:		24D70
% uname -a
Darwin <host> 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 arm64
% xcodebuild -version
Xcode 16.2
Build version 16C5032a

Attachments (3)

main.log (104.5 KB) - added by kprussing (Keith) 12 months ago.
neomutt.log (5.7 KB) - added by kprussing (Keith) 12 months ago.
Command output
config.log (10.8 KB) - added by kprussing (Keith) 12 months ago.
Neomutt's config.log

Download all attachments as: .zip

Change History (13)

Changed 12 months ago by kprussing (Keith)

Attachment: main.log added

Changed 12 months ago by kprussing (Keith)

Attachment: neomutt.log added

Command output

Changed 12 months ago by kprussing (Keith)

Attachment: config.log added

Neomutt's config.log

comment:1 Changed 12 months ago by ryandesign (Ryan Carsten Schmidt)

Owner: changed from l2dy@… to l2dy
Summary: neomutt @20240329 -doc: Configuration step failsneomutt @20240329 -doc: Error: No usable pkg-config

The config.log error that minix/config.h was not found is completely normal. It's evidence of the configure script correctly doing its job, determining that your operating system is not Minix.

The error message from the main.log that no usable pkg-config was found seems more relevant but I don't see anything about that in the config.log. Are you sure you attached the right config.log? The neomutt port depends on the pkgconfig port so it should be installed. Is it? Does the pkg-config program work?

Last edited 12 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:2 Changed 12 months ago by kprussing (Keith)

I was wondering about the minix/config.h being a red herring. A web search pointed in that direction, but I was expecting more information in the config.log. The config.log I attached is the by product left in `port work neomutt`/neomutt-20240329. Is there another log file I should look for?

Pkg-config appears to be installed and functioning. Running pkg-config --list-all prints out an expected long list of packages. I'm in the process of setting up a shiny new work laptop and have successfully installed: clamav, cmake, flang-19, git, isync, links, msmtp, doppler, and tmux which all have pkgconfig listed in their respective port rdeps. I did stumble across a bug that said to force deactivate and reactivate pkgconfig (I've unfortunately closed the tab so I don't have the tracker number handy). I gave that a try but with no change in results.

comment:3 Changed 12 months ago by kprussing (Keith)

I decided to go to the source and see if it might be some oddity in neomutt directly. I cloned the upstream repo and tried to configure off the latest main branch, but I appear to be getting the same error. I tried

% PKG_CONFIG=`which pkg-config` ./configure --prefix=/opt/local --disable-doc --with-ncurses=/opt/local --with-nls=/opt/local --lz4 --with-ssl=/opt/local --with-zlib=/opt/local --zstd --gpgme --with-idn2=/opt/local
<snip>
Checking for pkg-config.../opt/local/bin/pkg-config (not found)
Error: No usable pkg-config

Which is the same error when building the port.

I took a look in the autosetup directory and found autosetup/pkg-config.tcl which has a check in pkg-config-init that appears to run pkg-config --version. When I run that in the terminal I get 0.29.2 with no problem. However, I modified the pkg-config.tcl to print the contents of the $version:

diff --git a/autosetup/pkg-config.tcl b/autosetup/pkg-config.tcl
index 9ce7111f5..2d6e433ff 100644
--- a/autosetup/pkg-config.tcl
+++ b/autosetup/pkg-config.tcl
@@ -40,6 +40,7 @@ proc pkg-config-init {{required 1}} {
 
 	if {[catch {exec [get-define PKG_CONFIG] --version} version]} {
 		msg-result "[get-define PKG_CONFIG] (not found)"
+        msg-result "version: $version"
 		if {$required} {
 			user-error "No usable pkg-config"
 		}

Rerunning ./configure I now see the output contains version: couldn't create error file for command: permission denied. I am not familiar with tcl so this could well be another red herring.

comment:4 Changed 12 months ago by kprussing (Keith)

After a bit more web searching for "couldn't create error file for command: permission denied", I came across #50867 that had some ideas. I took a look at the permissions:

% ls -ld /tmp
drwxrwxrwt  18 root  wheel  576 Mar  7 10:26 /tmp/
% ls -ld /private/tmp
drwxrwxrwt  18 root  wheel  576 Mar  7 10:11 /private/tmp/

The major difference is /tmp is not a symlink for me, but the permissions appear to be correct.

comment:5 Changed 12 months ago by kprussing (Keith)

Digging around a bit more, I found out that exec creates a temporary file for standard error. That led me to edit the pkg-config.tcl to redirect the standard error to prevent trying to create a file (below). I was able to edit the Portfile before running port config neomutt -doc and it configured. I was then able to build, destroot, and install. But I'm not sure this is the right solution. Running the resultant executable fails with a segfault.

Patch

diff --git a/autosetup/pkg-config.tcl b/autosetup/pkg-config.tcl
index 9ce7111f5..79a4c9090 100644
--- a/autosetup/pkg-config.tcl
+++ b/autosetup/pkg-config.tcl
@@ -38,7 +38,7 @@ proc pkg-config-init {{required 1}} {
 	define PKG_CONFIG [get-env PKG_CONFIG pkg-config]
 	msg-checking "Checking for pkg-config..."
 
-	if {[catch {exec [get-define PKG_CONFIG] --version} version]} {
+	if {[catch {exec 2>@stderr [get-define PKG_CONFIG] --version} version]} {
 		msg-result "[get-define PKG_CONFIG] (not found)"
 		if {$required} {
 			user-error "No usable pkg-config"
@@ -114,7 +114,7 @@ proc pkg-config {module args} {
 
 	set pkgconfig [get-define PKG_CONFIG]
 
-	set ret [catch {exec $pkgconfig --modversion "$module $args"} version]
+	set ret [catch {exec 2>@stderr $pkgconfig --modversion "$module $args"} version]
 	configlog "$pkgconfig --modversion $module $args: $version"
 	if {$ret} {
 		msg-result "not found"
@@ -122,7 +122,7 @@ proc pkg-config {module args} {
 	}
 	# Sometimes --modversion succeeds but because of dependencies it isn't usable
 	# This seems to show up with --cflags
-	set ret [catch {exec $pkgconfig --cflags $module} cflags]
+	set ret [catch {exec 2>@stderr $pkgconfig --cflags $module} cflags]
 	if {$ret} {
 		msg-result "unusable ($version - see config.log)"
 		configlog "$pkgconfig --cflags $module"
@@ -134,8 +134,8 @@ proc pkg-config {module args} {
 	define HAVE_${prefix}
 	define ${prefix}_VERSION $version
 	define ${prefix}_CFLAGS $cflags
-	define ${prefix}_LIBS [exec $pkgconfig --libs-only-l $module]
-	define ${prefix}_LDFLAGS [exec $pkgconfig --libs-only-L $module]
+	define ${prefix}_LIBS [exec 2>@stderr $pkgconfig --libs-only-l $module]
+	define ${prefix}_LDFLAGS [exec 2>@stderr $pkgconfig --libs-only-L $module]
 	return 1
 }
 
@@ -164,5 +164,5 @@ proc pkg-config-get {module name} {
 proc pkg-config-get-var {module variable} {
 	set pkgconfig [get-define PKG_CONFIG]
 	set prefix [feature-define-name $module HAVE_PKG_]
-	exec $pkgconfig $module --variable $variable
+	exec 2>@stderr $pkgconfig $module --variable $variable
 }

comment:6 in reply to:  4 Changed 12 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to kprussing:

After a bit more web searching for "couldn't create error file for command: permission denied", I came across #50867 that had some ideas. I took a look at the permissions:

% ls -ld /tmp
drwxrwxrwt  18 root  wheel  576 Mar  7 10:26 /tmp/
% ls -ld /private/tmp
drwxrwxrwt  18 root  wheel  576 Mar  7 10:11 /private/tmp/

The major difference is /tmp is not a symlink for me, but the permissions appear to be correct.

Checking on our x86_64 macOS Sequoia machine, /tmp is still a symlink pointing to /private/tmp, as it has been in prior macOS versions as well:

% ls -ld {,/private}/tmp
drwxrwxrwt  5 root  wheel  160 Mar  7 18:27 /private/tmp
lrwxr-xr-x@ 1 root  wheel   11 Jan 16 09:35 /tmp -> private/tmp

Since that doesn't appear to be the case for you, I'd start by trying to fix that. Does /tmp become a symlink if you restart the computer? If not, can you delete /tmp and replace it with a symlink to /private/tmp?

While your investigation and workaround involving avoiding the creation of the temporary files may work here, builds of all kinds will expect to be able to create temporary files so you're likely to run into more problems soon if the ability to create temporary files isn't restored.

In MacPorts ports builds, TMPDIR is set to a directory inside the work directory. Some parts of some builds may however ignore that and use /tmp instead.

comment:7 Changed 12 months ago by kprussing (Keith)

I went ahead and rebooted and was about to blow away /tmp when I noticed a key distinction:

% ls -ld /tmp
lrwxr-xr-x@ 1 root  wheel  11 Feb  4 11:57 /tmp -> private/tmp
% ls -ld /tmp/
drwxrwxrwt  15 root  wheel  480 Mar  7 22:46 /tmp/

(note the trailing / on the second command). So /tmp was indeed a symlink all along. (classic user relying on tab completion error...)

I 100% agree that altering the build of the port is a bad idea. I was just trying to hunt down what was going on to cause the problem. Redirecting stderr felt hacky and "not the right thing". That hack would hide if something was legitimately wrong ultimately causing bigger problems down the road.

comment:8 Changed 12 months ago by kprussing (Keith)

TL;DR: I managed configure and build neomutt by building the distributed jmish0.c before running configure. It works as a one off, but I don't know how it would integrate with MacPorts.

After a bit more digging, I found a few more details. It appears that the autosetup tool used by neomutt to configure is relying on the fact that the user has a newish version of tclsh. In particular, it appears that older versions of tclsh do not respect `TMPDIR` and use a hardcoded value instead.

Looking at the first script run by configure (`autosetup/autosetup-find-tclsh`), the tool will look for the interpreter with a preference of a local build of Jim Tkl. As a test, I hand built the local version of jimsh0 (cc -o jimsh0 autosetup/jimsh0.c). When I ran configure, it ran to completion with no complaints about not finding pkg-config or any other problems triggered by the permissions on /tmp. Then building the executable completes and the executable runs with no segfault. So, a potential solution could be to build the local version of jimsh0 before running configure instead of patching the build scripts.

I am not familiar enough with the MacPorts architecture to make a real recommendation. Building the interpreter could be a pre-configure step, but that would only fix this port. It would not propagate to any other port using the autosetup tool.

(edit: typo)

Last edited 12 months ago by kprussing (Keith) (previous) (diff)

comment:9 Changed 10 months ago by kprussing (Keith)

I was able to build neomutt by cloning the macport-ports repository, applying the patch below, and then running port install from the mail/neomutt directory. As I mentioned above, this fixes the neomutt port, but would not fix any other ports that run into the same issue. This also removed the need for me to select the -doc variant (which fails now because ${prefix}/etc/mime.types.sample isn't created for that variant and the post-activate step expects it to exist)

diff --git a/mail/neomutt/Portfile b/mail/neomutt/Portfile
index 3e9c02c15e5..a2430f11891 100644
--- a/mail/neomutt/Portfile
+++ b/mail/neomutt/Portfile
@@ -180,3 +180,13 @@ post-activate {
         }
     }
 }
+
+pre-configure {
+    # Create an options to pass to command_exec to build jimsh0
+    options jimsh.cmd jimsh.dir
+
+    default jimsh.cmd {${configure.cc} -o jimsh0 autosetup/jimsh0.c}
+    default jimsh.dir {${worksrcpath}}
+
+    command_exec jimsh
+}

comment:10 Changed 10 months ago by mascguy (Christopher Nielsen)

Cc: mascguy added
Note: See TracTickets for help on using tickets.