-
Notifications
You must be signed in to change notification settings - Fork 24
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
macOS: get_coreclr fails if run in an already open Terminal window after a fresh dotnet install. Works on Windows. #24
Comments
I'd be fine with special-casing this for macOS. PRs are welcome, I have no mac to test this. The CI doesn't have this problem as it (properly, IMO) sets |
And by the way, the reason this is special-cased on Windows is that on this system one expects it to always install into |
Thanks @filmor Based on your advice, we could add the following which would make it work on macOS: def find_dotnet_root() -> str:
dotnet_root = os.environ.get("DOTNET_ROOT", None)
if dotnet_root is not None:
return dotnet_root
if sys.platform == "win32":
# On Windows, the host library is stored separately from dotnet.exe for x86
prog_files = os.environ.get("ProgramFiles")
dotnet_root = os.path.join(prog_files, "dotnet")
## if os.path.isdir(dotnet_root): MOVED BELOW
## return dotnet_root MOVED BELOW
### START NEW
if sys.platform == "darwin":
dotnet_root = r'/usr/local/share/dotnet'
if os.path.isdir(dotnet_root):
return dotnet_root
### END NEW
# Try to discover dotnet from PATH otherwise
dotnet_path = shutil.which("dotnet")
if not dotnet_path:
raise RuntimeError("Can not determine dotnet root")
I have a few questions:
if sys.platform == "linux":
dotnet_root = r'/usr/share/dotnet' |
|
Thank you :) |
On macOS with pythonnet 3.0.0a2 installed (clr-loader 0.1.7) but without .NET core installed:
get_coreclr(C:\MyApp.runtimeconfig.json)
This results in the following exception:
If a NEW Terminal window is opened then this error does not occur. However we should not have to open a new Terminal window for it to find the dotnet executable. Performing the same steps on Windows works fine - we don't need to open a new command window.
My application has the prerequisites that pythonnet and .NET runtime are first installed. I am getting reports from people that they have installed the prerequisites but it is still failing. They don't realise that they need to open a new Terminal window to get it working.
The reason for the exception seems to be in clr-loader/util/find.py there is a difference how it finds the "dotnet" executable between Windows and macOS:
dotnet_path = shutil.which("dotnet")
doesn't find anything because dotnet is not in the path for this Terminal window.To fix this, could macOS just look in /usr/local/share/dotnet ?
(I'm don't have Linux so I'm not sure where dotnet gets installed to on Linux)
The text was updated successfully, but these errors were encountered: