Repository navigation
Keep installed FieldWorks independent of dev registry paths (LT-22840) - #1183
johnml1135 wants to merge 9 commits into
Conversation
Dev launches wrote per-user overrides that made installed FLEx load incompatible configuration from a worktree. Stop the code/data and ICU writes, and keep the launch registry preflight read-only. Ignore per-user source-tree code/data paths in installed directory lookup. Provide an explicit selective repair with a WhatIf preview, preserving ProjectsDir and overrides outside identifiable source trees. Verified failing lookup regressions before the fix, full FwUtilsTests, and registry repair/preflight checks on PowerShell 5.1 and 7.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1183 +/- ##
=======================================
Coverage 39.49% 39.49%
=======================================
Files 1537 1537
Lines 354392 354417 +25
Branches 41058 41064 +6
=======================================
+ Hits 139974 139985 +11
- Misses 185044 185056 +12
- Partials 29374 29376 +2
🚀 New features to boost your workflow:
|
Delete the setRegistryValues and setKeysInHKCU targets; nothing in the build calls them. They wrote ProjectsDir, SilEncConverters40, EncodingConverterRepository and the silfw:// handler into HKCU, which sent an installed FieldWorks to the dev tree. Dev code and data already resolve from the running tree, so no dev run needs those keys. ProjectsDirectory no longer persists when running from a source tree: the choice lasts for the process. The reader and Repair-DeveloperRegistry.ps1 now also drop a source-tree ProjectsDir. Tests cover both run orders, the no-persist rule and a static check that the build scripts write no registry keys. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
InitializeIcu now prefers the running source tree's ICU data, and ignores a registry Icu*DataDir that is missing or inside a source tree. A stale or foreign key can no longer redirect a dev build, or an installed one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ParatextLexiconPluginDirectoryFinder falls back to the machine value when the per-user code, data or projects path is inside a source tree. Convert.cs does the same for RootCodeDir, with a local check so it stays independent of the FieldWorks dlls. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Repair-DeveloperRegistry.ps1 now removes SilEncConverters40 values, the EncodingConverterRepository value and the silfw:// handler when they point into a source tree. The handler goes as a whole key and only through ShouldProcess. Installed values are kept. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ProjectsDirectory documents that a source-tree run keeps the value in memory and that null does not delete a real HKCU value. Convert.cs catches the path and security exceptions its source-tree check can raise. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Developers want the same projects in both builds, so ProjectsDir is no longer filtered by the source-tree rule in FwDirectoryFinder or the Paratext finder, and Repair-DeveloperRegistry.ps1 keeps it. A dev run still never writes it: the setter keeps the choice in memory. Root*, Icu* and the converter keys stay filtered. Tests now expect a source-tree ProjectsDir to be honoured by dev and installed runs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Restore the em dash and drop the stray blank line in launch-or-attach.md, note that the repair keeps ProjectsDir, and indent Resolve-FieldWorksDevRegistry.ps1 with tabs like other scripts. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Update: removed the unused |
Fixes LT-22840.
Problem
Developer tooling wrote per-user overrides under
HKCU\SOFTWARE\SIL:FieldWorks\9\RootCodeDir,RootDataDir,ProjectsDir,Icu<ver>DataDir, plus thesilfw://handler and theSilEncConverters40andEncodingConverterRepositorykeys. The installed app reads HKCU before HKLM, so an installed FLEx could load code, data and ICU from a dev worktree. Installed 9.3.10 then failed to createAiAnalysisExportListenerwhile the Hermit Crab trace fix was being validated, andsilfw://links launched the dev exe.Design
Rule: a dev run never writes shared (HKCU) state, and a run never trusts a leftover HKCU path that points into a source tree.
A run is a "dev run" when
FwDirectoryFinder.FindDevDistFilesfinds aDistFilesfolder with aFieldWorks.slnin an ancestor of the running assembly (already on main since #1093). Otherwise it is installed. A "source-tree path" is a path under a directory that containsFieldWorks.sln(FwDirectoryFinder.IsSourceTreePath).Precedence (first match wins):
DistFiles> HKCU > HKLM > defaultICU_DATAenv > running tree'sDistFiles\Icu<ver>> HKCU > HKLMICU_DATAenv > HKCU > HKLM; a registry dir that does not exist or is a source-tree path is skippedProjectsDir> HKLM ><DataDir>\ProjectsProjectsDir> HKLM ><DataDir>\ProjectsProjects are deliberately shared between dev and installed runs so developers see the same projects.
ProjectsDiris NOT filtered by the source-tree rule. The only change is write side: a dev run keeps a projects-folder change in memory only (ProjectsDirectorysetter) and never writes or deletes HKCU. An installed run still persists it as before.What changed:
setRegistryValues/setKeysInHKCUMSBuild targets (no callers in the repo) are deleted; the test initializer no longer writesRootCodeDir/RootDataDir; the launch-preflight skill scriptResolve-FieldWorksDevRegistry.ps1is now read-only, also with-Force(it just runs the repair script with-WhatIf).FwDirectoryFinder.GetDirectoryand the Paratext plugin finder skip HKCURootCodeDir/RootDataDirunder a source tree and fall back to HKLM/default;Convert.csignores a source-tree v8RootCodeDir;FwUtils.InitializeIcugoes throughChooseIcuDataDirand ignores a missing or source-treeIcu*DataDir. The dev ICU probe now also requiresFieldWorks.sln.Production vs dev-only impact
Production (installed) code paths changed: the source-tree filters (no effect unless an installed FLEx sits beside a
FieldWorks.sln), skipping a nonexistent registry ICU directory inInitializeIcu(previously setICU_DATAto a missing folder), and theConvert.csv8RootCodeDircheck, which also catches path exceptions. Everything else is dev-only (build targets, test initializer, skill scripts, and the in-memory projects setter, which is active only in a source-tree run).Repair script (
Build/Repair-DeveloperRegistry.ps1)Removes existing HKCU values that point into a source tree:
RootCodeDir,RootDataDir,Icu*DataDir,SilEncConverters40\RootDir/DeveloperPluginDir,EncodingConverterRepository\Registry, and thesilfwhandler key if its exe is in a source tree. It keeps values outside source trees and keepsProjectsDir, which dev and installed runs share.Supports
-WhatIf/-Confirm. It cannot identify a checkout whoseFieldWorks.slnwas deleted or moved.Gotchas
FieldWorks.slnremoved is not recognised as a source tree.ProjectsDirpointing into a worktree; installed FLEx follows it, as before.Tests
FwDirectoryFinderTests(dummy registry): reader fallback matrix including a tree with noDistFiles; non-source user override wins; test initializer writes nothing;ProjectsDirectoryset from a source-tree run does not persist; both run orders (dev then installed, installed then dev); a text scan checks the build scripts write no registry keys; a source-tree HKCUProjectsDiris honoured by both dev and installed runs.IcuDataDirChoiceTests: tree first, missing/source-tree keys skipped, HKLM fallback.ParatextLexiconPluginDirectoryFinderTests: code/data fallback, source-treeProjectsDirhonoured, installed values win; on a temporary HKCU subkey, deleted in TearDown.Build/Repair-DeveloperRegistry.Tests.ps1: 22 checks (keepsProjectsDir) on PowerShell 5.1 and 7 (mocked registry): selective cleanup, preview, malformed/non-source values, missing keys, silfw/EC keys, read-only preflight.Manual verification
RootCodeDir/RootDataDir/Icu<ver>DataDirwith worktree paths, run-WhatIf(it lists them), run it for real, then launch installed FLEx; it loads from Program Files and your projects list is unchanged.HKCU\SOFTWARE\SIL, launchOutput\Debug\FieldWorks.exefrom two worktrees; each uses its ownDistFilesand ICU, and the HKCU snapshot diff is empty (including after changing the projects folder in the dev run).This change is