Skip to content

[Repo Assist] fix: auto-detect DOTNET_ROOT from symlink-resolved dotnet binary path#2163

Draft
github-actions[bot] wants to merge 2 commits into
mainfrom
repo-assist/fix-dotnet-root-auto-detect-2122-f3bb03b87a6af54c
Draft

[Repo Assist] fix: auto-detect DOTNET_ROOT from symlink-resolved dotnet binary path#2163
github-actions[bot] wants to merge 2 commits into
mainfrom
repo-assist/fix-dotnet-root-auto-detect-2122-f3bb03b87a6af54c

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 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:

/usr/bin/dotnet  →  /usr/lib/dotnet/dotnet

When FSharp.dotnetRoot is not configured and DOTNET_ROOT is 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, so VSTestWrapper.tryFindVsTestFromDotnetRoot throws a Win32Exception and test discovery fails entirely — even though dotnet is perfectly available on PATH.

The workaround (manually setting FSharp.dotnetRoot to /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's fs.realpathSync to follow any symlinks. If the resolved path differs from the original (i.e. dotnet was a symlink), we set DOTNET_ROOT to the parent directory of the real binary before launching FSAC.

Priority order for DOTNET_ROOT propagation:

  1. Already in env → leave untouched (no change to existing behaviour)
  2. FSharp.dotnetRoot configured → propagate that value unchanged
  3. Dotnet binary is a symlinkDOTNET_ROOT = dirname(realpathSync(dotnet))
  4. Dotnet binary is not a symlink → do not override (FSAC can handle it)

The symlink-only condition (point 3) avoids incorrectly setting DOTNET_ROOT to a generic bin directory (e.g. /usr/bin) on systems where dotnet is not installed via a symlink.

Trade-offs

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 the emitJsExpr Fable utility already used elsewhere in the codebase. Fantomas formatting check: ✅ passed.

Platform coverage: The fix is conditional on resolvedDotnet <> dotnet so 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.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4957663821dbb3260348084fa2f1659701950fef

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F# Test Adapter crashes because it uses the wrong path for dotnet

0 participants