Repository navigation
fix: resolve file names against *home-directory*; per-user kernel cache (#86, #87) - #89
Merged
Merged
Conversation
open, read-file, read-file-as-string, read-file-as-bytelist and the fasl load wrapper passed relative names straight to io.open, so after (cd Dir) they still read from the process cwd. They now prepend *home-directory* (set by cd) to non-absolute names, as the kernel's open contract and shen-go/shen-scheme do. The native fast paths share one resolver (P.home_path) with open, so they can no longer pick up a same-named file in the cwd that open would not. Fixes #86 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With SHEN_KERNEL_CACHE unset, cache_path() returned the relative
".shen-kernel-cache.<build>.bin", so every directory shen ran from got a
~1.8 MB cache plus its .stlib sidecar and recompiled the kernel. The
default is now ${XDG_CACHE_HOME:-$HOME/.cache}/shen-lua/kernel-<build>.bin;
the directory is created on the first write, and an unwritable location
skips caching as before. SHEN_KERNEL_CACHE=<path>|off is unchanged.
The cleanup of the pre-per-build ".shen-kernel-cache.bin" in the cwd only
ran for the old relative default, so it is removed with it.
Fixes #87
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 18, 2026
…me does (#86) shen-scheme and shen-go join *home-directory* and the file name as plain strings, so after a non-empty cd an absolute name is joined as well. Match that instead of passing absolute names through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two low-risk fixes from the capcov cross-port run, one commit each.
Fixes #86
Fixes #87
#86: relative file names resolve against
*home-directory*(82afe27)(cd Dir)sets*home-directory*(sys.kl:164), butopenand the native fast paths forread-file,read-file-as-string,read-file-as-bytelistand the faslloadwrapper passed relative names straight toio.open, so they still read from the process cwd.P.home_path(name)inprims.luaprepends*home-directory*to every name, as a plain string join.openand all four fast paths use it. The fast paths therefore can no longer open a same-named file in the cwd thatopenwould not.loadwrapper (boot.lua) reads and records the resolved path.*home-directory*is prepended unconditionally, matching shen-scheme d037ae6 and shen-go 1f587de. After(cd "/a"),(read-file "/b/x.shen")opens/a//b/x.shenand fails, as on both of them.#87: kernel cache moves to the per-user cache dir (7ad7ae4)
When
SHEN_KERNEL_CACHEwas unset,cache_path()returned the relative.shen-kernel-cache.<build>.bin. Every directoryshenran from got about 1.8 MB of cache plus the.stlibsidecar, and recompiled the kernel.${XDG_CACHE_HOME:-$HOME/.cache}/shen-lua/kernel-<build>.bin, with the sidecar next to it. The directory is created on first write (open_for_write).XDG_CACHE_HOMEnorHOMEis set, there is no cache.SHEN_KERNEL_CACHE=<path>|offis unchanged. The fasl default (~/.cache/shen-lua-fasl,SHEN_FASL_DIR) is untouched../.shen-kernel-cache.binonly ran for the relative default, so it was removed along with it. Stale.shen-kernel-cache.*files in project dirs are gitignored and can be deleted.Tests
Base is e3dec8b (main) and head is 7ad7ae4. Commands:
Both were run with
GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILEunset, a privateTMPDIRand a privateXDG_CACHE_HOME.make testmake certify(43.1 suite)TOTAL: 1210 pass, 0 fail across 23 specspassed ... 154/failed ... 0TOTAL: 1225 pass, 0 fail across 23 specspassed ... 154/failed ... 0New checks (15):
test/io_spec.lua(+7).cd, then each ofread-file,read-file-as-string,read-file-as-bytelist,openandload, with a decoy file of the same name in the cwd. Also an absolute name aftercd(joined, so it fails as on shen-scheme), and(cd "")restoring cwd resolution. On base the spec dies at the firstopen(open: cannot open ...).test/boot_cache_spec.lua(+8). Boot in an empty cwd withSHEN_KERNEL_CACHEunset: nothing lands in the cwd, the cache and sidecar land in$XDG_CACHE_HOME/shen-lua, else$HOME/.cache/shen-lua, a warm boot works, and an unwritable dir still boots. On base, 4 of these fail (got .shen-kernel-cache.bdd98551.bin .shen-kernel-cache.bdd98551.bin.stlib).Repros from the issues, at head:
Cross-port check (capcov workloads)
Payloads were extracted with capcov's
bench.pypayload filter and compared byte for byte with shen-go 1f587de (kernel 42.2).f-modelcheckdoes(cd ".../model/")and then(read-file "shen/load.shen").shen: open: cannot open shen/load.shen (shen/load.shen: No such file or directory).sha256 93ccb82e6c2849e0…, all 25MClines).b-typed,c-untyped,d-g5,a2-libs-typed,e-draftandf-modelcheckon a local merge of this PR with the Generated Lua exceeds LuaJIT's 200-locals limit: datatype rules with nested conclusion patterns, list literals with 200+ elements #84/Reader fails on list literals over ~1550 elements with a misleadingreader error near here:(suspected Lua stack overflow) #88 and Native Prolog engine overflows the Lua stack on modest typecheck depth (~400), where the legacy engine reaches about 1000 and shen-go has no limit #85 PRs. All six are identical to shen-go 1f587de, so there are no kernel 43.1 vs 42.2 differences to classify.🤖 Generated with Claude Code