Lost ability to arrow up for history

I am running SWI-Prolog (threaded, 64 bits, version 8.5.7) on my Mac OS Monterey. I have recently lost my ability to arrow up and see history.

I’m not really sure when it went away, but I’ve recently installed this development build of SWI Prolog (8.5.7) and also I recently created a user.pl file:

% user.pl
:- use_module(library(theme/dark)).

Any ideas?

History works here for me (macOS Monterey, gnu readline library from homebrew).

?- use_module(library(theme/dark)).
true.
?- X = 1.
X = 1.
< control-p>
?- X = 1.        (by history with the contro-p)
X = 1.

Only that apparently neither GNU readline nor BSD editline is around when you do the cmake. Re-run cmake . in the build directory which should print the stuff it doesn’t have. Surely it works fine on my M1 running Monterey:

 ?- current_prolog_flag(readline, X).
 X = editline.

And in the build dir

$ otool -L packages/libedit/libedit4pl.so
packages/libedit/libedit4pl.so:
	/opt/local/lib/libedit.0.dylib (compatibility version 1.0.0, current version 1.68.0)
	@rpath/libswipl.8.dylib (compatibility version 8.0.0, current version 8.5.7)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)

Which implies it gets libedit from Macports. For GNU readline you should get a similar story. Both have advantages.

This wasn’t a build I did myself, it was the development release for
SWI-Prolog 8.5.7-1 for MacOSX 10.14 (Mojave) and later on x86_64 and arm64.

I get this for the readline flag if it helps:

?- current_prolog_flag(readline, X).
X = swipl_win.

FWIW if I uninstall and install the latest stable build: SWI-Prolog 8.4.1-1 for MacOSX bundle on intel, the history works like I wanted and I also get:

?- current_prolog_flag(readline, X).
X = swipl_win.

I see. The SWI-Prolog.app is a different story. History works fine for me though. This is on the M1 (arm) version. Are you running on M1 or on Intel?

I’m running on an Intel mac

Just downloaded 8.5.7 .dmg file on my Intel macbook air running Monterey. History using up/down arrows works just fine. Also with dark theme (unlikely that causes this problem anyway).

You could try to move ~/.config/swi-prolog/init.pl to see if there is something in the init file that causes problems?

Does tab-based completion work?

Anyone else?

Yes, that seems to work just fine.

OK, I renamed the entire ~/.config/swi-prolog directory. When I launch 8.5.7, it recreates the ~/.config/swi-prolog/dir-history directory but puts no file in it.

Thinking that maybe it was a permissions problem, I made sure that Everyone has read and write permissions to everything in ~/.config/swi-prolog but that didn’t help (still nothing created).

Then I ran this to make sure the process had permissions to create files:

?- open('/Users/ericzinda/.config/swi-prolog/dir-history/test.txt', write, Out), 
    write(Out, test),
    close(Out).
Out = <stream>(0x600000164700).

This was able to create the test.txt file and write into it properly.

Edit: one other fact that may help: If I run the latest stable, it creates the structure /Users/ericzinda/.config/swi-prolog/dir-history/F4====== and puts history into it correctly as far as I can tell. It just looks like commands I have executed in the top level. Here is some of the content of that file (which looks right to me):

mqi_start(protocol(X)).
mqi_start([protocol(X)]).
mqi_start([protocol(X), port(Y)]).
current_predicate(mqi_version/2).

However, if I then launch 8.5.7 with that file there, up arrow doesn’t allow me to iterate through what is in that file. It does nothing.

Is there some kind of tracing I can turn on like a debug/1 trace to see where things are failing?

First, does history work in the same session, i.e., can you run a command and use arrow-up to reuse it. I’m getting the impression that the issue is save/restore of the history for a specific directory. Right? I think the save/restore is in boot/history.pl. Its a long time ago that I’ve looked at this code.

Also weird is there are no differences between the latest stable (8.4.2) and 8.5.7 when it comes to the Qt based console or the toplevel command reading code.

A sideways question, what do I get on a Mac by using the Qt based console that I am missing by using any other terminal emulator (there is a decent choice of terminal emulators for Macs).

Basically an app that can be in your dock with some useful menu options to get started. Once you know the commands to call from the terminal for all these operations the added value of the console is IMO limited. P.s. I’m not too convinced about this “decent choice of terminal emulators” on the Mac. I found Hyper, but it is really slow. So far nothing comes close to Linux/Gnome Terminator when it comes to features and (notably) speed. That runs on the Mac using X11 and Homebrew. Unfortunately the port isn’t 100% stable :frowning:

Two small things remain: the option to open multiple tabs that provide a new toplevel in a new thread at any point in time, even when some query is running in the main tab and the ability to open tools such as the thread monitor at any point in time if you are wondering what some long running query is doing. You can do the latter from the commandline using ^C, break, start the tools, leave the break and continue in nodebug mode.

3 Likes

well this is actually significant. thank you for taking the time to explain.

Yes, this works fine in the same session. I’ll take a look at boot/history.pl and see if I can figure anything out.