Repository navigation
Description
Goal: plan, check and execute refuse a --work-dir that is a symlink round a loop in words that name the loop, and not "(File exists)", which reads as a file in the way.
Filed by lane openRepoShape-1 from the work on #903 (PR #963), which left L1-67's second nit of #457 alone, as its review (r903) asked for it to stay tracked. The refusal is right (exit 2, adopt-work-dir-unwritable, nothing made); the reason is the part that does not say what is wrong. Line numbers are at 9e6ed9bb, the head of #963.
The reason. _work_root (adopt-project.py:14825) makes the directory with _made_0755(root), and a failing os.mkdir becomes (:14864) "--work-dir <path> cannot be made: making it a directory failed ()". A symlink that leads to itself fails os.mkdir with EEXIST, so the reason is File exists, the words a plain file in the way gets. The person is told a file is there, and finds a link.
Measured, the same on 50178305 (v1.1.1), 11a60b71 and 9e6ed9bb. Probe setup: a stub gh first on PATH that exits 1, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, GIT_CONFIG_GLOBAL=/dev/null, GIT_SSH_COMMAND=false, and a link to itself, made with ln -s <W> <W>. Then, for --source testorg/Thing and for a local source:
plan --source testorg/Thing --project Thing --org testorg --elected-by "Test Human" --elected-on 2026-09-02 --out <plan.yaml> --work-dir <W>
REFUSED adopt-work-dir-unwritable: --work-dir `<W>` cannot be made: making it a directory failed (File exists)
Remediation: Pass a --work-dir this user can write in, or none: without one, each run makes a new one.
Exit 2 for each of the four runs (base and head, org/repo and local), with no traceback. The remedy is written for a folder this user cannot write in, and says nothing of a link.
The fix:
- Where
os.mkdirfails withEEXISTand the--work-diras typed is a symlink that does not lead to a directory (os.path.islinkis true andos.path.isdiris false), the reason says so: "it is a symbolic link that leads round a loop". The code staysadopt-work-dir-unwritable, and the remedy says to remove or mend the link, besides passing another--work-dir. tests/test_adopt_work_dir_refusal.py::test_a_work_dir_that_is_a_symlink_loop_is_refused(:156) builds the loop and assertsmkdir_says(work)(:109), the machine's own error, so it holds "(File exists)" as it is. It should hold the new words, forplan,checkandexecute; a file in the way keepsFile exists, which is right for it.- Not in this issue: the order of
plan's refusals, which is adopt-project.pyplan: refusals that need only the flags come after the work directory, the source's git reads andgh repo clone#903's.
A dangling link never reaches this branch: _work_root takes os.path.realpath and makes the target (r903, measured for a link to a missing target-a and to missing-dir/target-b: both runs exited 0 and made the target).
- Comment wording in adopt-project.py:
planasks the leg-path, pin, date and value refusals of its flags, and anorg/reposource's own name and derived id, before the work directory, git's reads of the source andgh repo clone, and says why it cannot clone into a--work-dirnobody can write in (#903) #963's code (r903's round-2 NITs a-c, at9e6ed9bb, adopt-project.py:planasks the leg-path, pin, date and value refusals of its flags, and anorg/reposource's own name and derived id, before the work directory, git's reads of the source andgh repo clone, and says why it cannot clone into a--work-dirnobody can write in (#903) #963 issuecomment-6253937080):- (a)
adopt-project.py:4691and:5470-5471, andtests/test_adopt_plan_flag_refusals_first.py:30and:239, saygit check-ref-formatruns "in a throwaway repository"._ask_git_branchpasses an empty temporary directory as--git-dir, which is never a repository. Say "with an empty temporary directory as its--git-dir, which it removes". - (b)
adopt-project.py:4676and the test's:37list the refusals still after the source as if the list were complete. Add "among them": a--projectof 251 to 255 characters is refusedunsafe-valueafter git's reads. - (c)
adopt-project.py:4679, "with a remedy about the source": add "where it names a repository".
- (a)
Filed in v1.2.0 as #903's follow-up (#963); lane 3, the release owner, may place it otherwise.
Activity
adopt-project.py: `plan` asks the leg-path, pin, date and value refus…
brettheap commentedon Oct 20, 2026
CLAIMED — lane openRepoShape-1, session 300f8f46-004a-4e72-8587-4f192be2e108@Eagle, 2026-10-20T10:45:28Z, for #978
Logged in
lanes/log/openRepoShape-1.mdata256e5367d8dd63062c17f8872e91fa7bc08b6d1.The three reads (lane-collision-protocol Rule 1):
tests/test_adopt_clone_claimed.py: a `--work-dir` under a symlink loo…