After update
Error loading syntax file “Packages/PHP/PHP.sublime-syntax”:
Apparent recursion within a with_prototype action: 25000 context sanity limit hit
Syntax Highlight Error after update Build 4186
I’m seeing the same issue with the Django Syntax plugin (in HTML files, specifically).
Does it happen in safe mode? Can you provide an example file that reproduces the issue?
Plain PHP
PHP uses push...with_prototype
only to support regexp patterns in strings, which is known to be safe.
I’d suggest checking for possible out-dated PHP package overrides. A loong time ago, PHP used to use that strategy to combine HTML and PHP source, which already caused that kind of issues back in the days.
I even just about to work on/with PHP Blade templates, which extend PHP and still work fine on ST4186/87
Django Syntax
With Django Syntax this is still true today. This kind of implementation no longer works due to complexity all involved syntaxes reached.
I’d suggest to use Jinja2 instead, which uses an up-to-date implementation.
I can reproduce this in safe mode:
The syntax file involved: https://github.com/willstott101/django-sublime-syntax/blob/master/Django%20HTML.sublime-syntax
It’s since build 4186, and still present in build 4189.
Steps to reproduce:
- Start Sublime Text in safe mode
subl --safe
- Install Package Control
- install Django Syntax with
Package Control
- Just any (html) file with
Django Syntax -> Django HTML
will give thecontext sanity limit
error.
Example html, just in case:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
From the message from @deathaxe I understand the way the syntax file is build up is not “up-to-date” to current standards.
Any pointers on this would be helpful: Should the syntax file be made up-to-date (and if so, how), or should this still work and can this be considered a bug?
This issue is triggered by adding html syntax highlighting of tagged template tags in JavaScript , which causes an inclusion loop for all syntax definitions still using push .. with_prototype
to extend HTML.sublime-syntax.
For details refer to: https://github.com/sublimehq/sublime_text/issues/6555
That being said, Django Syntax is just one of them. I’d recommend to replace it by Jinja2 package, which provides even more accurate highlighting.
If something Django specific is missing, feel free to open an issue and we can look into adding it. Django templates are just Jinja2 templates with some extensions. Hence there’s actually no reason for all the different packages.
Problem occurs also with the packages:
Naomi
Naomi-syntax
I want to add that PHP-programs love to wrap javascript in php, and also HTML in PHP-code.
If Sublime is unable to meet this features (as worked before without problems), you may count me out and am I migrating to the free Visual Studio Code.
The support I am getting for paying Sublime is … really embarrassing.
Ans as you may expect, the ninja2 solution doesn’t work well either (no errors, but highlighting is bad for javascript embedded in PHP).
What’s wrong with ST’s default PHP syntax? It is based on HTML and supports highlighting CSS, JavaScript, JSON all with as proper as possible PHP interpolation, leveraging everything ST’s syntax engine offers. Much work has been put into all of those to support most relevant language related features. They are - in many cases - way better than those old “BetterXYZ” packages like Naomi.
And as this is the first time Naomi has been mentioned!! - It has already caused issues various times in the past, as it hacks with all sorts of core syntaxes in ways which must fail as those evolve.
Maybe try default syntaxes first and if there’s something you are missing file an issue at https://github.com/sublimehq/Packages.
The issue discussed in this topic is actually caused by adding as many long requested features as possible to core syntaxes, which now causes syntax definition complexity to explode by how various legacy ST3 packages extend/use them.
That being said Jinja2 package is completely unrelated to PHP. Jinja2 is a python template language, which is very similar to Django Templates and thus was suggested as alternative for those having trouble with existing Django packages.
Maybe don’t expect Naomi (ST3 package) to receive any updates to fix that issue, with regards to https://github.com/borela/naomi/issues/261 from 2020.
In the end I have done the only thing I can do: Complete reinstallation.
- Complete backup of Sublime in /Applications and ~/Library/Applications Support/Sublime Text
- Complete remove all in /Applications and ~/Library
- Download latest version (version 4192).
- Install
- Enter the license.
And it works again. Many thanks to all the help. It has not helped me very much, even the reinstall is not been described in detail.
So, Sublime is great, support is less good, description of the installed extension poor.
Calling Package Control: Remove Package and selecting Naomi should have been enough, assuming the setup was not completely winded up, already.
Re-installing the application wouldn’t have been required, as the reason was a misbehaving and unfortunatelly no longer compatible unpaid/open source 3rd-party package, all of which live in user-profile folder.
Process of resetting packages to freshly installed state are described at https://www.sublimetext.com/docs/revert.html. There’s not much to say about though, as it just means to rename/delete a folder.
More detailed description of installation process can be found at https://docs.sublimetext.io/guide/getting-started/installation.html.
Naomi has been removed without the requested result. The removal should have been part of the installation (as many do). The PHP folder in the Application Support is the blame of all. Removing this folder leads to no PHP support selectable/available, and with this folder results in the already given error.
The fresh installation does not need this strange required PHP folder and works as expected.
So where does this old PHP folder installation is coming from? On my other macbook (with an older installation) the folder was not installed.
ST’s default packages (which PHP belongs to) and majority of 3rd-party packages are deployed as zipped <name>.sublime-package
files to hide unneccesary details.
Any file located in Packages folder (see: Main Menu > Preferences > Browse Packages…) overrides corresponding files from *.sublime-package files. That’s part of ST’s “customizability”.
Thus removing PHP folder (and maybe restarting ST) should have been enough to revert to default PHP. It not being the case is weird. It would mean original file not being present. No idea how that can happen.
There are various tools like PackageResourceViewer which can be used to override single files or extract whole packages. I am not aware of any other automatic way how such override could have been produced. ST or its updater don’t touch any such file/folder.
But I’ve seen various reports so far, which were related with or caused by out-dated overridden package resources. This shouldn’t however happen to users which just install packages.
One possibility to detect unwanted overrides is OverrideAudit plugin. It creates reports about overridden package resources and provides sane/safe commands to manage them.