Fixed Jenkins build error MSB4018: System.InvalidOperationException: Unable to set permission while creating /tmp/NuGetScratch

Problem

  • NET Core Jenkin build fail and build logs.
...NuGet.targets(394,5): error MSB4018: The "WarnForInvalidProjectsTask" task failed unexpectedly. [<<Your CS Project>>]                                                                                                                                                                                                                          
...NuGet.targets(394,5): error MSB4018: System.InvalidOperationException: Unable to set permission while creating /tmp/NuGetScratch, errno=1. [<<Your CS Project>>]
...NuGet.targets(394,5): error MSB4018:    at NuGet.Common.NuGetEnvironment.<GetFolderPath>g__CreateSharedDirectory|6_0(String path) [<<Your CS Project>>]
...NuGet.targets(394,5): error MSB4018:    at NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath folder) [<<Your CS Project>>]
...NuGet.targets(394,5): error MSB4018:    at NuGet.Common.PathUtility.CheckIfFileSystemIsCaseInsensitive() [<<Your CS Project>>]
...NuGet.targets(394,5): error MSB4018:    at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) [<<Your CS Project>>]
...NuGet.targets(394,5): error MSB4018:    at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) [<<Your CS Project>>]
...NuGet.targets(394,5): error MSB4018:    at System.Lazy`1.CreateValue() [<<Your CS Project>>]
...NuGet.targets(394,5): error MSB4018:    at System.Lazy`1.get_Value() [<<Your CS Project>>]
  • It tell System.InvalidOperationException: Unable to set permission while creating /tmp/NuGetScratch
  • check /tmp permission by using following command
    NOTE: drwxrwxrwt >> t mean sticky bit is set. A file created in the /tmp directory can only be removed by its owner, or the root user.
# ls -ld /tmp
drwxrwxrwt 21 root root 12288 Apr 24 16:18 /tmp

Solution

  • restore correct permission in path /tmp by running the following command
chmod 1777 /tmp
#or
chmod a+trwx /tmp

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.