[Top][All Lists]

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

Re: [Chicken-users] Module unresolved error

From: Mario Domenech Goulart
Subject: Re: [Chicken-users] Module unresolved error
Date: Tue, 14 Jun 2016 21:12:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Hi Michael,

On Tue, 14 Jun 2016 11:09:09 -0400 Michael Silver <address@hidden> wrote:

> I’m new to CHICKEN and I’m working on converting a large Guile
> codebase to CHICKEN.


> The codebase is a collection of shared libraries (each library in a
> separate .scm file), collectively known as “lab-core”. So, I’ve
> packaged it all as an egg called “lab-core” with each individual .scm
> file as it’s own module (under different names).  Does this seem like
> a reasonable way to package such a project?

Sounds good to me.

> As I go file by file converting to CHICKEN modules, I keep running
> into “module unresolved” errors when attempting to install my egg via
> chicken-install.

Usually you should see some warnings that may lead to "module
unresolved" errors.

When I try to compile your example, I get:

  Warning: reference to possibly unbound identifier `string-chomp' in:
  Warning:    port-puts
  Warning:    suggesting: `(import data-structures)'
  Warning: reference to possibly unbound identifier `with-output-to-string' in:
  Warning:    port-puts
  Warning:    suggesting: `(import ports)'

  Error: module unresolved: loglevel

That means:

* in `port-puts' you are using `string-chomp', which is exported by the
  data-structures module, but you are not importing it.

* in `port-puts' you are using `with-output-to-string', which is
  exported by the ports module, but you are not importing it.

So, all you need to do is:

$ diff -u loglevel.scm.orig loglevel.scm
--- loglevel.scm.orig   2016-06-14 21:08:03.547764310 +0200
+++ loglevel.scm        2016-06-14 21:08:13.711763790 +0200
@@ -1,6 +1,6 @@
 (module loglevel *
  (import chicken scheme)
  -(use srfi-1)
  +(use data-structures ports srfi-1)

 ;; Expected behavior:

> Unfortunately, the output gives no indication of which function is
> causing the error or why, and the only way I’ve been able to figure
> this out is by commenting out chunks of code and narrowing down until
> I find the offending function. If I delete that function, the module
> compiles perfectly and I can use the rest of the functions just as you
> would expect. What does "module unresolved” mean and is there a better
> way to figure out what is causing it?

Do you see the warnings in the compiler output?

> I’ve attached a MWE where loglevel is a stripped-down version of one
> such library causing the “module unresolved” error. Here are the steps
> to reproduce:
> $ cd lab-core
> lab-core$ chicken-install -debug
> (see attached output.txt for the debug output)
> Compare this to:
> $ csi
>> (load “loglevel-no-module.scm”)
>> (err-puts "foo" 42 "!”)
> foo42!
> “!"
> which shows my functions working perfectly as long as I’m not using
> module syntax.
> Why would compiling into a module cause an error when my functions
> work fine in the REPL? Any help would be appreciated.

That's because the interpreter implicitly loads some modules, and the
compiler doesn't do that.

All the best.

reply via email to

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