Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on running script (unable to restore packages) #593

Closed
hitochan777 opened this issue Nov 14, 2020 · 3 comments
Closed

Error on running script (unable to restore packages) #593

hitochan777 opened this issue Nov 14, 2020 · 3 comments

Comments

@hitochan777
Copy link

hitochan777 commented Nov 14, 2020

Problem

When I run a script file with the following command I get an error as shown below:

$ dotnet script foo.csx
Unable to restore packages from '/home/myuser/.cache/dotnet-script/home/myuser/developer/net5.0/script.csproj'
Make sure that all script files contains valid NuGet references

Details:
/home/myuser/.cache/dotnet-script/home/myuser/developer/net5.0 : dotnet restore "/home/myuser/.cache/dotnet-script/home/myuser/developer/net5.0/script.csproj" -r linux-x64  --configfile "/home/myuser/.nuget/NuGet/NuGet.Config"

The content of the script is as follows:

$ cat foo.csx                                       
Console.WriteLine("hello");

Environment Info

$ dotnet --info          
.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /snap/dotnet-sdk/105/sdk/5.0.100/

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  5.0.100 [/snap/dotnet-sdk/105/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.0 [/snap/dotnet-sdk/105/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.0 [/snap/dotnet-sdk/105/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
$ dotnet script --version
1.0.1

I am wondering if upgrading .NET Core from 3.x to 5.x and dotnet-script from 0.50.1 to 1.0.1 is somewhat related.
#199 seems relevant but what is different from the issue is that I do not import any packages.

@hitochan777 hitochan777 changed the title Error on running script Error on running script (unable to restore packages) Nov 14, 2020
@filipw
Copy link
Member

filipw commented Nov 14, 2020

did you try running with --no-cache?

also it might be good to try uninstalling the tool and reinstalling again

@hitochan777
Copy link
Author

hitochan777 commented Nov 16, 2020

@filipw

Thank you for your reply.
I tried both but none of them is working.
Is it possible that dotnet-script is not compatible with .NET installed via snap?

$ dotnet script --no-cache hoge.csx
Unable to restore packages from '/home/myuser/.cache/dotnet-script/home/myuser/net5.0/script.csproj'
Make sure that all script files contains valid NuGet references

Details:
/home/myuser/.cache/dotnet-script/home/myuser/net5.0 : dotnet restore "/home/myuser/.cache/dotnet-script/home/myuser/net5.0/script.csproj" -r linux-x64  --configfile "/home/myuser/.nuget/NuGet/NuGet.Config"

$ dotnet tool uninstall -g dotnet-script                            
Tool 'dotnet-script' (version '1.0.1') was successfully uninstalled.

$ dotnet tool install -g dotnet-script  
You can invoke the tool using the following command: dotnet-script
Tool 'dotnet-script' (version '1.0.1') was successfully installed.

$ dotnet script --no-cache hoge.csx     
Unable to restore packages from '/home/myuser/.cache/dotnet-script/home/myuser/net5.0/script.csproj'
Make sure that all script files contains valid NuGet references

Details:
/home/myuser/.cache/dotnet-script/home/myuser/net5.0 : dotnet restore "/home/myuser/.cache/dotnet-script/home/myuser/net5.0/script.csproj" -r linux-x64  --configfile "/home/myuser/.nuget/NuGet/NuGet.Config"

@hitochan777
Copy link
Author

Hmm I don't know why but I was able to run scripts after reinstalling .NET via apt-get install instead of snap.
Installation via snap seems to cause other issues such as being unable to run vscode-omnisharp extension...
Anyways thanks for the help! @filipw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants