setup-dotnet: Permission denied in /usr/share/dotnet

Description: Runner does not have permission to install in the default directory

Task version: 3.0.0

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
Use action with selfhosted ubuntu runner with non-root user permissions

Expected behavior: Install dotnet

Actual behavior: Permission denied

I tried using the env DOTNET_INSTALL_DIR but it doesn’t seem to work

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 22 (8 by maintainers)

Most upvoted comments

It would probably be good update the docs to include instructions to set

env:
  DOTNET_INSTALL_DIR: "./.dotnet"

On self hosted linux nodes.

Hi, yes, comparing v3 to main there was no difference for me, both worked, using the following:

env:
  DOTNET_INSTALL_DIR: "./.dotnet"

steps:
- uses: actions/setup-dotnet@v3.0.1
  with:
    dotnet-version: '6.x'

@andrewgbell, you are right. The default directory was changed (it’s breaking change), details and motivation can be found here.

Hi, @wzchua, @andrewgbell, @austindrenski and @mathieu-benoit 👋 The new patch version was just released to fix the issue with DOTNET_INSTALL_DIR environment variable. If your user doesn’t have permissions to write SDK’s files into the default directory, you can use DOTNET_INSTALL_DIR to specify any other directory that suits you:

jobName:
  runs-on: self-hosted
  env:
    DOTNET_INSTALL_DIR: "path/to/directory"
  steps:
    - uses: actions/setup-dotnet@v3.0.1 # as soon as major tag is updated, v3 can be used
      with:
        dotnet-version: '7.0'

Please, give us your feedback in the comments. If you have any additional questions, feel free to ask.

Hi, @andrewgbell 👋 Thank you for the feedback, we are working on this issue.

Hi, I don’t have sudo permission. I would prefer an option to install in a non-root location

this solution pollutes your working directory so git commands or versioning tools that except clean working directory will fail!

@wzchua, I’m going to close this issue, as the new patch version of the actions was released and it fixes the problems that were stated in the issue and in the comments below. If you have any additional questions, feel free to ping me.

Hi, @wzchua, @andrewgbell, @austindrenski, @mathieu-benoit, @lanwin 👋 Sorry for the late answer, the logic of processing DOTNET_INSTALL_DIR was updated. Could you please, test the action in your workflows and leave your feedback, specify the main branch instead of v3 like that:

 - uses: actions/setup-dotnet@main

Hi @IvanZosimov. Does this now have to be defined when the agent doesn’t have root? Just curious as this wasn’t the case previously, so has the default install directory changed?

We have the same issue, was fine on v2.