read_source

Function read_source 

Source
pub fn read_source(path: &str) -> Result<String>
Expand description

Read a source file. Every file the system opens — the read-file primitive, the CLI’s file arguments and --purple boot script, the REPL’s :load — comes through here.

The path is tried as given: absolute, or relative to the process working directory. If that fails and the path is relative, it is retried under the directory named by the NARJU_LIB environment variable. Installed builds set NARJU_LIB to the directory holding their lib/*.naj copies, so the Purple boot resolves its libraries from any working directory while a user’s own relative paths keep taking precedence. On failure the error is the one from the path as given, so diagnostics name what the caller wrote.