SAFE-template icon indicating copy to clipboard operation
SAFE-template copied to clipboard

`The command "dotnet paket restore" excited with code -532462766` on a fresh SAFE template

Open Freymaurer opened this issue 1 year ago • 12 comments

Hey guys, i never encountered this error before, but we wanted to setup a SAFE project for a new colleague and we got an error The command "dotnet paket restore" excited with code -532462766. We tested this also for a fresh SAFE stack and still the issue persists. I have no idea why this issue happens. We "solved" it by removing paket and using simple dotnet dependencies but this is obviously no real solution.

This is not my machine, but i will try to answer asap if you want more information on this. But i do not expect you to solve this obscure issue. Just wanted to let you know.

We also tried running dotnet watch run src/Server/Server.fsproj without fake with the same result and tried building the projects which worked just fine.

The machine uses:

  • Win 11
  • .net8.0, node 20 and npm 9

image

Freymaurer avatar Jul 02 '24 21:07 Freymaurer

I've definitely seen this error code before. Last time it was to do with missing paket.references from the Shared directory causing Paket to use the wrong version of FSharp - this is now fixed as of 8 months ago.

Maybe these will help diagnose the issue:

  • What version of the SAFE template is being used?
  • What is the output of dotnet --list-sdks?
  • What is the output of dotnet build -v:d? (from the src/Server directory)

jwthomson avatar Jul 05 '24 15:07 jwthomson

Hello! Thanks for the quick response!

What version of the SAFE template is being used?

The newest version v5.0.6

What is the output of dotnet --list-sdks?

image

What is the output of dotnet build -v:d? (from the src/Server directory)

image

Freymaurer avatar Jul 05 '24 19:07 Freymaurer

Duplicate of #612, thanks for your report @Freymaurer! the other issue has a workaround in the discussion

Larocceau avatar Jul 12 '24 12:07 Larocceau

@baronfel ok. I've found some more information on this.

TLDR: If you dotnet watch build from the folder of the project, and you're using Paket, and a version of .NET 8 post 8.0.206, things go wrong. If you dotnet watch build from outside of the folder of the fsproj e.g. dotnet watch build src/server, then it works.

I suspect it's something that's changed since 8.0.206 that has somehow broken Paket. Here are some steps to reproduce:

  1. Install a version of .NET after 8.0.206 (I'm using 8.0.304).
  2. dotnet new SAFE (I'm using 5.0.7).
  3. dotnet watch build src/server - works ✅
  4. cd src/server
  5. dotnet watch build - pops ❌
  6. dotnet build - works ✅
  7. Change global.json to pin to 8.0.206.
  8. dotnet watch build - works ✅
  9. Revert change to global.json.
  10. Clear out everything in Server.fs to just e.g
module Server
[<EntryPoint>]
let main _ = 0
  1. In Server.fsproj, remove the reference to Shared and the Import of Paket.Restore.targets.
  2. dotnet watch build - works ✅

I don't always get a stack trace but when I do, it's this:

dotnet watch � Started
  Determining projects to restore...
  Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neut
  ral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
  File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
     at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, Objec
  tHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
     at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
     at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
     at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
     at System.StartupHookProvider.ProcessStartupHooks()


C:\Users\IsaacAbraham\code\safeFoo\.paket\Paket.Restore.targets(171,3): error MSB3073: The command "dotnet paket restore" exited with 
code -532462766. [C:\Users\IsaacAbraham\code\safeFoo\src\Server\Server.fsproj]

Also tagging @forki as it could relate to Paket.

Update 1

I've just observed that the "workaround" of calling it from a different folder does not work for dotnet watch run. It only works for dotnet watch build.

isaacabraham avatar Aug 15 '24 11:08 isaacabraham

Hello there - just went to update my Mortgage app and hit exactly this! Great timing haha

Ryan-Palmer avatar Aug 15 '24 13:08 Ryan-Palmer

FYI my temp workaround was to just add --no-restore to the dotnet watch run command

Ryan-Palmer avatar Aug 15 '24 13:08 Ryan-Palmer

ooooh that's interesting

isaacabraham avatar Aug 15 '24 13:08 isaacabraham

I was even thinking to add that to the template anyway because it's rarely needed anyway as part of watch run.

isaacabraham avatar Aug 15 '24 13:08 isaacabraham

experiencing the same error on mac os/x

.paket/Paket.Restore.targets(171,3): error MSB3073: The command "dotnet paket restore" exited with code 134. [src/Shared/Shared.fsproj]

and the @isaacabraham workaround above of pinning the .net sdk in global.json to 8.0.204 works.

awostenberg avatar Aug 26 '24 04:08 awostenberg

I've rerun the failing test thread above and both .NET SDK 8.0.400 and 9.0.100-rc.1 work like a charm - I'd highly suggest moving to those feature bands. As it is, this is a regression only on the 8.0.3xx branch from what I can see.

baronfel avatar Sep 16 '24 14:09 baronfel

I'm on 401 and still seeing it. I've also determined that the issue ONLY occurs with the Sdk.Web SDK, not the "regular" one.

isaacabraham avatar Sep 16 '24 15:09 isaacabraham

I came across this error when trying to upgrade .NET6 and .NET7 Safe stack apps to .NET8. With the help of an old Senior Dev., these are the steps that I have been taking to successfully upgrade to .NET8:

  1. Change net6.0 (or net7.0) to net8.0 in all .fsproj files, paket.dependencies, and paket.lock
  2. Change sdk version in global.json to 8.0.303 (or whatever newest version you have downloaded)
  3. Replace "server", dotnet "watch run" serverPath with "server", dotnet "watch run --no-restore" serverPath in the Run target in Build.fs
  4. Remove all version pins in paket.dependencies
  5. Update all tools individually with dotnet tool update {tool}
  6. If the Shared folder doesn't have a paket.references file, add one. (You may need to dotnet paket add FSharp.Core and FsToolkit.Errorhandling to this paket.references file depending on the build errors you get)
  7. dotnet restore from both the Server and Shared folders
  8. dotnet paket install from root
  9. dotnet paket update from root
  10. dotnet run Clean
  11. Delete bin and obj folders
  12. dotnet run
  13. Fix any build/compilation errors that may have popped up because of the updated dependencies

These are the steps that have worked for me at least. Yours might look slightly different.

sydsutton avatar Oct 18 '24 17:10 sydsutton

This worked for me https://github.com/dotnet/sdk/issues/43468#issuecomment-2437600057

kevkov avatar Oct 25 '24 17:10 kevkov

this issue is resolved by #634

Larocceau avatar Nov 22 '24 16:11 Larocceau