Exported procedure socket:tcp_connect/2 is not defined

Hi,
Past year I had no time to play with Prolog but today I finally found time to get back to work on a project I had started earlier.
I was still using a Swipl version that was over a year old. Updating Swipl did not work because some certificates were no longer recognized. So I decided to download and install the latest version of Swipl (threaded, 64 bits, version 9.3.7-47-g1ff28598f) on my Fedora 40 installation.
While compiling and installing, I saw no error messages but after I started my project with swipl load.pl I got this error message:

ERROR: /home/bengbers/lib/swipl/library/http/thread_httpd.pl:54:
ERROR: Exported procedure socket:tcp_connect/2 is not defined
ERROR: /home/bengbers/lib/swipl/library/pldoc/doc_index.pl:54:
ERROR: module/2: No permission to redefine module `pldoc_http’ (Already loaded from /home/bengbers/lib/swipl/library/ext/pldoc/doc_http.pl)
Warning: /home/bengbers/lib/swipl/library/ext/pldoc/doc_index.pl:54:
Warning: Goal (directive) failed: pldoc_index:use_module(library(doc_http),)

After adding :- use_module(library(doc_http),[]). to load.pl, I now get the same error but with these lines added:

ERROR: /home/bengbers/Mercurial/Prolog/DrawGraph_experiment/load.pl:5:
ERROR: load_files/2: No permission to load source ‘/home/bengbers/lib/swipl/library/doc_http.pl’ (Non-module file already loaded into module pldoc_index; trying to load into user)

What should I do?

Ben

EDIT

I installed all the dependenceis (it showed that some were missing) and reinstalled swipl.

After examination of load.pl, it showed that the error was caused by this line:
:-doc_server(4000).
After deleting that line, I could restart swipl without getting errors.
But now when trying to edit a file, I get this error:

?- ERROR: /home/bengbers/lib/swipl/xpce/prolog/lib/emacs/language_mode.pl:40:
ERROR: Exported procedure socket:tcp_connect/2 is not defined

What now?

Ben

No real clue. As Fedora 40 is now the main development platform, this should be pretty smooth. Did you follow SWI-Prolog on Redhat (Fedora, RHEL, CentOS) to install all dependencies prior to building?

I first issued the command sudo dnf install ... with all the packages that were named in the instructions. There after I cloned the repository again and followed all the instructions for compiling/building.
I saw no errors but I did see some messages on missing header files.

In a older discussion https://github.com/SWI-Prolog/swipl-devel/issues/1237 you asked if the previous swipl installation had been removed. I have never done this before and even don’t know how to do that.

Should I remove the existing installation? And if so, how can I do this?

Ben

Odd. Do the tests run fine? Please run

 ctest -j $(nproc)

Also, what do you get from the built-in test:

swipl
?- check_installation.

Old installations should not bother the process. Variables such as LD_LIBRARY_PATH and SWI_HOME_DIR can cause problems. Cmake checks for this and issues a warning.

Note that you may have problems if you compile the new version to be installed at the same place as the old one and you install the new one “over” the old one. In that case, remove the old one. You find it using swipl --home and simply remove it using rm -r <dir>. So, in a one liner using this command. I’d first run swipl --home to verify you are not removing something else!!

 rm -r $(swipl --home)

You normally get a warning about deleting the read-only file boot.prc. Just confirm.

Hi Jan,

~/Git/swpipl-devel/Build/ctest -j $(nproc)


100% tests passed, 0 tests failed out of 86

Total Test time (real) = 34.68 sec

[bengbers@fedora build]$ swipl

Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.7-47-g1ff28598f)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?-

NO ERRORS

[bengbers@fedora DrawGraph]$ swipl

Same result as [bengbers@fedora build]$ swipl

[bengbers@fedora DrawGraph]$ swipl load.pl

ERROR: /home/bengbers/lib/swipl/library/http/thread_httpd.pl:54:
ERROR: Exported procedure socket:tcp_connect/2 is not defined
ERROR: /home/bengbers/lib/swipl/library/pldoc/doc_index.pl:54:
ERROR: module/2: No permission to redefine module `pldoc_http’
(Already loaded from /home/bengbers/lib/swipl/library/ext/pldoc/doc_http.pl)
Warning: /home/bengbers/lib/swipl/library/pldoc/doc_index.pl:54:
Warning: Goal (directive) failed:
pldoc_index:use_module(library(doc_http),)
% Started server at http://localhost:4000/pldoc/
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.7-47-g1ff28598f)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?-
ERRORS!!!

[bengbers@fedora DrawGraph]$ cat load.pl

:- doc_server(4000, [allow(localhost), workers(1)]).

% :- manpce.

:- consult([
test,
drawGraph,
load_elements,
draw_elements,
mem_preds,
query,
templates,
exportResults
]
).

?- check_installation.

Checking your SWI-Prolog kit for common issues …

Version: … 9.3.7-47-g1ff28598f
Address bits: … 64
Architecture: … x86_64-linux
Installed at: … /home/bengbers/lib/swipl
Cores: … 4
.
Loading library(socket) … FAILEDExported
procedure socket:tcp_connect/2 is not defined
Warning:
Warning: See Issues with library(socket)
.
Warning: Found 1 issues.
true.

As far as I remember, after executing “swipl load.pl” and “test:test.”
swipl returned “true”.
I tried to use guitracer and that resulted in a frozen machine and it
was only after a few reboots that everything was working again.

In my application code the word tcp_connect is not used. I checked the
source code for socket and I saw that tcp_connect/2 is defined.
Is this usefull information?

Ben

Before reinstalling swipl, I first installed all the waiting patches and updated the Fedora installation with sudo dnf update. (To my surprise even after installing the patches there are still packages that have to be updated.)

I updated the repository, renamed the build-directory, created a new build-directory, deleted the existing lib (rm -r $(swipl --home) could be used since swipl --home returned the correct directory) and executed all the build commands. This time I redirected the output to log-files so now it is easy to see which header-files are missing.

swipl and swipl load.pl don’t give errors anymore. Also my test:test. executes without errors.
Using the editor and debugger however still gives problems. After clicking an entry in the menu both applications freeze. Neither ps -ax | grep swipl nor top give me any lead to which process is stil running. If I wait too long before logging off, the machine freezes and I have to use the power switch several seconds to turn it off.

Ben

I had the same after a recent update of fedora 40. It is a bug in XWayland that goes into a loop. I reported it and it has been fixed upstream. Not sure when the patches will become available in Fedora. I’d expect soon. I was really pleased with the feedback from the Fedora developers! For reference: 2284116 – Xwayland regularly goes to 100% CPU, making all X windows unresponsive

Thanks, This probaly also explains my other problems with my desktop!

There are also the installed packs (if any). You can find them (and the home directory) by:

swipl --dump-runtime-variables | egrep 'PACK|PLBASE'

(On my system, the packs are under $HOME/.local/share/swi-prolog and /usr/share/swi-prolog.)