el-falso / gdlinter

This plugin runs `gdlint` on save to automatically lint your GD Script as you code.
https://godotengine.org/asset-library/asset/2520
MIT License
15 stars 5 forks source link

Probably a brazen and daring request for help #3

Closed ThisisHappyEL closed 5 months ago

ThisisHappyEL commented 6 months ago

I really wanted to start my journey to Godot “right”, and therefore I immediately thought about a linter. The installation was successful (sort of). If you run the linting command from a third-party code editor (vs code), the result is working, but, unfortunately, the gdlint window says that the path to gdlint was not found.

I was looking for a solution to this problem, but it feels like I'm the only one who encountered this

el-falso commented 6 months ago

Normally gdlinter just executes the gdlint command on the OS and grabs it's output. What happens when you use the gdlint command in the terminal/console of the OS?

plink-plonk-will commented 5 months ago

I had the same issue when I tried to use this on Mac, even though the toolkit was installed properly and worked fine from a regular Terminal.

On Mac, when you run which gdlint after installing the toolkit, you can see that it's here: ${HOME}/Library/Python/3.9/bin/gdlint.

After further digging, this path is added to your PATH environment variable in your .zprofile when create a zsh session, but this is not executed when a new process is executed with OS.execute. The solution I found was to first query Python to see where the path was, and then use that to create a full path to gdlint.

To do this, I added a function to gdLinter.gd which I used to store the path to gdlinter in the enter_tree function for future OS.execute calls:

func get_gdlint_path() -> String:
    var output := []

    OS.execute("python3", ["-m", "site", "--user-base"], output)
    var python_bin_folder := (output[0] as String).strip_edges().path_join("bin")

    return python_bin_folder.path_join("gdlint")

I'm happy to open a PR with this change in it if you like, but I do not have a Windows (or Linux) machine available for testing with.

el-falso commented 5 months ago

Thank you really much for testing and providing a solution to this issue. I just released version v2.0.0 which includes the fix for this.

https://github.com/el-falso/gdlinter/releases/latest

plink-plonk-will commented 5 months ago

You're welcome! Thank you for releasing a new version :D