Skip to content

fix(load): name the file and the OS cause when a script cannot be loaded - #508

Merged
singaraiona merged 3 commits into
devfrom
fix/load-error-path
Sep 10, 2026
Merged

singaraiona merged 3 commits into
devfrom
fix/load-error-path

Conversation

@singaraiona

Copy link
Copy Markdown
Collaborator

Summary

load returned a bare io on any failure, so a missing dependency in a startup script printed error: io, indistinguishable from an IPC, journal or storage failure. Every failing step now names the file and the OS cause:

error: io: load "missing/persistent_connection.rfl": No such file or directory
error: io: load "/tmp/x": is a directory
error: io: load "big.rfl": cannot map 123 bytes: Cannot allocate memory

Both the mmap branch and the Windows fread branch. Source file/line and the load chain, which the issue lists as ideal, are not included: the parser's nfo already attributes eval errors inside the loaded file to it, and a load-chain trace is a separate change.

Test

test/rfl/system/load_errors.rfl: the codes in-process, and the exact lines on a subprocess's stderr for a missing file and a directory, plus the non-zero exit of the failing script.

Closes #505

https://claude.ai/code/session_01J4QKJW3RbRP8TQoquJtARg

ray_load_file_fn returned a bare `io` for every failure — open, stat,
map — so a missing dependency in a startup script printed `error: io`,
which reads like an IPC, journal or storage failure and sends diagnosis
the wrong way.  Each failure now says which step failed on which file
and why: `error: io: load "missing/x.rfl": No such file or directory`,
`... : is a directory`, `... : cannot map N bytes: ...`.  Both the mmap
and the Windows fread branches.

Closes #505

Claude-Session: https://claude.ai/code/session_01J4QKJW3RbRP8TQoquJtARg
…n .sys.args

`load` resolved a relative path against the working directory only, so
a script invoked from its project root and from its own directory could
not both find a shared file, and piped or heredoc input — which has no
file of its own — had no anchor at all.  q answers this with QHOME.

A relative load path is now tried against the working directory first
and, when that does not exist and RAYFORCE_HOME is set, below the home;
an absolute path is used as given; nested loads follow the same rule
(relative to the working directory, not to the loading file, as q).  A
failure names every path tried.  The command-line script itself is not
subject to the fallback.

(.sys.args) gains `source`: the file currently being evaluated — the
innermost load, or the command-line script — by the path that was
actually opened, so a script can locate its neighbours from any working
directory; empty at the REPL, under a pipe, or in a hook or timer
outside any file.  `file` is the command line's script ($0); `source`
follows nested loads ($BASH_SOURCE).  The REPL's pseudo-file name is
now a shared constant so `source` can recognise it.

Closes #506

Claude-Session: https://claude.ai/code/session_01J4QKJW3RbRP8TQoquJtARg
feat(load): RAYFORCE_HOME fallback for relative paths, and source in .sys.args
@singaraiona
singaraiona merged commit 0e39bd8 into dev Sep 10, 2026
9 checks passed
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

Successfully merging this pull request may close these issues.

load file failures report only error: io, without path or OS cause

1 participant