godot
godot copied to clipboard
GoDot version 4 doesn't find dotnet when installed from the official Ubuntu feeds
Godot version
4.0.beta10.mono.official.d0398f62f
System information
Ubuntu 22.10 with dotnet 6
Issue description
If you are using Ubuntu 22.10, maybe other version, and you install .Net 6.0 from the official Ubuntu feeds, Godot 4 can't find the .Net package's install location and therefore can't find /usr/share/dotnet/host/fxr
.
This is because the Ubuntu feeds put the dotnet directory at usr/lib/dotnet
and if you install the package directly from the Microsoft official feeds the package is at usr/share/dotnet
When launching Godot 4, the error message is: "The host fxr folder does not exist: /usr/share/dotnet/host/fxr"
Steps to reproduce
- Start from a clean machine - you must not have any version of dotnet installed from any distribution/official feed or Microsoft feed.
- Download Godot 4.
- Install to
/opt/godot
- this mean the Godot executable is at/opt/godot4/Godot_v4.0-beta10_mono_linux.x86_64
-
Run
sudo apt install dotnet-sdk-6.0
-
Run
/opt/godot4/Godot_v4.0-beta10_mono_linux.x86_64
Error message
ERROR: The host fxr folder does not exist: /usr/share/dotnet/host/fxr
at: try_get_path_from_dotnet_root (modules/mono/editor/hostfxr_resolver.cpp:323)
Minimal reproduction project
This is during the program launch, I'm happy to attach logs if that will help. I don't think a repro project helps here.
Are you able to execute dotnet --info
in a terminal? What does it output?
The /usr/share/dotnet
path is the canonical location for .NET installs so we fallback to that as last resort, but we also check other locations. For example:
- Do you have the
DOTNET_ROOT
variable set? - Do you have a text file in
/etc/dotnet/install_location
? What are the contents of that file?
Heya, thanks for the questions. I'll explain a little more too, this is only my second time filing a GitHub issue and I'm not sure how descriptive or terse I should be!
My semi-educated guess is the root of all this is Ubuntu is putting the .Net 6 SDK in that spot which is different from Microsoft, and from your questions, sounds like the Ubuntu one is leaving setup half-done? I have nothing for $DOTNET_ROOT
or etc/dotnet/install_location
I installed the .Net 6 SDK directly from apt (aka no snap package) but I found this on Microsoft's docs which is helpful: Troubles resolving dotnet
They're recognized people/apps look for dotnet all over the place (figuratively) and say it's okay to symlink to the spot where the program is looking - they specifically call out the share location
To fix this problem, symlink the snap dotnet executable to the location that the program is looking for. Two common paths the dotnet command is looking for are /usr/local/bin/dotnet and /usr/share/dotnet. For example, to link the current .NET SDK snap package, use the following command:
Sorry about the wall of text, with all this said I'm not sure if the best solution is for me to
- symlink from lib to share
sudo ln -s /usr/lib/dotnet /usr/share/dotnet
I tested and this solves the issue. It's a valid and easy solution. - Tell people to set either that environment variable or the file you mentioned? Heads up I don't know what the contents of that file should be.
- Chase down the Ubuntu maintainers and get them to change the install? I don't know how feasible this is
- Investigate the function which looks for
p_dotnet_root
or change the called of hostfxr_resolver to have the /usr/share/dotnet path as a fallback/last-resort?- If this option is considered or chosen, I'm happy to work on it. I don't want to sound like I'm asking people to do work I wouldn't do myself.
dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.111
Commit: b3bb659a9d
Runtime Environment:
OS Name: ubuntu
OS Version: 22.10
OS Platform: Linux
RID: ubuntu.22.10-x64
Base Path: /usr/lib/dotnet/sdk/6.0.111/
global.json file:
Not found
Host:
Version: 6.0.11
Architecture: x64
Commit: 943474ca16
.NET SDKs installed:
6.0.111 [/usr/lib/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.11 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.11 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Nothing is set for the env var $DOTNET_ROOT
❯ cat /etc/dotnet/install_location
cat: /etc/dotnet/install_location: No such file or directory
I have nothing for
$DOTNET_ROOT
oretc/dotnet/install_location
That's fine, they don't need to exist, just checking if they did because they affect the lookup.
I don't think we want to recommend users to add symlinks or modify their installation, I think the Ubuntu package should work fine out of the box. This could just be a bug with our hostfxr resolver.
The hostfxr resolver already uses /usr/share/dotnet
as last resort. It should also try to use the path relative to the dotnet executable if it can't find hostfxr in the common locations, can you run where dotnet
to see the path of the dotnet executable that is being used?
Ok cool, thanks for being so helpful! All of that makes sense and I think making Ubuntu's default installation of the dotnet SDK work out of the box is great.
I was surprised seeing /usr/bin/dotnet
as the output of which dotnet so I dug a little deeper and found the dotnet
in /usr/bin
is symlink
❯ where dotnet
where: command not found
/🔒
❯ which dotnet
/usr/bin/dotnet
/usr/bin🔒 via 🐍 v3.10.7
❯ ll dot*
lrwxrwxrwx 1 root root 20 Oct 31 05:32 dotnet -> ../lib/dotnet/dotnet*
Are you getting any other errors in the terminal? Otherwise, are you able to create and build a C# Godot project? I suspect this error may not actually be an issue.
I think this error is printed because it can't find the SDK in the usual locations but it will try to find it relative to the dotnet executable. If it's able to find it everything should be fine and the error can be ignored; otherwise, it should print the same error again but with a different path and then a third error that looks like this:
.NET: One of the dependent libraries is missing.
Typically when the `hostfxr`, `hostpolicy` or `coreclr` dynamic
libraries are not present in the expected locations.
You know what, there no other errors in the terminal and I can definitely build and run a C# project. The one thing which is confusing me is I still see mono in some places in the build log but we're definitely using msbuild, which (I'm really certain) is only a .Net thing.
Thanks for having me check this, as far as I can tell everything works.
Should I make a PR to improve how the hostfxr resolver deals with the Ubuntu package, or take a look a why the error is output to the terminal and suppress it in this case? Maybe we're all good because everything works?
Running: /usr/bin/dotnet build /home/myusername/Projects/Recluse/Recluse.sln -c Debug -v normal -l:GodotTools.BuildLogger.GodotBuildLogger,/opt/godot4/GodotSharp/Tools/GodotTools.BuildLogger.dll;/home/myusername/.local/share/godot/mono/build_logs/e35eef77723e324b17119417234834e7_Debug -p:GodotTargetPlatform=linuxbsd
Microsoft (R) Build Engine version 17.0.1+b177f8fa7 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
I still see mono in some places in the build log
Without seeing the log you are referring to I'm unable to provide an accurate explanation but I'd say this is expected since we still refer to the module as the mono module in a lot of places.
Should I make a PR to improve how the hostfxr resolver deals with the Ubuntu package, or take a look a why the error is output to the terminal and suppress it in this case? Maybe we're all good because everything works?
I think this may change with the Editor unification[^1], since non-C# users will use the same Editor complaining about not finding .NET won't be acceptable and we'll have to change how we handle that.
Since this may end up fixed as a side-effect of Editor unification, I feel like trying to fix the current code may not be worth doing at the moment. So if everything's working for you I think we can leave it as is for now if you're OK with the false-positive error.
[^1]: Currently there are two versions of the Godot Editor (standard and mono), we plan to have a single version instead which will support C# by downloading the necessary packages on-demand.
So i write this here because i always run in to this error when i distro hopping and forget about the solution for me :P if i have dot net sdk installed but it does not show up in the dotnet --info sdk section, i remove it.
sudo apt remove --purge --autoremove *dotnet*
then i modify the prefrerences:
sudo nano /etc/apt/preferences.d/dotnet
With content:
Package: dotnet*
Pin: origin packages.microsoft.com
Pin-Priority: 1001
and
sudo nano /etc/apt/preferences.d/aspnet
With content:
Package: aspnet*
Pin: origin packages.microsoft.com
Pin-Priority: 1001
and then i run:
sudo apt update && sudo apt install dotnet-sdk-7.0
sources here: https://github.com/dotnet/core/issues/7699 https://github.com/dotnet/sdk/issues/27129
And sometimes i need to make sure this is enabled, and sometime its on by default
Running Godot from the terminal solved my problem
Try this:
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod 777 dotnet-install.sh
./dotnet-install.sh --channel 7.0
export PATH="$PATH:$HOME/.dotnet"
Use microsoft script to install dotnet. It works fine.
Snap dotnet has issue, it seems like: https://github.com/godotengine/godot/issues/76422
Currently there are two versions of the Godot Editor (standard and mono), we plan to have a single version instead which will support C# by downloading the necessary packages on-demand.
Where is the tracker for this?
Where is the tracker for this?
See https://github.com/godotengine/godot-proposals/issues/2333. There's no open proposal for actually implementing this, but it's not planned for 4.1 at least.
Running Godot from the terminal solved my problem
solved for me
is there a way to remove that error (or any other error) from showing up?
even if everything works
Thank you
@kepiz This was fixed 4 days ago, the fix is not available in the version of Godot you're using (I assume 4.1.1-stable).
You'll find the fix in the upcoming 4.2-dev5, and likely in 4.1.2 when it's released.
How do I get past this for the moment? I've installed dotnet-sdk from snap and using godot4-mono from snap.
How do I get past this for the moment? I've installed dotnet-sdk from snap and using godot4-mono from snap.
What error do you have exactly? Have you tried my solution above?
I know saying do something different isn't as satisfying as solving the problem you're directly having but I think in this case if you're using a modern version of Ubuntu that's the easier solution for you. (I'm guessing you're using modern Ubuntu because snap)
Have you read the earlier parts of the issue I posed, especially the part about installing dotnet different ways?
[1] https://learn.microsoft.com/en-us/dotnet/core/install/linux#troubles-resolving-dotnet
The easiest is symlink from the location of your dotnet/host/fxr
to wherever Godot expects it. The hardest is figuring out why your method of installing dotnet put the files in a (probably) unexpected location.
Going back to there is a simpler way, I install the dotnet sdk via apt and install Godot to either /opt/Godot
or ~/.local/opt/Godot
depending on how much I want to change the permissions of stuff.
I personally think doing this is the best because you've got a pretty standard version of .Net installed and you are free to update or change the Godot editor at your own pace and there are no sandboxing/snap issues to debug.
I've tried symlinking