Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_module/1 doesn't respect changes in current working directory if executed as initialization goal #2560

Open
hurufu opened this issue Sep 19, 2024 · 0 comments

Comments

@hurufu
Copy link
Contributor

hurufu commented Sep 19, 2024

As in title. I found it when I tried to use modules from a different folder for #2435.

Contents of ~/.scryerrc:

:- use_module(library(iso_ext)).
:- use_module(library(files)).
:- use_module(library(lists)).
:- use_module(library(os)).

use_custom_modules(Ms) :-
    getenv("SCRYER_LIBRARY_PATH", LD),
    setup_call_cleanup(
        working_directory(WD, LD),
        maplist(use_module, Ms),
        working_directory(_, WD)
    ).

Put some dummy module foo.pl into $SCRYER_LIBRARY_PATH:

:- module(foo, []).

Put user.pl file into any folder different from $SCRYER_LIBRARY_PATH for example to /tmp. Contents of user.pl:

:- initialization(use_custom_module([foo]))

Make sure that $SCRYER_LIBRARY_PATH is exported and run Scryer:

# echo $SCRYER_LIBRARY_PATH 
/home/hurufu/Projects/prolog-utils
# pwd
/tmp
# scryer-prolog user.pl 
   error(existence_error(source_sink,"/tmp/foo.pl"),open/4).
?- use_custom_modules([foo]).
   true.

As you see if I execute use_custom_modules/1 from the top level – it works ok, but it throws an exception if it is called during initialization. I would expect initialization goal to succeed and it should use the correct path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant