# Importing define-modules with unbound variable error

**URL:** <https://forum.systemcrafters.net/t/importing-define-modules-with-unbound-variable-error/1228>\
**Category:** Programming\
**Tags:** guile, scheme\
**Created:** [December 22, 2024, 4:11pm UTC](https://forum.systemcrafters.net/t/importing-define-modules-with-unbound-variable-error/1228 "2024-12-22T16:11:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbrins](https://avatars.discourse-cdn.com/v4/letter/r/e68b1a/32.png) [@rbrins](https://forum.systemcrafters.net/u/rbrins)\
**Post date:** [December 22, 2024, 4:11pm UTC](https://forum.systemcrafters.net/t/importing-define-modules-with-unbound-variable-error/1228/1 "2024-12-22T16:11:01Z")

</div>

Currently working on creating a guile program that has a few modules defined using `(define-module (progname mod1))` these are the in `./progname` directory. My main program in the root directory is simply called `./progname`. I’m following the examples I see for multiple guile projects here like Haunt, Guile-zlib, Hoot.

In the main project where I called

```auto
(use-modules (progname mod1)
             (progname mod2)

```

I get `ERROR: In procedure %resolve-variable: Unbound variable: mod2procedure`.

I’ve tried adding `(add-to-load-path "/path/to/progname/")` and variations to the directory with no success. Also, when I run the code from the scheme all in one file it works correctly, and when I manually run the load-path above in a Guile REPL, the program works as well.

Any thoughts on how to get the modules known to the main program?

---

<div class="post-metadata">

**Author:** ![noahevans](https://avatars.discourse-cdn.com/v4/letter/n/f05b48/32.png) [@noahevans](https://forum.systemcrafters.net/u/noahevans)\
**Post date:** [December 22, 2024, 8:36pm UTC](https://forum.systemcrafters.net/t/importing-define-modules-with-unbound-variable-error/1228/2 "2024-12-22T20:36:11Z")

</div>

As far as I know you need to have progname in guile load path. When you install the program it should go in /usr/share/guile/site/3.0/progname and then it will automatically be in the loadpath.

When developing i usually interact with my programs through emacs geiser, so i use .dir-locals to set geiser-guile-load-path. If your program has a main entry point you could also make a bash script that exports GUILE\_LOAD\_PATH and then run guile progname/main.scm.

---

<div class="post-metadata">

**Author:** ![mirkoh](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@mirkoh](https://forum.systemcrafters.net/u/mirkoh)\
**Post date:** [December 23, 2024, 6:19pm UTC](https://forum.systemcrafters.net/t/importing-define-modules-with-unbound-variable-error/1228/3 "2024-12-23T18:19:33Z")

</div>

My guess Is that the load-path needs to be the root directory of your libraries so it should be `(add-to-load-path "/path/to")` if you want to use `(progname mod1)` .
