Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vinsworldcom opened this issue Mar 17, 2023 · 3 comments
Closed

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

vinsworldcom opened this issue Mar 17, 2023 · 3 comments

Comments

@vinsworldcom
Copy link

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

image

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

Cheers.

@molsonkiko
Copy link
Owner

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
Copy link
Author

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

static void SetSchemasToFnamePatternsFname()
{
string config_dir = Npp.notepad.GetConfigDirectory();
schemasToFnamePatternsFname = Path.Combine(config_dir, Main.PluginName, "schemasToFnamePatterns.json");
}

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
Copy link
Owner

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.

molsonkiko added a commit that referenced this issue Mar 17, 2023
FIXED
Bug where users who didn't have a JsonTools directory
    in the config folder would get a plugin crash on startup.
    Now a config subdirectory is automatically created if it doesn't
    already exist. This bug also existed with the
    `JSON from files and APIs` form, but now it has been solved in both places.
@molsonkiko molsonkiko pinned this issue Mar 17, 2023
@molsonkiko molsonkiko changed the title 4.11 crashes Notepad++ 8.5 4.11 crashes Notepad++ 8.5; SOLUTION: install 4.11.1 Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants