GeezerVison is showing github.com — Fallback to different installation directory if `/usr/share/dotnet` doesn't available due to permissions · Issue #518 · actions/setup-dotnet
Fallback to different installation directory if /usr/share/dotnet doesn't available due to permissions #518DescriptionDescription:
By default, dotnet is downloaded and installed under /usr/share/dotnet folder:
|
linux: '/usr/share/dotnet', |
Unfortunately, it is not great location because on some self-hosted runners and some Larger Runners (Linux Arm64 private beta), user doesn't have enough permissions to create / modify this folder.
In this case, action will fail with error:
Error: Failed to install dotnet, exit code: 1. mkdir: cannot create directory '/usr/share/dotnet': Permission denied
Proposed solution
I guess it is not possible to change default location /usr/share/dotnet to some new location because it will be a breaking change. So I am proposing adding a new fallback location in case if user doesn't have permissions for /usr/share/dotnet. It won't be a breaking change because fallback will be used only in cases when the current version of action would fail.
This action can check permissions of /usr/share/dotnet folder. If user doesn't have permissions to create / modify this folder, then the action should use different DOTNET_INSTALL_DIR directory instead of /usr/share/dotnet.
For example, it can use:
Alternative solutions
There are two alternative solutions:
- Change permissions of
/usr/share/dotnet once on self-hosted agent -> Unfortunately, it won't fix Linux Arm64 Larger Runners. Also, it is not super convenient and involve manual actions
- User can override
DOTNET_INSTALL_DIR environment variable by themselves -> it is definitely possible option but it is not super convenient and user needs to do it for every workflow YAML
We definitely have workarounds but it would be great if action can handle this case without workarounds. Reacted by Dave, skucher, ABW, Yuxiao Zeng, Guðmundur Ólafsson and Michael Conrad Activityv-HarithaVattikuti commented on Mar 22, 2024 Hello @maxim-lobanov
Thank you for creating this feature request. We will investigate it and get back to you as soon as we have some feedback. tremblaysimon commented on Apr 1, 2024 Seems to be a duplicate of #360.
@HarithaVattikuti, if you could check the PR #498 that seems to fix those issues.
Thank you in advance! maxim-lobanov commented on Apr 2, 2024 ContributorAuthor More actions @tremblaysimon I think #498 implements a bit different approach and I worry that it can't be accepted because it will be a breaking change.
The current path priorities:
env['DOTNET_INSTALL_DIR']
/usr/share/dotnet
env['RUNNER_TOOL_CACHE'] -> I propose adding a new location on third position in list of priorities.
#498 changes path priorities to:
env['DOTNET_INSTALL_DIR']
env['RUNNER_TOOL_CACHE']
/usr/share/dotnet
I could be wrong but It will be a breaking change for all hosted runners because all hosted runners will change default location from /usr/share/dotnet to env['RUNNER_TOOL_CACHE'].
Hosted runners have a cache of dotnet versions which is stored under /usr/share/dotnet: https://github.com/actions/runner-images/blob/2fd9adccce8acd226d394935c55b8a932b04d315/images/ubuntu/toolsets/toolset-2204.json#L274.
Changing the priorities order means that task will ignore cache on all hosted runners and will always download dotnet on flight. It can significantly increase workflow run duration for users of hosted runners. cjj196 commented on May 7, 2024 +1, this same issue occurs with windows self hosted runners as well. For example when trying to install 6.0.x using v4 a pair of access denied exceptions occur.
Access to the path 'C:\Program Files\dotnet\host\fxr\8.0.4' is denied.
Access to the path 'C:\Program Files\dotnet\sdk\6.0.421' is denied. no1melman commented on Sep 9, 2024 The interesting case we have with this, is that on Ubuntu 24.04 it's all installed to /usr/lib/dotnet not /usr/share/dotnet - however, even when you change the ~/.bashrc file to override the DOTNET_INSTALL_DIR to /usr/lib/dotnet the action still doesn't seem to work ..... the action still tries to point at /usr/share/dotnet v-priya-kinthali commented on Dec 23, 2025 Hello @maxim-lobanov👋,
Thank you for bringing up this feature request and suggesting effective approaches!
For now, we've added a note to the README in #689 with guidance on setting DOTNET_INSTALL_DIR to a user-writable path, which should help avoid permission errors on self hosted Linux runners.
We will continue to explore the feasibility of incorporating fallback logic into the action itself in future updates.
Thank you again for your valuable input😊! v-priyagupta108 commented on Oct 1, 2026 A fix for this is up in #785. It implements the fallback proposed here: when the default install location is not writable, the action falls back to .dotnet in the user's home directory with a warning, instead of failing with Permission denied. DOTNET_INSTALL_DIR keeps top priority, and runners that can write to the default location are unaffected.
Let us know if this resolves the failure on your runners. v-priyagupta108 commented on Oct 14, 2026 Just following up on this. Any thoughts on whether #785 covers your case? Happy to adjust if the behaviour isn't what you expected. v-priyagupta108 commented on Oct 27, 2026 Checking in again on #785, which implements the $HOME/.dotnet fallback proposed here. Does it cover your case, or is there a scenario it misses? v-priyagupta108 commented on Nov 2, 2026 Fixed by #785, now merged. When the default install location is not writable, the action falls back to .dotnet in the user's home directory with a warning instead of failing. DOTNET_INSTALL_DIR still takes priority, and runners that can write to the default location are unaffected. This will be available in the next release. Thanks for the detailed proposal. Frulfump commented on Nov 2, 2026 When's the next planned release? v-priyagupta108 commented on Nov 3, 2026 v6.1.0 is out and the v6 tag has been updated accordingly. If you're pinned to a SHA or an exact version, bump it.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|