godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.48k stars 148 forks source link

Incomplete readme's configuration section for Windows & Powershell #570

Closed WebF0x closed 5 months ago

WebF0x commented 6 months ago

Godot version

v4.2.stable.official [46dc27791]

VS Code version

1.85.1

Godot Tools VS Code extension version

1.3.1

System information

Windows 10

Issue description

Current

I'm following the Readme, but can't figure how to get setup with Windows & Powershell

Expected

Steps to reproduce

  1. VSCode
  2. In settings.json, delete the line for godot_tools.editor_path
  3. Help
  4. Show All Commands
  5. Godot Tools: Open workspace with Godot editor
  6. A file dialog opens, pick the Godot executable, e.g."c:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe"
  7. Terminal shows this error
    PS C:\Users\Dupui\Desktop\GodotProjects\BrickBreaker> "c:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" --path "c:\Users\Dupui\Desktop\GodotProjects\BrickBreaker" -e
    At line:1 char:95
    + ... ps\common\Godot Engine\godot.windows.opt.tools.64.exe" --path "c:\Use ...      
    +                                                              ~~~~
    Unexpected token 'path' in expression or statement.
    At line:1 char:1
    + "c:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.win ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The '--' operator works only on variables or on properties.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
  8. Following this Stack Overflow answer. Manually running the command prefixed with an ampersand (&) seems to solve it. It launches the Godot engine. E.g. & "c:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" --path "c:\Users\Dupui\Desktop\GodotProjects\BrickBreaker" -e
DaelonSuzuka commented 6 months ago

The instructions in the readme are for the current master branch, not 1.3.1. The command you're using has been completely reimplemented, so whatever documentation you're following is probably not relevant to you.

Unfortunately, I'm out of town at the moment, but I'll investigate this further when I get home.

WebF0x commented 5 months ago

@DaelonSuzuka ah good to hear! So maybe you just need to release a new version so we can use it in VSCode

The Readme instructions are for MacOS though, it would be nice to have instructions for Windows

WebF0x commented 5 months ago

Trying with the master branch.

WebF0x commented 5 months ago

Trying with the master branch.

WebF0x commented 5 months ago

Trying with the master branch.

Using this launch.json file:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch",
      "type": "godot",
      "request": "launch",
      "project": "${workspaceFolder}",
      "address": "http://127.0.0.1",
      "port": 6005,
      "scene": "main",
      "editor_path": "c:/Program Files (x86)/Steam/steamapps/common/Godot Engine/godot.windows.opt.tools.64.exe",
      // engine command line flags
      "profiling": false,
      "single_threaded_scene": false,
      "debug_collisions": false,
      "debug_paths": false,
      "debug_navigation": false,
      "debug_avoidance": false,
      "debug_stringnames": false,
      "frame_delay": 0,
      "time_scale": 1.0,
      "disable_vsync": false,
      "fixed_fps": 60,
      // anything else
      "additional_options": ""
    }
  ]
}
DaelonSuzuka commented 5 months ago

"address": "http://127.0.0.1", why have you added the http:// here?

Why are using all of those flags when they're all false and not related to what you're debugging?

Just use the minimal example and don't overcomplicate things:

{
    "name": "Launch",
    "type": "godot",
    "request": "launch"
}
WebF0x commented 5 months ago

both examples in the Readme don't work Neither does the above config where I experimented with some stuff (namely the http thing from this post and changing ports to match Godot settings)

WebF0x commented 5 months ago

Right now it fails silently, we would need error messages

For example "editor_path": "c:/Program Files (x86)/Steam/steamapps/common/Godot Engine/godot.windows.opt.tools.64.exe" I'm guessing it's forward slashed, but maybe it's backslashes idk. The tooltip doesn't show any example and no error messages means we can't fix our mistakes

DaelonSuzuka commented 5 months ago

Right now it fails silently, we would need error messages

There are a ton of error messages. It validates that the executable exists, that it's actually Godot, that the executable's version matches the version of the current project. If you're truly getting nothing, than I question if you're actually running the 2.0.0 branch.

The new debugger interface also has logging, which is visible here:

image

WebF0x commented 5 months ago

Thanks I didn't know to look there for the logs, I was expecting some kind of red squiggly lines in the config file or something like that.

These are my logs

