tareqimbasher / NetPad

A cross-platform C# editor and playground.
MIT License
1.25k stars 66 forks source link

The dotnet-ef tool is not functioning properly on NetPad on macOS. #78

Closed darwin-z closed 2 months ago

darwin-z commented 1 year ago

I've already set up the .NET SDK and installed the dotnet-ef tool. It runs fine in the local command line. However, on the App Dependencies Check page, it shows that the .NET SDK is installed successfully, but dotnet-ef displays "Entity Framework Core .NET tool is not installed."

image image image image image
tareqimbasher commented 1 year ago

That's interesting, it looks like although NetPad is saying it can't find the EF Core tool, it was still able to execute it, and then the tool wasn't able to find the .NET SDK.

I assume you restarted NetPad after installing the EF Core tool?

I'll investigate and see what's going on. Thanks for reporting.

tareqimbasher commented 1 year ago

Also I noticed in the StackTrace your last screenshot that it seems you've built NetPad from source? If so, were you seeing the same exact error when using the prebuilt binary?

darwin-z commented 1 year ago

I downloaded NetPad(v0.4.2) from the Release.

image

So far, I have found that executing it on my local command line with root privileges has the same issue.

Normal state(dotnet --info,dotnet-ef

image image

Executing with sudosudo dotnet --info,sudo dotnet-ef

image

Environment variables display as Not Set

image

However, when I use sudo -E to preserve the current environment variables, the result is the same as executing directly.

sudo -E dotnet-ef --info and sudo -E dotnet-ef

image image

I took a rough look at your code, and regarding the operations involving Process.Start, it seems that user environment variables are not being passed, which might be causing the absence of these variables. Perhaps some modifications are needed here.

image
tareqimbasher commented 1 year ago

Yep that's exactly what the problem is. Thank you for taking the time and digging and providing all that great info, makes my job that much easier! 😄

I think there's a couple more places where I need to pass along the env variables, and the one you pointed to is one of them.

Should have a patch for this soon. Did you use the standard installer from Microsoft to install the .NET SDK or did you use a package manager like homebrew? Trying to account for the different install pathways users might choose.

darwin-z commented 1 year ago

I use the official dotnet-install.sh installation script to install the .NET SDK, it defaults to installing it in my home directory.

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#script-behavior

tareqimbasher commented 1 year ago

Update: #84 is merged and will fix this issue. It will go out in v0.5.0. I also added ~/.dotnet as a common directory that NetPad will search within for a .NET SDK installation, so you will be able to remove the manual .NET SDK path you set in settings.

Will keep this open until you're able to confirm the new version is working properly for you.

tareqimbasher commented 11 months ago

@2hangha1fen9 v0.5.0 is out, can you please verify your issue is resolved.

darwin-z commented 11 months ago

@2hangha1fen9 v0.5.0 is out, can you please verify your issue is resolved.

It's working now, but the dependency detection dialog is not displaying correctly.👍

image
tareqimbasher commented 3 months ago

@darwin-z a couple versions of NetPad have been released since the last update here. Are you still experiencing this issue?