homebrew-amc icon indicating copy to clipboard operation
homebrew-amc copied to clipboard

AMC fails after cairo update

Open stiglitzkleiber opened this issue 2 years ago • 13 comments

Installation of AMC has been running since May 2022 under Mac OS Monterey without problems. Since a Homebrew update (7.1.23) I get the following error upon call of $ auto-multiple-choice:

Can't load '/opt/homebrew/Cellar/auto-multiple-choice/1.5.0/libexec/lib/perl5/darwin-thread-multi-2level/auto/Cairo/Cairo.bundle' for module Cairo: dlopen(/opt/homebrew/Cellar/auto-multiple-choice/1.5.0/libexec/lib/perl5/darwin-thread-multi-2level/auto/Cairo/Cairo.bundle, 0x0001): symbol not found in flat namespace (_Perl_newSV_type) at /opt/homebrew/opt/perl/lib/perl5/5.36/darwin-thread-multi-2level/DynaLoader.pm line 210.
 at /opt/homebrew/Cellar/auto-multiple-choice/1.5.0/libexec/lib/perl5/darwin-thread-multi-2level/Cairo/GObject.pm line 14.
Compilation failed in require at /opt/homebrew/Cellar/auto-multiple-choice/1.5.0/libexec/lib/perl5/darwin-thread-multi-2level/Cairo/GObject.pm line 14.
BEGIN failed--compilation aborted at /opt/homebrew/Cellar/auto-multiple-choice/1.5.0/libexec/lib/perl5/darwin-thread-multi-2level/Cairo/GObject.pm line 14.
Compilation failed in require at /opt/homebrew/Cellar/auto-multiple-choice/1.5.0/libexec/lib/perl5/Gtk3.pm line 47.
BEGIN failed--compilation aborted at /opt/homebrew/Cellar/auto-multiple-choice/1.5.0/libexec/lib/perl5/Gtk3.pm line 47.
Compilation failed in require at /opt/homebrew/Cellar/auto-multiple-choice/1.5.0/lib/AMC/perl/AMC-gui.pl line 26.
BEGIN failed--compilation aborted at /opt/homebrew/Cellar/auto-multiple-choice/1.5.0/lib/AMC/perl/AMC-gui.pl line 26.

A call of $ brew info auto-multiple-choice results in:

==> maelvls/amc/auto-multiple-choice: stable 1.5.0
Printable tests for students with OCR marking
https://www.auto-multiple-choice.net
/opt/homebrew/Cellar/auto-multiple-choice/1.5.0 (1,295 files, 31.7MB) *
  Built from source on 2022-08-16 at 19:16:19
From: https://github.com/maelvls/homebrew-amc/blob/HEAD/auto-multiple-choice.rb
==> Dependencies
Build: librsvg ✔, make ✔
Required: adwaita-icon-theme ✔, amc-pango ✔, cairo ✔, freetype ✔, gettext ✔, glib ✔, gobject-introspection ✔, gtk+3 ✔, imagemagick@6 ✔, libffi ✔, libx11 ✔, netpbm ✔, opencv ✔, [email protected] ✔, perl ✔, poppler ✔, qpdf ✔

stiglitzkleiber avatar Jan 11 '23 15:01 stiglitzkleiber

That might be because Homebrew updated cairo, and the cairo.dylib changed name due to a major version bump, and auto-multiple-choice can't find it"

Would you be able to re-install auto-multiple-choice and see if that fixes the issue?

brew reinstall auto-multiple-choice

Since you are using an M1 mac, which doesn't have a bottle for it, that will re-build the formula from source. If it is a problem with cairo.dylib changing name due to a version bump, that should fix it.

Also, what is the version of Cairo on your machine? Can you run:

brew info cairo

maelvls avatar Jan 11 '23 15:01 maelvls

This is the log from the re-install:

