Skip to content

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

@hllizi

Description

@hllizi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions