molsonkiko / JsonToolsNppPlugin

A Notepad++ plugin providing tools for JSON like linting, querying, a tree view, and CSV conversion.
Apache License 2.0
70 stars 9 forks source link

4.11 crashes Notepad++ 8.5; SOLUTION: install 4.11.1 #30

Closed vinsworldcom closed 1 year ago

vinsworldcom commented 1 year ago

Running the latest release 4.11 results in Notepad++ not starting:

image

The artifact from the previous commit works fine in Notepad++

Cheers.

molsonkiko commented 1 year ago

Oh no... I assume you used the actual release and not the GH actions artifact. This falls into the category of "things that I eventually got to work on my computer but knew in the back of my mind might fail on other people's computers". I really don't know how to run my program on another computer (e.g. with AWS EC2) let alone how to do so automatically. Yeah, what's (probably) going on is that the plugin now looks for a JSON config file at startup (for automatic JSON schema validation) and if it doesn't find it, it writes one. The error message you got looks very similar to one that I got many times before I eventually fixed it (on my machine), and I generally got it when writing to the config file. Assuming that's the issue, here's the relevant code: Lines 95-99 of Main.cs does some setup of the automatic schema validation stuff. The function that is most likely directly causing the issue is at line 784 of Main.cs.

I know it's kind of backwards for the developer to be saying what is probably causing the bug and then not immediately fixing it, but any changes I make wouldn't change the behavior I see, so I'm just sort of hoping someone will care enough to help me out.

If not, I probably just abandon this feature and tell the folks over at the nppPluginList to only list version 4.10.1 of JsonTools on the plugin list.

vinsworldcom commented 1 year ago

I assume you used the actual release and not the GH actions artifact.

I tried both.

The error message you got looks very similar to one that I got many times before I eventually fixed it (on my machine), and I generally got it when writing to the config file.

It's a pretty "generic" error message - I think generated by Notepad++ when a plugin fails so not really giving much information about what is wrong with the plugin.

Assuming that's the issue, here's the relevant code: Lines 95-99 of Main.cs

Yes, that calls SetSchemasToFnamePatternsFname() which is at https://github.com/molsonkiko/JsonToolsNppPlugin/blob/6b2123aafd095238b2390760f36c6a57ea8f37af/JsonToolsNppPlugin/Main.cs#L889-L893

and you can see the issue in line 892 above. You get the Notepad++ config directory, append the plugin name as a further directory and then access a file in that directory. So:

c:\path\to\Notepad++\plugins\config\JsonTools\schemasToFnamePatterns.json

but the "JsonTools" directory does not exist. I have a JsonTools.ini file in the "config\" directory, but no subdirectory for JsonTools. Perhaps you should check for it's existence - and if not, create it - before creating the path to the file?

I manually added that directory:

cd c:\path\to\Notepad++\plugins\config
mkdir JsonTools

and now version 4.11 works fine!

Cheers.

molsonkiko commented 1 year ago

Oh, that makes sense!

I completely forgot when I was adding this feature that the JsonTools config subdirectory was added a while back, and if someone was upgrading from a version before the config directory existed they might have this exact issue.

Thank you for your help.