`Last 15 lines from /Users/elster/Library/Logs/Homebrew/auto-multiple-choice/01.make:
gcc -o AMC-pdfformfields pdfformfields.c  -O2  -lm 
pdfformfields.c:8:10: fatal error: 'poppler.h' file not found
#include <poppler.h>
         ^~~~~~~~~~~
1 error generated.
make[1]: *** [Makefile:139: AMC-pdfformfields] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from AMC-buildpdf.cc:23:
./buildpdf.cc:30:10: fatal error: 'cairo.h' file not found
#include <cairo.h>
         ^~~~~~~~~
1 error generated.
make[1]: *** [Makefile:136: AMC-buildpdf] Error 1
make[1]: Leaving directory '/private/tmp/auto-multiple-choice-20230111-94432-21msan/auto-multiple-choice-1.5.0'
make: *** [Makefile:126: all_precomp] Error 2 
`

and brew info cairo drops this message:

==> cairo: stable 1.16.0 (bottled), HEAD
Vector graphics library with cross-device output support
https://cairographics.org/
/opt/homebrew/Cellar/cairo/1.16.0_5 (126 files, 6.4MB) *
  Poured from bottle on 2023-01-07 at 11:38:56
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/cairo.rb
License: LGPL-2.1-only or MPL-1.1
==> Dependencies
Build: pkg-config ✔
Required: fontconfig ✔, freetype ✔, glib ✔, libpng ✔, libx11 ✔, libxcb ✔, libxext ✔, libxrender ✔, lzo ✔, pixman ✔
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 177,266 (30 days), 554,486 (90 days), 1,480,417 (365 days)
install-on-request: 7,021 (30 days), 25,624 (90 days), 119,968 (365 days)
build-error: 18 (30 days)

stiglitzkleiber avatar Jan 11 '23 16:01 stiglitzkleiber

Same for me! It seems that GCC_PDF is not evaluated properly. Compiling with -v -d, it appears that $GCC_PDF (defining the C FLAGS for cairo, ....) is empty when it is not at the end of the message:

