[Top][All Lists]

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

Re: How to correctly load modules from runtime defineable locations?

From: Zelphir Kaltstahl
Subject: Re: How to correctly load modules from runtime defineable locations?
Date: Fri, 6 Mar 2020 12:53:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Icedove/60.9.0


I am not sure this will help you, but here is what I observed and what
works best for me:

  * For running Guile programs use: `guile -L <root dir of project>
    <path to scm file>`.
  * For using libraries:
      o If Guile is installed via GUIX, try to install the library
        through GUIX as well, then it should be available for Guile.
      o If Guile is installed via GUIX, but the library is not on GUIX
        or not in the version you would like, create a directory
        somewhere and set the Guile load path for that directory.
      o If Guile is built and installed by yourself also use Guile load
  * Modules need to be named the same as the directories they are in to
    be found:
      o To use (use-modules (some mymodule)) the module should be in a
        directory `some` and a file `mymodule.scm`.
      o To use (use-modules (some)), the module should be in a file
        named `some.scm`.

Perhaps the Guile load path varies on different systems?


On 06.03.20 06:22, Михаил Бахтерев wrote:
> 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
> 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]