TFS Linux Agent with error: The user's home directory could not be determined
How to fix problem with dotnet restore on TFS 2017 Linux agent - The user’s home directory could not be determined.
I have recently configured Linux agent for Team Foundation Server 2017 to be able to run dotnet core project there.
But during dotnet restore
step error was thrown: Error: /usr/bin/dotnet failed with return code: 1 with more explanation:
The user’s home directory could not be determined. Set the ‘DOTNET_CLI_HOME’ environment variable to specify the directory to use.
It may occur also on newer versions of TFS and on its online version - Visual Studio Team Services (VSTS), currently called Azure DevOps.
After quick search I knew that dotnet needs to know where home is located for some operations.
Agent logs
Full agent logs for dotnet restore step:
What didn’t help
First I checked if $HOME
variable can be seen on this Linux Machine, logged in as user which is given for TFS.
It was ok. Then I set DOTNET_CLI_HOME as Linux environment variable, pointing to $HOME
. It didn’t help.
There were much more solutions to check, looking through the internet, but next one worked for me.
Solution
This solutions is not elegant, but it works and in my view is acceptable, and it has one big advantage - it doesn’t require access to Linux Machine ssh.
I set DOTNET_CLI_HOME as build definition variable, pointing to /tmp
directory. That’s it, now dotnet restore and build works :)
Summary
I don’t know if this solution will work for everyone, but it takes only 2 clicks to try, so definitely it’s good to start with :)
Stay up to date!
Get all the latest & greatest posts
delivered straight to your inbox