Mac – Bypass unresolvable error when cleaning packages with package manager

homebrewmacports

Using MacPorts, when I run

sudo port -f clean --all all

Then I get an error. Snippet of output below:

--->  Cleaning ml
--->  Cleaning mldonkey
--->  Cleaning mlpack
--->  Cleaning mlt
Error: Unable to open port: Package Qt5Core was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Core.pc'
to the PKG_CONFIG_PATH environment variable

I don't know which one is causing the problem (I tried uninstalling/installing mlt but that doesn't do it). This may not be specific to MacPorts, but I see the same error with homebrew posted so maybe it is more general.

I searched in /opt/local/ which is the installation directory of MacPorts but I don't have Qt5Core.pc.

Is there a way to make this MacPorts command continue running (kind of like with exception handling) and continue cleaning other packages after the error is encountered?

Best Answer

The error has been reported at https://trac.macports.org/ticket/54861. A workaround patch has been provided.

diff --git a/multimedia/mlt/Portfile b/multimedia/mlt/Portfile
--- a/multimedia/mlt/Portfile
+++ b/multimedia/mlt/Portfile
@@ -42,7 +42,7 @@ if {${subport} eq "${name}"} {
     if {[info procs qt5.active_version] eq ""} {
         proc qt5.active_version {} {
             global prefix
-            if {[file exists ${prefix}/bin/pkg-config]} {
+            if {[file exists ${prefix}/bin/pkg-config/Qt5Core.pc]} {
                 set av [exec ${prefix}/bin/pkg-config --modversion Qt5Core]
                 return ${av}
             } else {
@@ -53,10 +53,15 @@ if {${subport} eq "${name}"} {

     qt5.depends_component \
                     qtsvg
-    if {[vercmp [qt5.active_version] 5.7.0] >= 0} {
-        configure.cxxflags-append \
-                    -stdlib=libc++ \
-                    -std=c++11
+    pre-configure {
+        # qt5.active_version only works if Qt is installed; we can
+        # be certain that is the case in the pre-configure phase.
+        if {[vercmp [qt5.active_version] 5.7.0] >= 0} {
+            ui_debug "Qt 5.7.0 and up require at least C++11"
+            configure.cxxflags-append \
+                        -stdlib=libc++ \
+                        -std=c++11
+        }
     }
 }