2024-01-21 23:45:17.787 [info] Stopping debug controller
2024-01-21 23:45:17.792 [info] Stopping debug controller
2024-01-21 23:45:18.093 [info] Creating debug session
2024-01-21 23:45:18.094 [info] Project version identified as 4.2
2024-01-21 23:45:18.107 [info] Starting debug controller in 'launch' mode
2024-01-21 23:45:18.185 [info] Starting game process
2024-01-21 23:45:18.185 [info] Verifying version of '"c:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe"'
2024-01-21 23:45:18.185 [info] Got version string:
2024-01-21 23:45:18.185 [info] Launching game process using command: '""c:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe"" --path "C:\Users\Dupui\Desktop\GodotProjects\TestProjectVscode" --remote-debug "tcp://127.0.0.1:56044" --breakpoints "res://character.gd:7"'

It does not start the game, so no breakpoints kick in either

image

The double quotes around the Godot .exe is kinda weird. The reason I put quotes in the extension settings is because otherwise I get this error

2024-01-21 23:51:33.183 [info] Stopping debug controller
2024-01-21 23:51:33.193 [info] Stopping debug controller
2024-01-21 23:51:33.493 [info] Creating debug session
2024-01-21 23:51:33.493 [info] Project version identified as 4.2
2024-01-21 23:51:33.508 [info] Starting debug controller in 'launch' mode
2024-01-21 23:51:33.544 [info] Starting game process
2024-01-21 23:51:33.544 [info] Verifying version of 'c:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe'
2024-01-21 23:51:33.544 [info] Got version string:
2024-01-21 23:51:33.544 [warning] Cannot launch debug session: 'c:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe' is not a valid Godot executable
WebF0x commented 5 months ago

In case it rings a bell I also notice this extension error: "Cannot read properties of undefined (reading 'extended_classes')"

image

DaelonSuzuka commented 5 months ago

The double quotes are definitely a problem. The quotes are there in the first place to protect against paths with spaces in the name, and because of the doubles, the path is no longer quoted at all.

I'll look at improving the input validation and maybe specifically detecting and fixing double quotes.

Personally, I would never use the Steam version of Godot because I'm a control freak and I want to be in absolute control of what versions of development tools I'm using. I have a folder C:/Godot that I put all my Godot exes in, and I've added that folder to my system path, and therefore my editor_path is just godot3 or godot4.

I'll also download Godot from Steam just to test it out, although it really shouldn't make a difference beyond the path having a bunch of spaces in it.

DaelonSuzuka commented 5 months ago

@WebF0x Can you install the extension from this build artifact:

https://github.com/godotengine/godot-vscode-plugin/actions/runs/7632154415/artifacts/1190053860

PR #575 fixes several problems related to debug configurations.

WebF0x commented 5 months ago

@DaelonSuzuka Thanks with your new build the debugger works for me 🎉

Recommendations for next steps

Tests

Here are some tests with your build. With different godotTools.editorPath.godot4 I tried to launch the Godot editor and the debugger:

Backslashes and quotes (Godot editor❌ Debugger ❌ )

image image image

Backslashes and no quotes (Godot editor❌ Debugger ✔️ )

image image image

Forward slashes and quotes (Godot editor❌ Debugger ❌ )

image image image

Forward slashes and no quotes (Godot editor❌ Debugger ✔️ )

image image image

DaelonSuzuka commented 5 months ago

I feel like this discussion would not be complete without cursing Microsoft for allowing spaces in paths: It was a truly insane decision, and everybody involved should be hit with sticks until they repent.

Once more, with feeling:

https://github.com/godotengine/godot-vscode-plugin/actions/runs/7635374030/artifacts/1190671209

Fix the command to launch the Godot editor from VS Code Tests

You could have saved yourself a bunch of time by just saying "hey, spaces also break the 'open editor command'".

  • In the Readme:

    • examples of correct paths
  • In the godotTools.editorPath.godot4 settings description:

    • clarify what makes a path correct (e.g. "Must use forward slashes, without surrounding quotes")

Literally any valid path. Forward or backslashes don't matter, enclosing quotes don't matter (anymore).

validation right in the settings windows, with a red error message like this one (fail fast!)

This isn't possible. There's no json-schema format type for "a path to a file that exists".

WebF0x commented 5 months ago

@DaelonSuzuka works like a charm, thanks for your quick help!

cursing Microsoft

Hell yeah. I work on a Mac and anytime I do a pet project on Windows it's a pain!

You could have saved yourself a bunch of time by just saying "hey, spaces also break the 'open editor command'".

Ambiguity means more back-and-forths. You understood what I meant, that's a win in my book!

I'm excited to go try this extension now, I think it will be much better than the default Godot editor!

WebF0x commented 5 months ago

Done

DaelonSuzuka commented 5 months ago

works like a charm

Awesome! Thanks for your help in confirming it's fixed.