Skip to content

Addon: Error when running the formatter with safe mode + reorder code both active #286

Description

@CosmoMyzrailGorynych

Godot v4.7.1, Fedora Linux, installed through Flatpak. Godot has full filesystem access.
The binary is present at /home/comigo/.var/app/org.godotengine.Godot/cache/godot/gdquest/gdscript-formatter, has the +x flag. The plugin's settings do point at this location.

Throws this on every format command (tried with different scripts, all are valid and working in-game):

  ERROR: core/variant/variant_utility.cpp:1023 - Format GDScript failed: res://roguelite/relics/embedded_starfish.gd
  ERROR: core/variant/variant_utility.cpp:1023 - 	Exit code: 1 Output: 
  ERROR: core/variant/variant_utility.cpp:1023 - 	If your script does not have any syntax errors, this might be a formatter bug.

Running the executable in style ./gdscript-formatter /path/to/file.gd does work and change the file (and makes mistakes, will open a separate issue if there isn't one for that case).
Still, it doesn't run in Godot. I tried disabling other script editor-related plugin, restarted, and it didn't help.

Activity

  1. silviohfc commented on Jul 21, 2026

    @silviohfc

    Same problem here, with Godot .NET and GDScript in a Mac Tahoe 26.5.
    I tried updating by Format > Install or Update Formatter menu, but still not working.

  2. added theissue type on Jul 22, 2026
  3. changed the title [-]Doesn't work and idk how to troubleshoot it[/-] [+]Addon: Error when running the formatter after install[/+] on Jul 22, 2026
  4. self-assigned this
    on Jul 22, 2026
  5. NathanLovato commented on Jul 22, 2026

    @NathanLovato
    Contributor

    Could you please show me how you point at the binary in the editor settings? Do you use an absolute path? Just the binary name?

  6. PixelSaver commented on Jul 22, 2026

    @PixelSaver

    Having the same issue (endeavor os - arch linux 4.7.1 stable installed through pacman). It's listed as the absolute path to it:
    /home/{USER}/.cache/godot/gdquest/gdscript-formatter

    I did also make it an executable and then run it in the cli, which it did work (just repeating what OP said)

  7. CosmoMyzrailGorynych commented on Jul 22, 2026

    @CosmoMyzrailGorynych
    Author

    Could you please show me how you point at the binary in the editor settings? Do you use an absolute path? Just the binary name?

    I didn't do anything manually. I ran the command the readme tells to download/update the binary, and it set the real absolute path to the executable.

  8. NathanLovato commented on Jul 23, 2026

    @NathanLovato
    Contributor

    Could you please try this version? It has a small patch. I'm not getting the issue on my test machines, so I'm not exactly sure yet what's happening. At least this update captures any errors reported by the formatter or while "installing" it.

    You can replace your copy of the addon with the files in there, then run install or update formatter, and on your script: Format -> Format Current Script

    addons.zip

    Then if it fails, please copy paste the output from the Output bottom panel. Normally it should include any error message the formatter itself reports. Could you also please tell me if you use any particular settings for the add-on? Like the safe mode in the editor settings.

  9. PixelSaver commented on Jul 23, 2026

    @PixelSaver

    Just redownloaded, heres the output:

      ERROR: core/variant/variant_utility.cpp:1023 - Format GDScript failed: res://utilities/ui/pixel_menu.gd
      ERROR: core/variant/variant_utility.cpp:1023 - 	Exit code: 1 Output: Formatting 1 file...Error: "Failed to format file /tmp/gdscript_formatter_72609.gd: Safe mode: formatted output is structurally different from input. Keeping original source."
      ERROR: core/variant/variant_utility.cpp:1023 - 	If your script does not have any syntax errors, this might be a formatter bug.
    

    wait I tried it without safe mode and it works...

    Image These are the settings I used (and it works without safemode and it fails with it on)

    Hope that helps!

  10. NathanLovato commented on Jul 23, 2026

    @NathanLovato
    Contributor

    Thanks! Okay, I see, if you use reorder with safe mode it's normal that it fails, the settings are not compatible at the moment. I'll think of a way to change this to warn you about this.

    Safe mode reparses the file after formatting and verifies that the the syntax tree is the same as before formatting. But when reordering we change the order of function so that changes the parsed syntax tree which triggers the safe mode safety.

    I generally don't recommend turning on reordering at all times personally, but rather running it manually occasionally because an automatic order is not necessarily ideal for following along your code. It works well for small scripts but it's not necessarily productive for larger code files.

  11. CosmoMyzrailGorynych commented on Jul 23, 2026

    @CosmoMyzrailGorynych
    Author

    Replicated what PixelSaver received.
    Confirming that turning safe mode off does format the code successfully.
    Also found a new formatter bug :) 😅 Will open/lookup an issue.

    I generally don't recommend turning on reordering at all times personally, but rather running it manually occasionally because an automatic order is not necessarily ideal for following along your code.

    Yeah, but code standards are standards, and the best way to enforce them is to make them unavoidable (equals "automatic" here). Ideally there should be tweaks to make this or that more lax, and I guess they will come with time.

    I'll think of a way to change this to warn you about this.

    Perhaps make the binary do a simple flag check and bail out early with an error message with something along "Safe mode cannot be combined with reordering", as the errors will now be properly logged in the Output panel in Godot?

  12. changed the title [-]Addon: Error when running the formatter after install[/-] [+]Addon: Error when running the formatter with safe mode + reorder code both active[/+] on Jul 24, 2026
  13. NathanLovato commented on Jul 24, 2026

    @NathanLovato
    Contributor

    Yeah, but code standards are standards

    For code style, it's actually guidelines, it's not hard rules. The code order part in particular is something to help beginners reduce cognitive load or for people who really like strict consistency.

    Closed by #296

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions