[Repo Assist] fix: auto-detect DOTNET_ROOT from symlink-resolved dotnet binary path#2163
Draft
github-actions[bot] wants to merge 2 commits into
Draft
Conversation
…Closes #2122) When neither DOTNET_ROOT nor FSharp.dotnetRoot is configured, resolve the dotnet binary path through symlinks (using Node's fs.realpathSync) and set DOTNET_ROOT to the parent directory of the real binary. This only triggers when the resolved path differs from the input, i.e. when dotnet is accessed via a symlink — the typical case on Ubuntu where the system package installs to /usr/lib/dotnet/dotnet but the PATH entry /usr/bin/dotnet is a symlink. Priority order for DOTNET_ROOT: 1. Already set in process environment — leave untouched 2. FSharp.dotnetRoot setting configured explicitly — propagate as-is 3. dotnet binary path resolves through a symlink — use dirname(realpath) 4. dotnet binary path is not a symlink — do not override (FSAC handles) Without this fix FSAC falls back to its hard-coded /usr/share/dotnet default, which does not exist on Ubuntu, causing VSTestWrapper to throw and test discovery to fail entirely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #2122
Problem
On Ubuntu (and other distributions where dotnet is installed via system packages), the dotnet binary is accessed through a symlink:
When
FSharp.dotnetRootis not configured andDOTNET_ROOTis not set in the environment, FSAC falls back to its hard-coded default of/usr/share/dotnet(the Microsoft install location). This path does not exist on Ubuntu, soVSTestWrapper.tryFindVsTestFromDotnetRootthrows aWin32Exceptionand test discovery fails entirely — even thoughdotnetis perfectly available onPATH.The workaround (manually setting
FSharp.dotnetRootto/usr/lib/dotnet) works but should not be necessary.Fix
After resolving the dotnet binary path that was already detected via
which dotnet, we call Node'sfs.realpathSyncto follow any symlinks. If the resolved path differs from the original (i.e. dotnet was a symlink), we setDOTNET_ROOTto the parent directory of the real binary before launching FSAC.Priority order for
DOTNET_ROOTpropagation:FSharp.dotnetRootconfigured → propagate that value unchangedDOTNET_ROOT = dirname(realpathSync(dotnet))The symlink-only condition (point 3) avoids incorrectly setting
DOTNET_ROOTto a generic bin directory (e.g./usr/bin) on systems where dotnet is not installed via a symlink.Trade-offs
realpathSynccall is synchronous and fast (single syscall), adding negligible overhead during FSAC startup.try/withguard ensures that ifrealpathSyncthrows for any reason, we fall back gracefully.FSharp.dotnetRootis not explicitly configured. If [Repo Assist] Fix: propagate FSharp.dotnetRoot as DOTNET_ROOT environment variable to FSAC #2136 is merged first, this PR will conflict on the adjacent lines and will need a minor rebase.Test Status
Full compilation requires the full Fable + webpack toolchain (network not available in this environment). The change uses only existing Node.js APIs (
fs.realpathSync,path.dirname) and theemitJsExprFable utility already used elsewhere in the codebase. Fantomas formatting check: ✅ passed.Platform coverage: The fix is conditional on
resolvedDotnet <> dotnetso it is a no-op on macOS and Windows where dotnet is not accessed via symlinks, and only activates on Linux distributions where it is needed.