guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to correctly load modules from runtime defineable locations?


From: Михаил Бахтерев
Subject: How to correctly load modules from runtime defineable locations?
Date: Fri, 6 Mar 2020 10:22:19 +0500

Hello, Guile world.

I have got the following issue, when trying to understand, how the
Guiles modules system works.

1. I've wrote simple code

; check.scm
(setlocale LC_ALL "")

(let* ((fn (current-filename))                                               
       (dir (if (string? fn) (dirname fn) "."))                              
       (lib (if (string? fn) (string-append (dirname dir) "/lib") "../lib")))
  (add-to-load-path lib)                
  (add-to-load-path dir))

(display %load-path)
(newline)

(use-modules (json))

(scm->json #("hello" "world"))
(newline)

2. I have the following tree structure

$ find
.
./bin
./bin/check.scm
./lib
./lib/json
./lib/json/parser.scm
./lib/json/builder.scm
./lib/json.scm

These json files are taken from https://github.com/aconchillo/guile-json
intact.

3. I have Guile 2.2.6

4. In that environment i run

$ guile bin/check.scm 
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/news/bin/check.scm
;;; WARNING: compilation of /tmp/news/bin/check.scm failed:
;;; no code for module (json)
;;; compiling /tmp/news/lib/json.scm
;;; compiling /tmp/news/lib/json/builder.scm
;;; compiled 
/home/mob/.cache/guile/ccache/2.2-LE-8-3.A/tmp/news/lib/json/builder.scm.go
;;; compiling /tmp/news/lib/json/parser.scm
;;; compiled 
/home/mob/.cache/guile/ccache/2.2-LE-8-3.A/tmp/news/lib/json/parser.scm.go
;;; compiled /home/mob/.cache/guile/ccache/2.2-LE-8-3.A/tmp/news/lib/json.scm.go
(/tmp/news/bin /tmp/news/lib /usr/share/guile/2.2 /usr/share/guile/site/2.2 
/usr/share/guile/site /usr/share/guile)
["hello","world"]

My questions:

1. What does the message "no code for module" mean? It seems, that Guile
can find the code and compile it.

2. Why does the program work in some distributives (Arch, Debian) and
does not work in others (Ubuntu)? What is the difference, given the
Guile versions are the same?

3. What am i doing wrong? My intent is to have some freedom in library
placement, i do not want to use autoconf and automake for fixed paths.
Is it possible to solve this task with `add-to-load-path` or should i
use another technique?

-- MB, respectfully, with many thanks in advance.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]