Help getting sweep running (Failed to locate ‘sweep-module’)

I’m trying to get sweep working in Doom Emacs and am getting sweeprolog--ensure-module: Failed to locate ‘sweep-module’

I’m on linux and am running emacs from the terminal with the LD_PRELOAD environment variable. ldd suggests it will load first as expected:

$ LD_PRELOAD=/home/bmaddy/.asdf/installs/swiprolog/9.0.0/lib/swipl/lib/x86_64-linux/ ldd $(which emacs) | head (0x00007ffe87742000)
	/home/bmaddy/.asdf/installs/swiprolog/9.0.0/lib/swipl/lib/x86_64-linux/ (0x00007f619ae1c000) => /lib/x86_64-linux-gnu/ (0x00007f619ad7e000) => /lib/x86_64-linux-gnu/ (0x00007f619acfd000) => /lib/x86_64-linux-gnu/ (0x00007f619acc2000) => /lib/x86_64-linux-gnu/ (0x00007f619aca6000) => /lib/x86_64-linux-gnu/ (0x00007f619ac99000) => /lib/x86_64-linux-gnu/ (0x00007f619a470000) => /lib/x86_64-linux-gnu/ (0x00007f619a369000) => /lib/x86_64-linux-gnu/ (0x00007f619a302000)

When I look at the running process, I can see that it is loaded:

$ # start emacs
$ LD_PRELOAD=/home/bmaddy/.asdf/installs/swiprolog/9.0.0/lib/swipl/lib/x86_64-linux/ emacs
$ # in a different terminal
$ lsof -wp $(pidof emacs) | grep swipl
emacs   843198 bmaddy  mem       REG              259,4  1984648  65152305 /home/bmaddy/.asdf/installs/swiprolog/9.0.0/lib/swipl/lib/x86_64-linux/

M-x describe-variable has "/home/bmaddy/.asdf/shims" first in the list of paths and using M-x shell-command to run swipl --version gives

SWI-Prolog version 9.0.0 for x86_64-linux

I manually evaluate (require 'sweeprolog) and it prints


Then I open a prolog file and run M-x sweeprolog-mode and get this error:

sweeprolog–ensure-module: Failed to locate ‘sweep-module’. Make sure SWI-Prolog is installed and up to dateError during redisplay: (jit-lock-function 1) signaled (error “Failed to locate ‘sweep-module’. Make sure SWI-Prolog is installed and up to date”)
Error during redisplay: (jit-lock-function 501) signaled (error “Failed to locate ‘sweep-module’. Make sure SWI-Prolog is installed and up to date”)

Does anyone have tips on how to troubleshoot this? I’m not sure where to look next.

Some version info:

$ uname -a
Linux biz 5.15.0-53-generic #59-Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ swipl --version
SWI-Prolog version 9.0.0 for x86_64-linux

$ emacs --version
GNU Emacs 27.1
Copyright (C) 2020 Free Software Foundation, Inc.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

$ ~/.emacs.d/bin/doom --version
GNU Emacs     v27.1            nil
Doom core     v3.0.0-dev       HEAD -> master, origin/master, origin/HEAD c44bc81a0 2022-08-19 11:24:34 +0200
Doom modules  v22.08.0-dev     HEAD -> master, origin/master, origin/HEAD c44bc81a0 2022-08-19 11:24:34 +0200

Copyright (c) 2014-2022 Henrik Lissner.

Doom Emacs uses the MIT license and is provided without warranty of
any kind. You may redistribute and modify copies if given proper
attribution. See the LICENSE file for details.

In emacs, if you eval (expand-file-name "" sweeprolog--directory) what does that give?

If you run swipl -q -g write_sweep_module_location -t halt $path_to_sweeppl_from_the_previous_step, what does that print?

Sweep works find for me on Ubuntu and Debian, with emacs 30.0.50, which is what I get by building from git://
Here is my (re)build recipe; I’ve found the latest version to be stable (but you might want to do git clean -dxf to be sure that everything gets rebuilt):

git pull --jobs=8 --recurse && \
./ && \
./configure --prefix=$HOME/.local --with-harfbuzz && \
make -j 8 bootstrap && \
make install

In the past, I’ve had to add --withgnutls=ifavailable to the “configure” (see apt install libgnutls28-dev)

Thanks for the detailed report.
The situation is not entirely clear, but based on what you describe I suspect that Emacs finds and uses an old swipl executable instead of the version 9.0.0 you have installed.

Does it work if you set sweeprolog-swipl-path to the full path of swipl version 9 prior to calling sweeprolog-mode?

I think I’m missing which variable you’ve described, is it exec-path?
Does (executable-find "swipl") give the expected path to the up-to-date swipl executable?

(expand-file-name "" sweeprolog--directory) gives


and the other one in the terminal:

$ swipl -q -g write_sweep_module_location -t halt $path_to_sweeppl_from_the_previous_step
V 1
L /home/bmaddy/.asdf/installs/swiprolog/9.0.0/lib/swipl/lib/x86_64-linux/
M /home/bmaddy/.asdf/installs/swiprolog/9.0.0/lib/swipl/lib/x86_64-linux/

$ swipl -q -g write_sweep_module_location -t halt /home/bmaddy/.emacs.d/.local/straight/build-27.1/sweeprolog/
ERROR: Prolog initialisation failed:
ERROR: source_sink `'/home/bmaddy/.emacs.d/.local/straight/build-27.1/sweeprolog/'' does not exist

$ ls /home/bmaddy/.emacs.d/.local/straight/build-27.1/sweeprolog/
sweeprolog-autoloads.el  sweeprolog.el  sweeprolog.elc

$ # I did find here
$ ls /home/bmaddy/.asdf/installs/swiprolog/9.0.0/packages/sweep/
CMakeFiles           CMakeLists.txt       LICENSE    sweep.c    sweep.html  sweeprolog.el        sweep.tex
cmake_install.cmake  CTestTestfile.cmake  Makefile  sweep.doc         sweeprolog-tests.el

Hmm, this seems like the sweeprolog installation you’ve got with straight.el is missing some files, namely it’s missing (and the manual, but that’s a secondary concern)… I’m not very familiar with straight.el but maybe you have some filter applied to the pulled files?

Thank for the info. I’d like to use a more recent version of Emacs, but unfortunately Doom Emacs doesn’t work with 29 or higher. I’ve tried things like spacemacs and manual configuration in the past, but have always run into issues with packages upgrading and breaking. That’s caused me to loose weeks of productivity on multiple occasions. I’m hoping Doom’s ability to roll back will save me from those issues (:crossed_fingers:). Because of that, I’m a little afraid to upgrade. I do appreciate the suggestion though.

Oh, yes, I also use straight: In the recipe, you need to make it include the .pl files; if you use use-package, something like this:

(use-package sweeprolog
  :defer t
  :commands (sweeprolog-mode)
  :straight (sweeprolog
             :type git
             :host nil
             :repo ""
             :branch "main"
             :files ("*.el" "")) ; this being the key thing
  :mode (("\\.pl\\'" . sweeprolog-mode)
         ("\\.plt\\'" . sweeprolog-mode))
  (setopt sweeprolog-swipl-path (expand-file-name "~/.local/bin/swipl")))
1 Like

Thanks to you and others for taking the time to look at this–I greatly appreciate it!

Yes, my mistake, the describe-variable was for exec-path.

Setting sweeprolog-swipl-path to /home/bmaddy/.asdf/installs/swiprolog/9.0.0/bin/ after requiring sweeprolog still resulted in the same error when calling sweeprolog-mode.

(executable-find "swipl") gives


I’m using asdf-vm to build prolog, so that’s just a shim that points to the right version. When I run M-x shell-command with asdf where swirpolog it reports the prolog it’s using as being here:


Using M-x shell-command to run swipl --version still gives

SWI-Prolog version 9.0.0 for x86_64-linux

Ah! That worked! Thank you so much @jamesnvc and @oskardrums!

1 Like

For anyone else running into this same issue, here’s the setup that I ended up using.

In .doom.d/packages.el:

(package! sweeprolog
  (:type git
   :host nil
   :repo ""
   :branch "main"
   :files ("*.el" "")))

In .doom.d/config.el:

(use-package! sweeprolog
  :mode (("\\.pl\\'" . sweeprolog-mode)
         ("\\.plt\\'" . sweeprolog-mode)))

I also copied /usr/share/applications/emacs27.desktop to ~/.local/share/applications/ and changed

Exec=emacs27 %F


Exec=env LD_PRELOAD=/home/bmaddy/.asdf/installs/swiprolog/9.0.0/lib/swipl/lib/x86_64-linux/ emacs27 %F

Thanks again everyone!

1 Like

I’ve pushed a small patch to check if is missing and if so provide a dedicated error message in sweeprolog--ensure-module. Hopefully that’ll make such issues easier to understand and resolve.

1 Like