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

Interpreter doesn't find file to execute after loading a file that uses with-cwd #48

Open
hllizi opened this issue Nov 15, 2023 · 0 comments

Comments

@hllizi
Copy link

hllizi commented Nov 15, 2023

Using with-cwd somehow messes up the way the interpreter looks for the file to be executed if the interpreter is started via a shebang sequence and with-cwd is employed in a file that is loaded with "-l" or "-lm". (I am using Scheme 48, btw)

Minimal (non)working example:

lib.scm:

(with-cwd "/tmp"
          (for-each display
                    (directory-files)))

main.scm:

#! /nix/store/3x6dm1pp2m2pb104agz0r8fzcms13wam-scsh-0.7pre/bin/scsh \
-l lib.scm -s
!#

(display "I got here!")

The result when both files are put in the same directory and main.scm ist executed is:

  • The contents of /tmp are printed
  • The following error is printed instead of the expected "I got here!"
error: No such file or directory [open-input-file]
       "./main.scm"
       #{&i/o-error}

A hackish solution to the problem is to put (chdir ".") at the end of lib.scm. Then "I got here!" will get to be printed.

The same problem exists when Scheme 48 modules are used and with-cmd is used in the definitions.

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