Pack_install(tokenize) failed on macOS

Hi,
Wanted to try the tokenize.pl package and used pack_install as in the subject on MacOS. The .zip was downloaded but the installation failed. I don’t understand what to do from the error messages below. Any suggestions on how to fix this?
Thank you.

?- pack_install(tokenize).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install tokenize@1.0.1 from https://github.com/shonfeder/tokenize/archive/v1.0.1.zip Y/n? 
ERROR: /private/var/folders/qt/pkj_bbgn65zblkm1m_pn3vk80000gn/T/AppTranslocation/524304D2-B159-4F3E-8EA0-E89CF83206E9/d/SWI-Prolog.app/Contents/swipl/library/archive.pl:96:
ERROR:    /private/var/folders/qt/pkj_bbgn65zblkm1m_pn3vk80000gn/T/AppTranslocation/524304D2-B159-4F3E-8EA0-E89CF83206E9/d/SWI-Prolog.app/Contents/swipl/library/archive.pl:96: Initialization goal raised exception:
ERROR:    dlopen(/private/var/folders/qt/pkj_bbgn65zblkm1m_pn3vk80000gn/T/AppTranslocation/524304D2-B159-4F3E-8EA0-E89CF83206E9/d/SWI-Prolog.app/Contents/swipl/lib/fat-darwin/archive4pl.so, 0x0001): Library not loaded: '/usr/local/opt/zstd/lib/libzstd.1.dylib'
  Referenced from: '/private/var/folders/qt/pkj_bbgn65zblkm1m_pn3vk80000gn/T/AppTranslocation/524304D2-B159-4F3E-8EA0-E89CF83206E9/d/SWI-Prolog.app/Contents/Frameworks/libarchive.13.dylib'
  Reason: tried: '/usr/local/opt/zstd/lib/libzstd.1.dylib' (no such file), '/usr/local/lib/libzstd.1.dylib' (no such file), '/usr/lib/libzstd.1.dylib' (no such file)
ERROR:    In:
ERROR:      [55] throw(error(shared_object(open,'dlopen(/private/var/folders/qt/pkj_bbgn65zblkm1m_pn3vk80000gn/T/AppTranslocation/524304D2-B159-4F3E-8EA0-E89CF83206E9/d/SWI-Prolog.app/Contents/swipl/lib/fat-darwin/archive4pl.so, 0x0001): Library not loaded: \'/usr/local/opt/zstd/lib/libzstd.1.dylib\'\n  Referenced from: \'/private/var/folders/qt/pkj_bbgn65zblkm1m_pn3vk80000gn/T/AppTranslocation/524304D2-B159-4F3E-8EA0-E89CF83206E9/d/SWI-Prolog.app/Contents/Frameworks/libarchive.13.dylib\'\n  Reason: tried: \'/usr/local/opt/zstd/lib/libzstd.1.dylib\' (no such file), \'/usr/local/lib/libzstd.1.dylib\' (no such file), \'/usr/lib/libzstd.1.dylib\' (no such file)'),context(...,_5510878)))
ERROR:      [53] <meta call>
ERR ...

If this were my problem I would just short circuit the error and download and copy the Prolog code directly onto my machine.

I took a quick peek at the two files and did not see anything that looked other than just Prolog code but don’t hold my feet to the fire.

HTH

Thanks. I will try that next. However, if anyone knows why pack_install is not working (bad setup for me in macOS etc) may help others too.

Hm, the error doesn’t look like it has anything to do with the tokenize pack in particular, but that your swipl isn’t able to load libzstd to extract the archive. How did you install SWI? Are you able to install any other packs?

1 Like

Hi, I installed in the recommended way on Mac.

What is the recommended way? The binary bundle? Macports? Homebrew? From source? Which SWI-Prolog version? Which MacOS version? Intel/M1?

The stack trace is quite clear something is wrong with the libarchive extension.

Hi jan,
I used swipl-8.4.1-1.x86_64.dmg,
macOS: 12.5.1
processor: 2.2 GHz Quad-Core Intel Core i7.

I just tried

pack_install(list_util).

was given the option to use .git or the zip file. I picked zip first and that failed. I picked .git the second time and that succeeded.
However,

use_library(list_util).

failed with:

ERROR: source_sink `list_util' does not exist
ERROR: In:
ERROR:   [20] throw(error(existence_error(source_sink,list_util),_2044))
ERROR:   [16] '$resolve_source_path'(list_util,_2076,[if(not_loaded),...]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2428
ERROR:   [15] '$load_file_e'(list_util,user,[if(not_loaded),...]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2404
ERROR:   [14] '$load_file'(list_util,user,[if(not_loaded),...]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2373
ERROR:    [9] toplevel_call(user:user: ...) at /Applications/SWI-Prolog.app/Contents/swipl/boot/toplevel.pl:1158

I tried

pack_install(tokenize).

again but it did not give me the .git option and the zip option failed before so I cancelled.

This git versions need git rather than libarchive to unpack. tokenize can be installed fine on the current 8.5.20 release (tested using the bundled app on Monterey running on an M1). That also installes list_util. I don’t know what use_library/1 does, but the system

 ?- use_module(library(list_util)).
 true.

works fine.

8.4.1 is old. 8.4.3 might work (not tested), 9.0, based on 8.5.20 will be released soon.

Hi jan,
Thank you very much.
I will upgrade to 8.5.20 and retry.

It was a problem with my mac missing various libraries. The problem resolved after I did a “brew upgrade” and added some missing libraries.
Thanks to everyone for their suggestions.