SaturnFramework / Saturn

Opinionated, web development framework for F# which implements the server-side, functional MVC pattern
https://saturnframework.org
MIT License
714 stars 108 forks source link

Compatible SDK version for gloabl.json error #159

Closed sashang closed 5 years ago

sashang commented 5 years ago

First this is my environment:

echo $DOTNET_ROOT 
/home/sashan/code/dotnet/2.1.4
echo $PATH
/home/sashan/code/dotnet/2.1.4 /home/sashan/.dotnet/tools /home/sashan/.npm-packages/bin /home/sashan/bin /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/lib/jvm/default/bin /usr/bin/site_perl /usr/bin/vendor_perl /usr/bin/core_perl /var/lib/snapd/snap/bin

Then create a new saturn project and run build.sh

  1. dotnet new saturn -lang F# --force
  2. chmod +x build.sh
  3. /build.sh run

It ends with the following error:

dotnet "restore" 
A compatible SDK version for global.json version: [2.1.4] from [/home/sashan/code/saturn_sample/global.json] was not found
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
Running build failed.
Error:
System.Exception: Restore failed on "restore" 
  at Fake.DotNetCli+Restore@146-3.Invoke (System.String message) [0x00000] in <5a8d2d45ccf1c534a7450383452d8d5a>:0 
  at Fake.DotNetCli.Restore (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] setRestoreParams) [0x0011b] in <5a8d2d45ccf1c534a7450383452d8d5a>:0 
  at FSI_0005.Build+clo@18-2.Invoke (Microsoft.FSharp.Core.Unit _arg2) [0x00006] in <5a34cd8d20ad4f70b3e07dd3781d5714>:0 
  at Fake.TargetHelper.runSingleTarget (Fake.TargetHelper+TargetTemplate`1[a] target) [0x00049] in <5a8d2d45ccf1c534a7450383452d8d5a>:0 

---------------------------------------------------------------------

Why is this? I've specified the path to the SDK in DOTNET_ROOT?

MarneeDear commented 5 years ago

Did you double check the global.json version? It looks like the latest version of the Saturn template specifies "2.1.300" in global.json. You'll need that version installed.

sashang commented 5 years ago

Well my global.jason has 2.1.4 in it.

sashan@deimos /home/sashan/code ☺ > rm -rf saturntest/
sashan@deimos /home/sashan/code ☺ > mkdir saturntest
sashan@deimos /home/sashan/code ☺ > cd saturntest/
sashan@deimos sashan/code/saturntest ☺ > ls
sashan@deimos sashan/code/saturntest ☺ > echo $DOTNET_ROOT 
/home/sashan/code/dotnet/2.1.3
sashan@deimos sashan/code/saturntest ☺ > which dotnet
/home/sashan/code/dotnet/2.1.3/dotnet
sashan@deimos sashan/code/saturntest ☺ > dotnet --version
2.1.300
sashan@deimos sashan/code/saturntest ☺ > dotnet new saturn -lang F# --force
The template "Saturn v0.4.1" was created successfully.

Processing post-creation actions...
xdg-open: unexpected argument '+x'
Try 'xdg-open --help' for more information.
Unable to apply permissions +x to "*.sh".
Post action failed.
Description: Make scripts executable
Manual instructions: Run 'chmod +x *.sh'

sashan@deimos sashan/code/saturntest ☺ > chmod +x .paket/paket.exe build.sh 
sashan@deimos sashan/code/saturntest ☺ > ls
build.cmd  build.fsx  build.sh*  global.json  paket.dependencies  paket.lock  saturntest.sln  src/
sashan@deimos sashan/code/saturntest ☺ > cat global.json 
{
  "sdk": {
    "version": "2.1.4"
  }
}⏎                                                                                                                                                                                                                                                             sashan@deimos sashan/code/saturntest ☺ > 

Subsequently running build.sh fails

dotnet "build" --configuration Release 
A compatible SDK version for global.json version: [2.1.4] from [/home/sashan/code/saturntest/global.json] was not found
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
Running build failed.
baronfel commented 5 years ago

2.1.4 is quite old, from January of this year, and is no longer supported. You should upgrade to at least 2.1.300 as requested by the template and try again. And also curse Microsoft for making confusing versioning schemes.

sashang commented 5 years ago

wtf........2.1.300 is an upgrade????

sashang commented 5 years ago

I think this is solved. I reinstalled the template and ran the build.sh again and it worked.

sashan@deimos sashan/code/saturntest ☺ > source ~/code/dotnet-env-2.1.3 
sashan@deimos sashan/code/saturntest ☺ > dotnet new -i Saturn.Template

sashan@deimos sashan/code/saturntest ☺ > dotnet new saturn -lang F# --force
The template "Saturn v0.7.0" was created successfully.

Processing post-creation actions...
xdg-open: unexpected argument '+x'
Try 'xdg-open --help' for more information.
Unable to apply permissions +x to "*.sh".
Post action failed.
Description: Make scripts executable
Manual instructions: Run 'chmod +x *.sh'

sashan@deimos sashan/code/saturntest ☺ > chmod +x .paket/paket.exe build.sh 
sashan@deimos sashan/code/saturntest ☺ > dotnet --version
2.1.300
sashan@deimos sashan/code/saturntest ☺ > ./build.sh