[Top][All Lists]

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

Re: The load path

From: Marius Vollmer
Subject: Re: The load path
Date: Fri, 05 Nov 2004 16:05:25 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

[ Andy, I discussed this with rlb on #guile, but I guess you weren't
  there at the time.  The below is a (subjectively filtered)

Andy Wingo <address@hidden> writes:

> First off, the load path for a guile in /usr/bin/guile doesn't
> include /usr/local.

Yes.  I am not sure whether it is good to single out /usr/local, tho.
There might be any number of directories that people could reasonable
expect to be in the load path, such as /opt/<package>/guile for a
Guile using <package>.

We do currently support "init.scm": This file gets executed at startup
immediately after boot-9.scm.  It is looked for in the load path.
That file is intended for site-specific initialization such as adding
/usr/local, /opt/<package> etc to the load path.

This does not address what should be in that file _by_default_.  In
fact, the Debian approach is to have a directory of init files that
all get executed in order, so that different packages can cleanly
deposit their own actions.

We think we should support this directly in Guile.  What about
executing this code at the end of boot-9.scm:

  (define (list-directory dir pattern)
    (let ((port (opendir dir))
          (regexp (make-regexp pattern)))
      (do ((entry (readdir port) (readdir port))
           (res '() (if (regexp-exec regexp entry) (cons entry res) res)))
          ((eof-object? entry) res))))

  (define (run-directory dir)
    (if (file-exists? dir)
        (for-each (lambda (f)
                    (load (string-append dir "/" f)))
                  (sort (list-directory dir ".*\\.scm$") string<?))))

  (run-directory (string-append (assq-ref %guile-build-info 'sysconfdir)
                                "/guile-" (effective-version)"

This will run every *.scm file in ${sysconfdir}/guile-1.x/init.d/ in
lexicographic order.

There can be additional rules about the contents of init.d/: Files
with names matching *site-local.scm are reserved for the site admin.
All filenames must start with at least two-digits, etc.

You could then add /usr/local to the load path from within init.d.

Packagers could do what is appropriate for their system by installing
a suitable file into init.d.  Etc.

Opinions, everyone?

> Secondly, guile's load path includes ".". This is unexpected. The set of
> includes should not depend on the working directory of the user.

Yes agreed, I have removed "." in HEAD.

reply via email to

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