gcc -o AMC-buildpdf AMC-buildpdf.cc  -O2   -lstdc++ -lm  -I/opt/homebrew/opt/opencv/include/opencv4 -L/opt/homebrew/opt/opencv/lib -lopencv_gapi -lopencv_stitching -lopencv_alphamat -lopencv_aruco -lopencv_barcode -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_sfm -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_viz -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -std=c++11
Package pthread-stubs was not found in the pkg-config search path.
Perhaps you should add the directory containing `pthread-stubs.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pthread-stubs', required by 'xcb', not found
gcc -o AMC-pdfformfields pdfformfields.c  -O2  -lm 
In file included from AMC-buildpdf.cc:23:
./buildpdf.cc:30:10: fatal error: 'cairo.h' file not found
#include <cairo.h>
         ^~~~~~~~~
pdfformfields.c:8:10: fatal error: 'poppler.h' file not found
#include <poppler.h>
         ^~~~~~~~~~~
1 error generated.
make[1]: *** [Makefile:139: AMC-pdfformfields] Error 1
make[1]: *** Waiting for unfinished jobs....
1 error generated.
make[1]: *** [Makefile:136: AMC-buildpdf] Error 1
make[1]: Leaving directory '/private/tmp/auto-multiple-choice-20230111-60030-dgd165/auto-multiple-choice-1.5.0'
make: *** [Makefile:126: all_precomp] Error 2
/opt/homebrew/Library/Homebrew/shims/shared/git --version
/opt/homebrew/Library/Homebrew/shims/shared/curl --version
/opt/homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'

whereas it should be (here $GCC_PDF is complete):

gcc -o AMC-buildpdf AMC-buildpdf.cc  -O2   -lstdc++ -lm -I/opt/homebrew/Cellar/pango/1.50.12/include/pango-1.0 -I/opt/homebrew/Cellar/harfbuzz/6.0.0/include/harfbuzz -I/opt/homebrew/Cellar/pango/1.50.12/include/pango-1.0 -I/opt/homebrew/Cellar/glib/2.74.4/include -I/opt/homebrew/Cellar/fribidi/1.0.12/include/fribidi -I/opt/homebrew/Cellar/harfbuzz/6.0.0/include/harfbuzz -I/opt/homebrew/Cellar/graphite2/1.3.14/include -I/opt/homebrew/Cellar/poppler/23.01.0/include/poppler/glib -I/opt/homebrew/Cellar/poppler/23.01.0/include/poppler -I/opt/homebrew/Cellar/cairo/1.16.0_5/include/cairo -I/opt/homebrew/Cellar/glib/2.74.4/include -I/opt/homebrew/Cellar/glib/2.74.4/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.74.4/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre2/10.42/include -I/opt/homebrew/Cellar/pixman/0.42.2/include/pixman-1 -I/opt/homebrew/Cellar/fontconfig/2.14.1/include -I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/Cellar/libpng/1.6.39/include/libpng16 -I/opt/homebrew/Cellar/libxcb/1.15/include -I/opt/homebrew/Cellar/libxrender/0.9.11/include -I/opt/homebrew/Cellar/libxext/1.3.5/include -I/opt/homebrew/Cellar/libx11/1.8.3/include -I/opt/homebrew/Cellar/libxcb/1.15/include -I/opt/homebrew/Cellar/libxau/1.0.11/include -I/opt/homebrew/Cellar/libxdmcp/1.1.4/include -I/opt/homebrew/Cellar/xorgproto/2022.2/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/ffi -L/opt/homebrew/Cellar/pango/1.50.12/lib -L/opt/homebrew/Cellar/harfbuzz/6.0.0/lib -L/opt/homebrew/Cellar/poppler/23.01.0/lib -L/opt/homebrew/Cellar/glib/2.74.4/lib -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/Cellar/cairo/1.16.0_5/lib -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lpoppler-glib -lgobject-2.0 -lglib-2.0 -lintl -lcairo -I/opt/homebrew/opt/opencv/include/opencv4 -L/opt/homebrew/opt/opencv/lib -lopencv_gapi -lopencv_stitching -lopencv_alphamat -lopencv_aruco -lopencv_barcode -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_sfm -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_viz -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -std=c++11

What is weird , is that in a terminal, everything is fine when determining GCC_PDF:

pkg-config --cflags --libs cairo pangocairo poppler-glib                  ((arm64))
-I/opt/homebrew/Cellar/pango/1.50.12/include/pango-1.0 -I/opt/homebrew/Cellar/harfbuzz/6.0.0/include/harfbuzz -I/opt/homebrew/Cellar/pango/1.50.12/include/pango-1.0 -I/opt/homebrew/Cellar/glib/2.74.4/include -I/opt/homebrew/Cellar/fribidi/1.0.12/include/fribidi -I/opt/homebrew/Cellar/harfbuzz/6.0.0/include/harfbuzz -I/opt/homebrew/Cellar/graphite2/1.3.14/include -I/opt/homebrew/Cellar/poppler/23.01.0/include/poppler/glib -I/opt/homebrew/Cellar/poppler/23.01.0/include/poppler -I/opt/homebrew/Cellar/cairo/1.16.0_5/include/cairo -I/opt/homebrew/Cellar/glib/2.74.4/include -I/opt/homebrew/Cellar/glib/2.74.4/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.74.4/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre2/10.42/include -I/opt/homebrew/Cellar/pixman/0.42.2/include/pixman-1 -I/opt/homebrew/Cellar/fontconfig/2.14.1/include -I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/Cellar/libpng/1.6.39/include/libpng16 -I/opt/homebrew/Cellar/libxcb/1.15/include -I/opt/homebrew/Cellar/libxrender/0.9.11/include -I/opt/homebrew/Cellar/libxext/1.3.5/include -I/opt/homebrew/Cellar/libx11/1.8.3/include -I/opt/homebrew/Cellar/libxcb/1.15/include -I/opt/homebrew/Cellar/libxau/1.0.11/include -I/opt/homebrew/Cellar/libxdmcp/1.1.4/include -I/opt/homebrew/Cellar/xorgproto/2022.2/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/ffi -L/opt/homebrew/Cellar/pango/1.50.12/lib -L/opt/homebrew/Cellar/harfbuzz/6.0.0/lib -L/opt/homebrew/Cellar/poppler/23.01.0/lib -L/opt/homebrew/Cellar/glib/2.74.4/lib -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/Cellar/cairo/1.16.0_5/lib -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lpoppler-glib -lgobject-2.0 -lglib-2.0 -lintl -lcairo

rcqls avatar Jan 12 '23 09:01 rcqls

And what can I do to revitalise my AMC installation?

stiglitzkleiber avatar Jan 12 '23 13:01 stiglitzkleiber

And what can I do to revitalise my AMC installation?

Hope @maelvls would be able to fix the installation process to have $GCC_PDF non empty. From now I have no idea how to solve the issue. Just as an info: when doing brew reinstall -d -v auto-mulitple-choice it stops when failing and by opening a new terminal in the private directory containing the temporary installation, I am able to run make AMCCONF=brew PREFIX=/opt/homebrew/Cellar/auto-multiple-choice/1.5.0 LIBS_PREFIX=/opt/homebrew without failure. This is weird since this is failing in the installation process.

rcqls avatar Jan 12 '23 14:01 rcqls

Found a solution, adding libpthread-stubs as dependency fix the issue (since pkg-config was failing for cairo):

  ...
  depends_on "amc-pango"
  depends_on "libpthread-stubs" # add this line!
  depends_on "cairo"
  ...

@maelvls I have proposed a PR to fix this issue.

rcqls avatar Jan 13 '23 03:01 rcqls

@rcqls I'm stuck as I don't know how to implement your solution: further help would be much appreciated

stiglitzkleiber avatar Jan 13 '23 16:01 stiglitzkleiber

@rcqls I'm stuck as I don't know how to implement your solution: further help would be much appreciated

To reinstall auto-multiple-choice before the PR is accepted.

  1. brew edit auto-multiple-choice to edit the formula
  2. add depends_on "libpthread-stubs" => :build just before depends_on "cairo"
  3. brew reinstall --formula /opt/homebrew/Library/Taps/maelvls/homebrew-amc/auto-multiple-choice.rb

Tell me if this working for you!

rcqls avatar Jan 13 '23 16:01 rcqls

great, it works, thanks a lot! Kaspar (macOS Monterey 12.6.2 on MacBook Pro M1 2020)

stiglitzkleiber avatar Jan 13 '23 16:01 stiglitzkleiber

great, it works, thanks a lot! Kaspar (macOS Monterey 12.6.2 on MacBook Pro M1 2020)

Nice!

rcqls avatar Jan 13 '23 16:01 rcqls

I think I found the root cause of this issue. What prompted me to investigate is that pthreads-stubs shouldn't be required for building auto-multiple-choice.

My guess is that Homebrew added pthreads-stubs as a dependency of some formula for a while, and then removed it. It might be libxcb (https://github.com/Homebrew/homebrew-core/pull/111928). The removal of the dependency on pthreads-stubs happened 3 weeks ago, which matches the timeline of this issue.

Re-installing libxcb will fix the issue:

brew reinstall libxcb
brew upgrade auto-multiple-choice

maelvls avatar Jan 16 '23 08:01 maelvls

I think I found the root cause of this issue. What prompted me to investigate is that pthreads-stubs shouldn't be required for building auto-multiple-choice.

My guess is that Homebrew added pthreads-stubs as a dependency of some formula for a while, and then removed it. It might be libxcb (Homebrew/homebrew-core#111928). The removal of the dependency on pthreads-stubs happened 3 weeks ago, which matches the timeline of this issue.

I noticed that re-installing libxcb fixed the issue, but I'll need to reproduce what I found.

Just tested what you have found by reinstalling libxcb and then removing libpthread-stubs dependency and everything seems fine now.

rcqls avatar Jan 16 '23 09:01 rcqls

Confirmed: brew reinstall libxcbwas the solution. Thanks!

bartzbeielstein avatar Jan 17 '23 18:01 bartzbeielstein