Sublime Forum

Error Loading syntax file, JSON error

#1

On opening Json file ( was editing build system) I am getting this error, also syntax higlighting is not working in JSON files.

OS: Win 10
Sublime Text - 3

0 Likes

Error after upgrading to ST 4
#2

Tools menu -> Browse Packages
and delete your JavaScript/JSON.sublime-syntax override file so that ST will use it’s built in one

0 Likes

#3

Is it the default file ? and where is it located I can’t find it.

0 Likes

#4

Did you disable the JavaScript package?

1 Like

#5

My bad, I actually did disabled Javascrpit package. But now after enabling it the error is gone but the syntax highlighting is not working in Json files.

0 Likes

#6

I hope it is okay to re-open an old topic. I want to add this note for anyone running into this after a version 4 upgrade and subsequent downgrade back to version 3. My observations are for Linux.

I installed the version 4 update and then was dismayed by the upgrade fee and went back to version 3.2.2. I then saw the same Javascript/JSON message that is cited here. I deleted the version 4 directory, thinking it was loading something from there, but that did not help.

I disabled the Javascript package as suggested here, but the error remained.

I did “locate JSON.sublime” and the found ~/.cache/sublime-text-3/Cache/JSON/JSON.sublime-syntax.cache/rcache and the same in ~/.config/. I deleted those, but the error returned on restarting the editor.

I did “grep -rs JSON.sublime ~/.config/sublime_text_3” and found an entry in Session.sublime_session for “syntax”: “Packages/JSON/JSON.sublime-syntax”. I deleted that line and now the message is gone.

I hope this save someone else some time.

0 Likes

#7

This sounds like you may have had a a JSON file open? The state of the editor, including the syntaxes used for files, is persisted into the session information so that it can be recovered on startup.

In the rare case that a syntax changes or goes away (say you remove a package that added one), Sublime will keep trying to use the same syntax until you close and re-open the file, which will allow it to either find the new one or decide that there’s no matching syntax.

0 Likes

#8

No, I only had PHP files open. If fact, I have never worked with a JSON file. It’s not something I do in my work.

0 Likes

#9

I’m facing the same issue. It started happening just 1-2 days ago. I’m using Sublime Text on Ubuntu 20.04

0 Likes

#10

It appears this had started after upgrade to Sublime Text 4. Tried reverting to old versions but didn’t work. Only after I deleted sublime text directories in ~/.config and ~/.cache and reinstalled version 4, it worked.

0 Likes

#11

JSON syntax was moved from JavaScript to its own JSON package as it more widely used.

Two reasons may cause an error message after upgrading:

  1. At least one JSON file is open. As syntax is assigned when opeing a file only, it may have pointed to the old no longer existing syntax definition.
  2. A syntax cache file of the old syntax remained in ~/.cache which is referenced by something. It points to a no longer existing syntax definition.

Reinstalling the whole application doesn’t help in such situations because files causeing such issues keep untouched then.

Closing and reopening files should be the first step.

Followed by removing ~/.cache should always be and then renaming/removing ~/.config/sublime-text/local/session_file which may contain some references to such caches.

This may help loosing all settings and plugins.

related:

2 Likes

Sublime 4 Plugin not working