Open fedeinthemix opened 8 years ago
Sounds like both the source and object files for the library are in the search path defined by library-directories
, and Chez Scheme is attempting to verify that the source is not newer than the compiled object file (as described in section 2.4 of the User's Guide). You don't need to install any source once you have compiled object files.
On Sat, Aug 20, 2016 at 5:20 PM, Jamie Taylor notifications@github.com wrote:
Sounds like both the source and object files for the library are in the search path defined by library-directories, and Chez Scheme is attempting to verify that the source is not newer than the compiled object file (as described in section 2.4 of the User's Guide).
I've read the user guide and that's my understanding as well, but I'm wondering why it says that it can't find the file.
You don't need to install any source once you have compiled object files.
I know that I don't need to, but I want to install the source to allow peoples to easily see the implementation of the program. I could install the source somewhere else, but I would like to understand why what I'm doing doesn't work.
I played around with this a bit and discovered that it didn't behave quite like I expected. I'm not sure why it doesn't find a relative path when library-directories
contains a location for the source... but I think you can get the results you want if you define only the object portion of the source/object pair for that path entry, like so:
CHEZSCHEMELIBDIRS=::/usr/local/lib/csv9.4-site:
Thanks for the suggested workaround. I can confirm that with it I can load the library without errors. What's still undesirable is that 'inspect' can't find the source file.
On Sun, Aug 21, 2016 at 2:32 AM, Jamie Taylor notifications@github.com wrote:
I played around with this a bit and discovered that it didn't behave quite like I expected. I'm not sure why it doesn't find a relative path when library-directories contains a location for the source... but I think you can get the results you want if you define only the object portion of the source/object pair for that path entry, like so: CHEZSCHEMELIBDIRS=::/usr/local/lib/csv9.4-site:
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cisco/ChezScheme/issues/97#issuecomment-241231844, or mute the thread https://github.com/notifications/unsubscribe-auth/AHUKsqY3418BYW2YY-_DrOMJrMw1dJocks5qh5ydgaJpZM4JpEud .
Remove the ./
from the path in include
. Using it apparently prevents the normal path searching behavior (according to the documentation for with-source-path
).
I tired that, but I get a similar error:
Exception in include: file "kernel/types.scm" not found in source directories
On Mon, Aug 22, 2016 at 7:08 PM, Jamie Taylor notifications@github.com wrote:
Remove the ./ from the path in include. Using it apparently prevents the normal path searching behavior (according to the documentation for with-source-path).
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cisco/ChezScheme/issues/97#issuecomment-241481021, or mute the thread https://github.com/notifications/unsubscribe-auth/AHUKsuDTWXd9abJ7WODhRRpdqbRTe_K6ks5qidd6gaJpZM4JpEud .
I tested this on my system - 3.16.0-4-amd64 x86_64 GNU/Linux - and can't reproduce the issue.
My setup:
CHEZSCHEMELIBDIRS=/home/me/code/scheme/chezscheme/external-libraries library file path = /home/me/code/scheme/chezscheme/external-libraries/lib-a.sls path of types.scm = /home/me/code/scheme/chezscheme/external-libraries/kernel/types.scm
Content of lib-a.sls:
(library (lib-a) (export up) (import (chezscheme)) (include "kernel/types.scm"))
Content of types.scm:
(define up "Variable up imported.")
Importing library lib-a and using up in the repl:
> (import (lib-a))
> up
-> "Variable up imported."'
Tested also compiling lib-a.sls and types.scm with compile-file somewhere else and then moved the files to "/home/me/code/scheme/chezscheme/external-libraries". Works as expected also with both the source files and the compiled files in the library directory specified with CHEZSCHEMELIBDIRS.
Using 'inspect' also works:
> (import (lib-a)))
> (inspect up)
> "Variable up imported" :
> "Variable up imported" : file kernel/types.scm
> "Variable up imported" : list
1: (define up "Variable up imported.")
*** end of file ***
If you compile lib-a and move it to another directory without moving also types.scm or types.so to the right directory or modifying source-directories, you will get an exception:
Exception in include: file "kernel/types.scm" not found in source directories
This is because the default value of source-directories is ("."), which means "source files will be found only in or relative to the current directory, unless named with an absolute path" to quote the documentation.
For example, if you compile lib-a.sls and move just the object file lib-a.so to "/usr/local/lib/csv9.4-site" without moving types.scm or types.so to "/usr/local/lib/csv9.4-site/kernel" you will get an exception. If you don't want to move types.scm you must add the path to kernel/types.scm to the source-dirctories. Create a "schemerc" file and use it to modify the source-directories.
For example the content of the schemerc file is:
(source-directories '("." "/location/of/types"))
Now include will look in the current directory of the library lib-a and in "/location/of/types". The location of the file types.scm must be "/location/of/types/kernel/types.scm". Now you start chezscheme with scheme schemerc
and import lib-a.
Another option is to make types.scm a library and add it to your library-directories with
scheme --libdirs "/usr/local/lib/csv9.4-site:/location/of/types"
or CHEZSCHEMELIBDIRS.
I have a problem with a library making use of 'include'. Consider the following toy example, where the file "./kernel/types.scm" defines the variable 'up'
I compile the library with
(compile-library "./lib-a.sls")
, install it in a system directory, say "/usr/local/lib/csv9.4-site" and define the environment variableAt this point I can start Chez Scheme and use the library.
However, if I also install the source file "./kernel/types.scm" in "/usr/local/lib/csv9.4-site/kernel/types.scm", when I try to import the library, I get an error of type
Exception in file-modification-time: failed for "./kernel/types.scm": no such file or directory
unless I set the parameter 'source-directories' to include "/usr/local/lib/csv9.4-site", or I 'cd' to that directory.
My questions are:
Currently, to work around this, I first install the source files in the final location, change the relative paths to absolute ones and compile the library. However, this is more complicated than desired.
Thanks for any advice.