actions / actions/setup-dotnet
Fallback to different installation directory if `/usr/share/dotnet` doesn't available due to permissions
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 572
- Avg merge
- 12d 20h
- Merged PRs (30d)
- 1
Description
Description:
By default, dotnet is downloaded and installed under /usr/share/dotnet folder: https://github.com/actions/setup-dotnet/blob/5d1464d5da459f3d7085106d52e499f4dc5d0f59/src/installer.ts#L220
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:
$HOME/.dotnet-> this way location will be consistent with MacOS Runners + user always have permissions to $HOME<runner.temp>/.dotnet-> https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
Alternative solutions
There are two alternative solutions:
- Change permissions of
/usr/share/dotnetonce 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_DIRenvironment 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/installer.ts around line 220, where the default /usr/share/dotnet installation location is selected. Review how the action invokes installation and handles permission failures, then determine how a fallback such as $HOME/.dotnet should be selected without changing the existing default. Done means installation succeeds when /usr/share/dotnet cannot be created or modified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ci-cd, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100