Running from an ssh session without X11 available:
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.33-26-gb078fbdf1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
CMake built from "/tmp/swipl-devel/build.pgo-native"
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
13 ?- spy(paxos:set_quorum).
SDL_Init() failed: No available video device
SDL_VIDEODRIVER=(null)
[PCE fatal: nil: Failed to initialize SDL
in: <No exception goal>
]
<No goal>
Host stack:
[79] pce_principal:set_pce_thread([app_name(swipl)])
[77] pce:init_pce
[76] '$run_init_goal'(pce:init_pce)
[75] catch(system:'$run_init_goal'(pce:init_pce), _8684, system:'$initialization_error'(_8684, pce:init_pce, '/tmp/swipl-devel/build.pgo-native/home/xpce/prolog/lib/pce.pl':280))
[74] catch_with_backtrace(system:'$run_init_goal'(pce:init_pce), _8684, system:'$initialization_error'(_8684, pce:init_pce, '/tmp/swipl-devel/build.pgo-native/home/xpce/prolog/lib/pce.pl':280))
Right. Pushed a fix for that. Detecting whether or not to load xpce is a bit harder now. For now, we use this:
%! has_display is semidet.
%
% True when we can run graphics. Graphics are always available on
% Windows or MacOS (although they may appear on the main console
% when invoked from a remote login). On Linux, we can detect
% ``DISPLAY`` (X11) or ``WAYLAND_DISPLAY`` (Wayland). We also
% assume we can run graphics if the ``SDL_VIDEO_DRIVER`` is set to
% `dummy`, implying we try to run _headless_.
has_display :- current_prolog_flag(windows, true), !.
has_display :- current_prolog_flag(apple, true), !.
has_display :- getenv('WAYLAND_DISPLAY', D), D \== '', !.
has_display :- getenv('DISPLAY', D), D \== '', !.
has_display :- getenv('SDL_VIDEO_DRIVER', dummy).
And we load xpce if the flag xpce is set to true, set it up for lazy loading if the flag xpce is not set and there is a display and do not enable it if xpce is set to false.
would this work if we (remotely) ssh into a windows/macos machine? I would suspect this would show the gui in the host machine, which is probably not wanted.
True. That is what the comments also say. I don’t know whether there is a reliable way to detect such issues. Yes, we can detect an SSH login. There could also be some non-SSH login with the same result or there could be some SSH display forwarding active. I doubt there is a 100% solution. In any case, you can run one of these to be explicit:
I am getting the same error after the fix, but with make:
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.34-22-g656029f07)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
CMake built from "/tmp/swipl-devel/build.pgo-native"
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
91 ?- make.
SDL_Init() failed: No available video device
SDL_VIDEODRIVER=(null)
[PCE fatal: nil: Failed to initialize SDL
in: <No exception goal>
]
<No goal>
Host stack:
[93] pce_principal:set_pce_thread([app_name(swipl)])
[91] pce:init_pce
[90] '$run_init_goal'(pce:init_pce)
[89] catch(system:'$run_init_goal'(pce:init_pce), _4206, system:'$initialization_error'(_4206, pce:init_pce, '/tmp/swipl-devel/build.pgo-native/home/xpce/prolog/lib/pce.pl':280))
[88] catch_with_backtrace(system:'$run_init_goal'(pce:init_pce), _4206, system:'$initialization_error'(_4206, pce:init_pce, '/tmp/swipl-devel/build.pgo-native/home/xpce/prolog/lib/pce.pl':280))
If you trigger autoloading, yes. gtrap/1 is trap/1 enabling the GUI. Maybe use this?
:- if(current_prolog_flag(gui, true).
et :- gtrap(_).
:- else.
et :- trap(_).
:- endif.
I pushed some changes to the code deciding on whether or not to load xpce that does not make the library available if there is no GUI context and xpce is not explicitly enabled. That should result in gtrap/1 to be undefined.
You are right. There was a typo in the name of the SDL environment variable. Pushed a fix. I thought the CI would trap that, but as the CI base images are too old to support SDL3, xpce is not part of the CI That should be fixed after Ubuntu 26.04 is released.