actions / setup-dotnet

Set up your GitHub Actions workflow with a specific version of the .NET core sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

All dotnet commands fail due to environment variables

william-dafriend opened this issue · comments

Description:
All attempts at using the action fail with the following error

/usr/share/dotnet/sdk/8.0.101/NuGet.targets(424,5): error MSB4018: System.InvalidOperationException: Required environment variable 'HOME' is not set. Try setting 'DOTNET_CLI_HOME' or 'HOME' and running the operation 

Task version:
version 4

Platform:

  • Ubuntu
  • macOS
  • Windows
  • Debian

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
Attempt to run an action using setup-dotnet/v4 and call any dotnet command

Expected behavior:
commands should complete successfully

Actual behavior:
Comamnds return errors about missing environment variables

All dotnet commands work fine in the _work directory directly on the runner. I have tried explicitly setting HOME and DOTNET_CLI_HOME environment variables in the action itself. These variables are both set and exported for the user on the github runner.

Hello @william-dafriend
Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

@william-dafriend If you are running your action-runner as a service on Linux, make sure the service is installed to use a user account, otherwise it will default to root; where these aren't defined. If you want to use root, then export DONET_CLI_HOME=/tmp and that will get you past this issue.

Hello @william-dafriend, Thank you for creating the issue and we have investigated the issue. Understood that
you have tried setting both the HOME and DOTNET_CLI_HOME environment variables directly in the action itself and you might do this in a workflow file:

steps:

  • name: Set Environment Variables
    run: |
    echo ""DOTNET_CLI_HOME=$HOME"" >> $GITHUB_ENV
    echo ""HOME=$HOME"" >> $GITHUB_ENV
  • name: Run dotnet command
    run: dotnet build

We have tested the same in our local, able to set the the environment variables through the workflow and the commands are successful. Please find the screenshot for reference.

image

Please confirm whether you have set the env variables by following the above step in your workflow.

Hello @william-dafriend, Please confirm whether you have set the env variables by following the above step in your workflow.

Hello @william-dafriend, Please confirm whether you have set the env variables by following the above step in your workflow.

Closing this issue as we don't hear any response from long time. Please feel free to reach us if you are still facing the issue.