Fix dnx dispatcher to resolve install dir through symlinks - #54710
Merged
mthalman merged 2 commits intoJun 15, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes dnx launcher resolution on Unix-like installs where dnx is invoked via a PATH-reachable symlink (e.g., /usr/bin/dnx), ensuring the dispatcher computes the real install directory before locating dotnet and the newest SDK.
Changes:
- Resolve the script’s real directory by following symlinks (without relying on
readlink -f). - Emit a clear error when no SDK is installed (instead of constructing an invalid
.../sdk//dotnet.dllpath). - Use
execfor the finaldotnet exec ...invocation so signals and exit codes propagate correctly.
Replace the obsolescent `tail -1` shorthand with the POSIX-mandated `tail -n 1` form. Every `tail` implementation we'd encounter (GNU, BSD, macOS, busybox) supports both, but `-n N` is the form required by POSIX and is preferred for portable `/bin/sh` scripts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
baronfel
approved these changes
Jun 11, 2026
JoeRobich
approved these changes
Jun 11, 2026
Member
Author
|
/ba-g unrelated failure |
Member
|
/backport to release/11.0.1xx-preview6 |
Contributor
|
Started backporting to |
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.
Tactics
Summary
On Linux,
dnxinvoked fromPATH(the normal way) fails withThe application to execute does not exist: '/usr/bin/sdk/<ver>/dotnet.dll'. The dispatcher script usesdirname "$0"to find its install directory, which returns/usr/binwhen invoked through the/usr/bin/dnxsymlink instead of the real install dir/usr/lib/dotnet. The fix resolves symlinks to find the script's real location. Two smaller fixes are bundled in: a clear error message when no SDK is installed (instead of a confusing.../sdk//dotnet.dllpath-not-found), and usingexecfor the finaldotnetinvocation so signals and exit codes propagate correctly without an extra shell process.Customer Impact
Every Linux user who runs
dnxthe normal way, via thednxcommand onPATH, gets:dnxis unusable through the standard entry point. Only invocation by the absolute real path/usr/lib/dotnet/dnxworks, and no normal user does that. macOS.pkgand tarball layouts that route through a symlink would be broken the same way. Additionally, users with no SDK installed (only the runtime) see the samedotnet.dll-not-found shape of error rather than a clear "dnx requires a .NET SDK" message.Regression?
Yes, introduced by #54587. Prior to those PRs,
dnxwas a simple"$(dirname "$0")/dotnet" dnx "$@"wrapper. That older form also relies ondirname "$0", but it works through the/usr/bin/dnxsymlink only by happy accident: thedotnetit dispatches to is/usr/bin/dotnet, which is itself a symlink to the realdotnetbinary, and the script never needed to compute any explicit SDK path. #54587 introduced the explicitSDK_PATHconstruction, which is the first time the script needed the real install directory — anddirname "$0"doesn't give it. The bug has not yet shipped. It will appear in the next 10.0.302 servicing release unless this fix lands first.Easy repro (in an
ubuntu:24.04container withdotnet-sdk-10.0from the default repos):Output:
Testing
sh,dash,bash, andbusybox shacross multiple scenarios: direct invocation, single-symlink invocation, multi-hop symlink chain, PATH invocation, args with spaces / quotes / dollar signs, no-SDK error case, newest-SDK selection across multiple installed SDKs, paths with spaces, exit-code propagation.shellcheck --shell=shpasses clean (POSIX-compliant).dnx --helpvia/usr/bin/dnx, viaPATH.dnxworks from PATH after package install dotnet#7193 tracks adding a permanent installer-layer test that runsdnx.Risk
Low. The change is confined to a single script. The symlink-resolution loop is the canonical POSIX idiom.