godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.15k stars 19.96k forks source link

Win32Exception on Ubuntu when opening c# script via external editor #89415

Open Tshadow999 opened 5 months ago

Tshadow999 commented 5 months ago

Tested versions

Tested on Godot v4.2.1.stable.mono (b09f793f5)

System information

Godot v4.2.1.stable.mono (b09f793f5) - Freedesktop SDK 23.08 (Flatpak runtime) - X11 - Vulkan (Mobile) - dedicated AMD Radeon RX 6700 XT (RADV NAVI22) () - AMD Ryzen 7 7700X 8-Core Processor (16 Threads)

Issue description

I want to use neovim in order to edit c# scripts. I made a bash script which will open a terminal and then run neovim from there. When I click a c# script to open it I get the Win32Exception.

Expectation: run the bash script

Full error for completeness:

  /run/build/godot-tools/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:112 - System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'home/tycho/Programming/Games/connect_godot.sh' with working directory '/home/tycho/Programming/Games/Clicker'. No such file or directory
     at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
     at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
     at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
     at GodotTools.Utils.OS.RunProcess(String command, IEnumerable`1 arguments) in /run/build/godot-tools/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs:line 241
     at GodotTools.GodotSharpEditor.OpenInExternalEditor(Script script, Int32 line, Int32 col) in /run/build/godot-tools/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs:line 253
     at GodotTools.GodotSharpEditor.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /run/build/godot-tools/modules/mono/editor/GodotTools/GodotTools/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/GodotTools.GodotSharpEditor_ScriptMethods.generated.cs:line 160
     at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret) in /run/build/godot-tools/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs:line 24

Steps to reproduce

Make new project, add a scene and attach c# script.

in editor settings under dotnet: External Editor = Custom Custom Exec Path = path to bash file. example: "/home/username/remote_godot.sh Custom Exec Path Args = {project}

The Bash file

#!/bin/dash

echo $1

# If there is no second argument from godot
if [ "$1" ==  "$0" ]; then
    gnome-terminal -- nvim
else
    gnome-terminal -- nvim $1
fi 

Also add execution rights to this file in terminal: chmod +x path_to_file.sh

Minimal reproduction project (MRP)

project.zip

paulloz commented 5 months ago

Hello 🙂
Can you double-check the path configured in dotnet/editor/custom_exec_path_args? The error hints that it might lack a / at the beginning:

An error occurred trying to start process 'home/tycho/Programming/Games/connect_godot.sh'
Tshadow999 commented 5 months ago

I think I copied something wrong when writing this, the same happens with the / in the beginning Here is the error when I do that:

/run/build/godot-tools/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:112 - System.ComponentModel.Win32Exception (2): An error occurred trying to start process '/home/tycho/programming/games/connect_godot.sh' with working directory '/home/tycho/programming/games/Clicker'. No such file or directory
     at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
     at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
     at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
     at GodotTools.Utils.OS.RunProcess(String command, IEnumerable`1 arguments) in /run/build/godot-tools/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs:line 241
     at GodotTools.GodotSharpEditor.OpenInExternalEditor(Script script, Int32 line, Int32 col) in /run/build/godot-tools/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs:line 253
     at GodotTools.GodotSharpEditor.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /run/build/godot-tools/modules/mono/editor/GodotTools/GodotTools/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/GodotTools.GodotSharpEditor_ScriptMethods.generated.cs:line 160
     at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret) in /run/build/godot-tools/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs:line 24

Edit : typo

akien-mga commented 2 weeks ago

Can you confirm that /home/tycho/programming/games/connect_godot.sh exists and has executable permission? (E.g. with ls -l /home/tycho/programming/games/connect_godot.sh)

Tshadow999 commented 2 weeks ago

It does exist and I had already given it all the rights.

I did manage to find a different solution to this, instead of changing dotnet/editor/external_editor, change text_editor/external/use_external_editor. And that seems to work quite well.