Page: repo paths are found at runtime
Job: explanation
Level: mid grug (level 2 of 6)
Source lines:
SageFs.Core/RepoPaths.fs:257#repoPathFullSageFs.Core/RepoPaths.fs:251#Array.fold
repo paths are found at runtime
this page says why the code has this shape and what a reader must be careful of.
why this exists
A SageFs checkout can live anywhere. A path baked in at build time would point at wherever the assembly was built. resolves a full path from the root found at runtime, and SageFs.Core/RepoPaths.fs:257#repoPathFull joins each segment onto that root in one place.SageFs.Core/RepoPaths.fs:251#Array.fold
run grep -n 'let repoPath' SageFs.Core/RepoPaths.fs
It prints:
250:let repoPath ([<ParamArray>] segments: string array) : string =
257:let repoPathFull ([<ParamArray>] segments: string array) : string =
The cited file SageFs.Core/RepoPaths.fs ships with this site at the same path. Run the command from the school folder, or open SageFs.Core/RepoPaths.fs.
what breaks
A caller that joins paths by hand can point at the source tree of another checkout or at a folder that only existed on the build machine. Tests that move the working directory would then read a stale tree.
where it fits
Repo paths gives every reader of repository files the same root. Live test routing uses session roots for a different job: choosing which session owns a changed file.
try it
Run the grep above from this repository root. Then move a checkout and ask the session where its repository is. The answer follows the assembly, not the compiler.
reference: every connection to this page
This is reference. The next page in the reading order is at the bottom of the page.
goes on to: a changed file belongs to a session root, the host checks text before it runs
flowchart LR H["you are here: repo paths are found at runtime"] B0["a changed file belongs to a session root"] B1["the host checks text before it runs"] H --> B0 H --> B1
grill: say it out loud, then tap
Grug asks. Say the answer out loud, then tap. Grug remembers what you miss and asks again in the pop quiz.
a badge says two things: the number is its level, the colour is the kind of answer it asks for. The six levels are level 1 of 6 recall a fact; level 2 of 6 recall a detail; level 3 of 6 trace a path; level 4 of 6 trace a longer path; level 5 of 6 predict or judge; level 6 of 6 judge a transfer. Colour and level are independent: a high-level question can still ask for a fact, and the colour tells you which it is.
try first, then show answer
2. The root walked from the assembly location at runtime
The assembly location is read at runtime, so a checkout moved after the build still resolves to its own files.
try first, then show answer
1. A checkout can live anywhere, so no absolute path is shipped
No absolute checkout path is shipped, so the engine has to find the root from where the code now runs.
try first, then show answer
3. repoPath with segments
One path builder keeps separator handling and root resolution in a single reviewed place.
try first, then show answer
repoPath
The function named repoPath folds the segments onto the root returned by requireRepoRoot.