-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add support for external C# script editors #2
Comments
I cannot speak for every C# editor, but when using Jetbrains Rider when setting up a configuration for a project it expects you to set a path to your C# runtime: AFAIK it is not easy to access the mono runtime inside the Flatpak (unless you also put Rider into the Flatpak maybe?) because of the sandbox. |
In Editor Settings > Dotnet > Editor > External Editor it doesn't work if I select Visual Studio Code directly. But it seems to work for me (at least to open a C# script from Godot) when selecting Custom and manually entering the exec path to VSCode through dotnet/editor/external_editor = 6 ; Custom
dotnet/editor/custom_exec_path = "flatpak-spawn"
dotnet/editor/custom_exec_path_args = "--host code --goto {file}:{line}:{col}" This is for the snap version of Code. If Code is also a flatpak then I think the issue is just clarifying the instructions, that it doesn't work directly, but you should set it to Custom and add the arguments. Of course, a better option would be for this flatpak to provide a shell script for |
You have just repeated the instructions already provided in the readme: https://github.com/flathub/org.godotengine.GodotSharp#using-an-external-script-editor From my testing it will not give you any code completion or intellisense unless you have dotnet / mono installed on your host machine, which defeats the purpose of the Flatpak IMO. |
I disagree. The purpose of the flatpak (for me at least) is to make Godot auto-update hassle-free, and use the sandboxing. I assume it's pretty much expected that
Doing |
This Flatpak uses org.freedesktop.Sdk.Extension.dotnet7, and, if it hasn't already been installed, this Flatpak ( |
Late correction: I tried installing GodotSharp locally and it didn't install a separate Flatpak for the (Sorry for the pings, folks) |
This seems to work fine. I just tested on VSCodium (my IDE is in unsandboxed snap, not flatpak). But if you use a local flatpak installation you have to set Oh, and I suppose it's better if someone with a flatpak'd IDE could test too. Maybe you just need to set a similar setting or perhaps So it's possible no changes need to be made, except maybe clarifying in the README how this can be done instead of saying "The Mono external editor support does not work". Also, my suggestion above would still be the ideal to make it work out-of-the box, it would just require a bit of scripting:
|
Update appdata.xml patch with updated information on MSBuild, external C# script editors and this Flatpak being unofficial - Mark this Flatpak as unofficial - Describe usage of .NET 8 for MSBuild - Describe usage of external editors for C# scripting and link to flathub/org.godotengine.GodotSharp#2 and #2
I'm updating the .NET Freedesktop SDK extension to .NET 8 (instead of .NET 7) here: #8 Just letting you know in case anyone here is using this Flatpak and somehow any problems arise after the update gets merged and published, though that shouldn't be happening because the installation folder should still be |
I have a solution for VSCode (tested) and MonoDevelop (should work too) to fix this issue with simple scripts. @Zishan-Rahman Please provide these scripts at
#!/usr/bin/sh
flatpak-spawn --host code "$@" && exit
zenity --name='godot_editor' --class='godot' --error --title='Godot: .NET External Editor' \
--window-icon="/app/share/icons/hicolor/scalable/apps/org.godotengine.GodotSharp.svg" \
--no-wrap --text="\
Trying to run external editor <b>VS Code</b> failed: EXIT_STATUS=$?.
Ensure the <b>code</b> program is available outside Flatpak via command line.
Or provide a custom command in the <b>editor settings</b>, e.g.:
<b>dotnet/editor/external_editor:</b> Custom
<b>dotnet/editor/custom_exec_path:</b> flatpak-spawn
<b>dotnet/editor/custom_exec_path_args:</b>
--host flatpak run com.visualstudio.code <i>{project}</i> -g <i>{file}</i>:<i>{line}</i>:<i>{col}</i>
You can also disable this editor setting to use the internal script editor:
<b>dotnet/editor/external_editor</b>"
Note: for people who use Codium (or Code-OSS, etc), it will also work directly if they were already redirecting the
#!/usr/bin/sh
flatpak-spawn --host monodevelop "$@" && exit
zenity --name='godot_editor' --class='godot' --error --title='Godot: .NET External Editor' \
--window-icon="/app/share/icons/hicolor/scalable/apps/org.godotengine.GodotSharp.svg" \
--no-wrap --text="\
Trying to run external editor <b>MonoDevelop</b> failed: EXIT_STATUS=$?.
Ensure the <b>monodevelop</b> program is available outside Flatpak via command line.
Or provide a custom command in the <b>editor settings</b>, e.g.:
<b>dotnet/editor/external_editor:</b> Custom
<b>dotnet/editor/custom_exec_path:</b> flatpak-spawn
<b>dotnet/editor/custom_exec_path_args:</b>
--host /path/to/monodevelop <i>{file}</i>;<i>{line}</i>;<i>{col}</i>
You can also disable this editor setting to use the internal script editor:
<b>dotnet/editor/external_editor</b>"
This method won't work for Rider because it's not relying on PATH environment variable. It's doing some complex logic to detect its installation path (e.g. inside |
@geekley Thanks so much for your recent suggestion. I really do appreciate it, and sorry for both the ping and the lateness of my reply. However, I recently tried out your original proposed solution (either installing the .NET SDK natively or hardcoding the SDK path in our chosen editor to the I tried working with a non-Flatpak build of Codium with the Flatpak initially and was surprised to have gotten IntelliSense and code completion working initially, not realising that Codium defaulted to the version of .NET that I already had installed on my system. I then tried hardcoding That was with my natively installed build of Codium, though, so I decided to try it with a freshly installed Flatpak build of Codium for the sake of completeness, and I did get it to load when running it through the Godot editor itself, but I'm still not getting code completion that way just yet. The problems I'm having here boil down to the As for Rider, as shown in the screenshot taken by @zocker-160 (sorry for the ping) in this comment, it may be worth trying to set the C# runtime there to the absolute path of the Flatpak's custom .NET SDK as we would do in VSCode/Codium (by selecting What I want to do is get the specific information on at least running VSCode or Codium (both native and Flatpak), and more general information on running other editors, with this Flatpak into either README.md or its own Markdown file, and add the link to the relevant information in the AppData description. Once I do, I'll open a PR with the included information in the README.md. Hopefully I don't have to make any massive changes to the Flatpak manifest itself. I plan to do the same for |
Just to clarify, I made 2 proposals to tackle the 2 separate issues described here. They aren't mutually exclusive, because each is trying to solve a different issue:
(1) is because having wrapper scripts to escape the sandbox would make those settings behave as they would outside Flatpak - which is better than having to explain everything in the README and requiring custom setup. (2) was just a reply to zocker-160 saying it may be possible to set up the IDE to work with fatpak'd Godot, but that's IMO out-of-scope here (IDE setup is up to the user) - except maybe by adding instructions in README like I said above. |
I remember back when I used flatpak'd Codium, I had to do this i.e., add |
@geekley no I respectfully disagree with your second point. This might be only a minor issue for "normal" distros, but it is a big deal for immutable distributions which do (almost) solely rely on Flatpak for their applications. It is not about having slightly different versions of .NET in editor vs Godot, it is about not being able to rely on .NET existing on the host at all + IDE also running in a Flatpak. Unless I am missing something, from my testing I came to the conclusion that this use case is hitting a limitation of Flatpak itself since I could only make it work with some major and ugly hacks, that can and will stop working randomly. |
From here, I have a few suggestions:
To demonstrate my latter suggestion, in flatpak-spawn --host code "$@" && exit we could instead run (flatpak-spawn --host code "$@" || flatpak-spawn --host flatpak run com.visualstudio.code "$@") && exit so that it tries running a natively installed version of VSCode first, then it tries looking for a Flatpak'd version. This way, the script works even for immutable distros that will almost only use Flatpaks for apps. We could do the same for Rider as well, and maybe even MonoDevelop for those who, instead of building and installing it natively, may want to build and install the Flatpak'd version of it themselves using flatpak-builder, which can be installed as a Flatpak. Come to think of it, if this works, we could also do the same for Blender, in both this and the standard Flatpak. From what I understand now, @geekley's point of the simple shell scripts is so that, when Godot itself is looking for a Sorry for all the pings, by the way. |
Heck, if we end up applying both of the above suggestions, then, per geekley's comment, we could run this in (flatpak-spawn --host code "$@" || flatpak-spawn --host FLATPAK_ENABLE_SDK_EXT=* flatpak run com.visualstudio.code "$@") && exit And hopefully that would work as it should. |
Like I said above, for Rider/Fleet it's not that simple, as the executable it'll try to call depends on very complex upstream code (I've used ILSpy on a dll in GodotTools to investigate how it works). So it can't be solved with wrapper scripts - that is, assuming this problem even exists for Rider at all (which I'm not testing since I don't have it installed). As for Flatpak-only systems, there's also the need to test this, i.e. if .NET SDK included in Godot-flatpak can be used from another flatpak, the IDE; preferably testing on such immutable systems:
|
I'll admit that, due to my own misunderstanding, I somehow thought the complex upstream code you repeatedly kept mentioning was in Rider itself until I read this🤦♂️ I am willing to look into said upstream code for myself to see if/where anything could be done, as I don't want to give up on this just yet. @geekley (sorry for the ping) Please can you tell me which DLL you dissassembled with ILSpy so that I can try investigating it myself as well?
I assume that installing this Flatpak, with the |
@Zishan-Rahman You should see the method logged in Godot Editor when it fails to find Rider (it's not installed). There's methods for each OS. The Linux code was doing stuff like loading some settings JSON file to find a possible path to add to the list, finally adding the But I don't know for sure it doesn't work (as I think it would be possible to access both Rider paths, local and snap, from this Flatpak), so it's better to install Rider or Fleet first and see if there's even an issue at all with opening C# scripts from Godot. |
It was something similar to this: https://github.com/JetBrains/resharper-unity/blob/0b25daf05acebdc1a0acd3d2c71d27294286acd0/unity/PathLocator/RiderPathLocator.cs#L60 Referenced from here I think: https://github.com/godotengine/godot/blob/master/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs |
I noticed the description mentions the Flatpak doesn't support external C# script editors. However, this is critical because Godot with C# support isn't really worth using if you can't use an external editor. The built-in editor for C# is very limited (it lacks autocompletion), so pretty much everyone using C# is using an external editor with it.
What are the roadblocks to using external C# editors that external GDScript editors don't have to deal with?
The text was updated successfully, but these errors were encountered: