Closed maniekbezkitu closed 3 years ago
Note: The text I was pasting was ST settings in JSON detected as JSON (Sublime). When I changed syntax to regular JSON the file saved as expected. Seen the same issue with JS (Test) file so maybe it's related to syntax detection or something.
Sublime Text 3/Packages/TypeScript/typescript/listeners/listeners.py
Looks like the TypeScript plugin is causing issues, removing it should resolve this issue. You'd probably want create a bug report on their project page.
I just saw the same, after upgrading to Catalina last night.
In my case, the detected file type is UnitTest (JavaScript)
; changing to just JavaScript allowed me to save the new file as normal. (I'm not even sure what UnitTest
is / what plugin identifies files as such.)
I do have the Typescript plugin installed, but after removing the plugin I can still repro the error. (I'm not sure how to view Sublime error logs, don't have a stack trace)
This only happens when pasting into a new tab, not when making edits to an already-saved tab, so the root issue seems to be related to file creation permissions in Catalina and not file write.
I'm seeing this as well with ST 3.2.2 on macOS Catalina 10.15.4 and 10.15.3.
It does seem related to syntax packages - in my case "HTML (Jinja2)", since changing to a builtin one before attempting to save prevents the problem.
Interestingly if I switch to just the "Jinja2" syntax instead of "HTML (Jinja2)" I do not encounter the problem. Could it be something with parenthesis in the syntax name?
I tried allowing Full Disk Access to Sublime Text from the privacy control panel on the chance that it is related to that, but it seemed to have no effect.
Same here, @cpisto and @maniekbezkitu, running MacOS 0.15.4 (19E266) Saving changes to existing code inside the code directory does work.
This happens to me when attempting to save a new buffer with the mysterious Shell-Unix-Generic
syntax. Changing the syntax to Bourne Again Shell (bash)
makes the save work normally. No console logs in either case.
The Shell-Unix-Generic
syntax isn't selectable in the menu or command palette, but is a built-in package (TIL) and seems to be the default for files named .env
. Pasting a .env
file's contents into a new buffer and attempting to save it reliably reproduces this error.
I don't have either the TypeScript or the Jinja2 plugin.
Sublime Text Version 3.2.2, Build 3211 macOS Catalina 10.15.5
UPDATE (2020-06-26): Tried debugging this again today. Followed the steps above to reproduce, and found the following in the macOS console logs, filtering by process
== sublime text
:
-[NSSavePanel beginServicePanel]_block_invoke : Could not advance an Open/Save panel to run phase due to error: Error Domain=com.apple.ViewBridge Code=16 "(null)" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError}
-[NSSavePanel beginServicePanel] : an exception occurred during attempt to advance an Open/Save panel to run phase!
-[NSSavePanel runModal] caught non-fatal NSObjectNotAvailableException 'The operation couldn’t be completed. (com.apple.ViewBridge error 16.)' with user dictionary {
error = "Error Domain=com.apple.ViewBridge Code=16 \"(null)\" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError}";
} and backtrace (
0 CoreFoundation 0x00007fff3207fbe7 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6ae575bf objc_exception_throw + 48
2 AppKit 0x00007fff2fc70a7d -[NSSavePanel beginServicePanel] + 801
3 AppKit 0x00007fff2fc71268 -[NSSavePanel runModal] + 98
4 Sublime Text 0x000000010fdf7e08 _Z19px_show_save_dialogP11px_window_tRKNSt3__16vectorINS1_4pairI9substringNS2_IS4_NS1_9allocatorIS4_EEEEEENS5_IS8_EEEES4_S4_S4_PNS1_12basic_stringIcNS1_11char_traitsIcEENS5_IcEEEE + 1076
5 Sublime Text
Here's larger log excerpts, filtering all fields first by sublime
and then by save
(can't figure out how to do an 'or' filter):
Looks like the most relevant messages are:
error 15:52:36.547714-0400 tccd Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for RESP:{ID: com.sublimetext.3, PID[797], auid: 501, euid: 501, responsible path: '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text', binary path: '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text'}, ACC:{ID: com.apple.appkit.xpc.openAndSavePanelService, PID[73587], auid: 501, euid: 501, binary path: '/System/Library/Frameworks/AppKit.framework/Versions/C/XPCServices/com.apple.appkit.xpc.openAndSavePanelService.xpc/Contents/MacOS/com.apple.appkit.xpc.openAndSavePanelService'}, REQ:{ID: com.apple.appleeventsd, PID[449], auid: 55, euid: 55, binary path: '/System/Library/CoreServices/appleeventsd'}
error 15:52:36.742264-0400 tccd Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for RESP:{ID: com.sublimetext.3, PID[797], auid: 501, euid: 501, responsible path: '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text', binary path: '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text'}, ACC:{ID: com.apple.quicklook.QuickLookUIService, PID[73588], auid: 501, euid: 501, binary path: '/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/QuickLookUI.framework/Versions/A/XPCServices/QuickLookUIService.xpc/Contents/MacOS/QuickLookUIService'}, REQ:{ID: com.apple.appleeventsd, PID[449], auid: 55, euid: 55, binary path: '/System/Library/CoreServices/appleeventsd'}
error 15:52:36.925992-0400 tccd Prompting policy for hardened runtime; service: kTCCServiceCalendar requires entitlement com.apple.security.personal-information.calendars but it is missing for RESP:{ID: com.sublimetext.3, PID[797], auid: 501, euid: 501, responsible path: '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text', binary path: '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text'}, ACC:{ID: com.apple.appkit.xpc.openAndSavePanelService, PID[73587], auid: 501, euid: 501, binary path: '/System/Library/Frameworks/AppKit.framework/Versions/C/XPCServices/com.apple.appkit.xpc.openAndSavePanelService.xpc/Contents/MacOS/com.apple.appkit.xpc.openAndSavePanelService'}, REQ:{ID: com.apple.mds, PID[192], auid: 0, euid: 0, binary path: '/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Support/mds'}
(Really not sure why Sublime Text has any connection to kTCCServiceCalendar
...)
Found some additional relevant looking info in a GIMP issue. I'll try tinkering with the "full disk access" settings and see if the error goes away, and will update again with the results.
Regardless of cause, I feel like this error ought to be at least detectable from within Sublime Text. Would certainly help debugging to have some sort of in-app console logs available when it happens.
UPDATE (also 2020-06-26): No such luck re: full disk access, but I did figure out how to include debug and info logs in the macOS console.
Most relevant looking excerpt is some additional context on the NSObjectNotAvailableException
:
debug 16:34:59.881942-0400 appleeventsd Event:0x7fc9f1d07090 which means aePort ( port:67923/0x10953 rcv:0,send:0,d:1 limit:0) has gone dead for app "com.apple.appkit.xpc.openAndSavePanelService (Sublime Text)"
info 16:34:59.882307-0400 appleeventsd CONNECTION: releasing app App:"com.apple.appkit.xpc.openAndSavePanelService (Sublime Text)"/"com.apple.appkit.xpc.openandsavepanelservice"/"com.apple.appkit.xpc.openAndSavePanelService" 797/0x0:0x395395 ????0010 sess=100007 because we received error on its connection.
default 16:34:59.882867-0400 Sublime Text -[NSSavePanel beginServicePanel]_block_invoke : Could not advance an Open/Save panel to run phase due to error: Error Domain=com.apple.ViewBridge Code=16 "(null)" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError}
debug 16:34:59.882366-0400 appleeventsd unRegisterApp App:"com.apple.appkit.xpc.openAndSavePanelService (Sublime Text)"/"com.apple.appkit.xpc.openandsavepanelservice"/"com.apple.appkit.xpc.openAndSavePanelService" 797/0x0:0x395395 ????0010 sess=100007
default 16:34:59.883044-0400 Sublime Text -[NSSavePanel beginServicePanel] : an exception occurred during attempt to advance an Open/Save panel to run phase!
debug 16:34:59.883366-0400 launchservicesd bool LSApplication::SetPidToListenForDeathOn(pid_t)_block_invoke(), EVENT-HANDLER got pid-death notification for the application App:"com.apple.appkit.xpc.openAndSavePanelService (Sublime Text)" asn:0x0-395395 pid:797 refs=5 @ 0x7ffab0a25d40 fListeningForProcessDeathOnPid= 797 source=0x7ffab0a601a0
debug 16:34:59.883405-0400 launchservicesd bool LSApplication::SetPidToListenForDeathOn(pid_t)_block_invoke_2(), EVENT-HANDLER cancelling pid-death dispatch source that we set up for the application App:"com.apple.appkit.xpc.openAndSavePanelService (Sublime Text)" asn:0x0-395395 pid:797 refs=6 @ 0x7ffab0a25d40 fListeningForProcessDeathOnPid= 797 source=0x7ffab0a601a0
info 16:34:59.883675-0400 launchservicesd Got exit notification for application App:"com.apple.appkit.xpc.openAndSavePanelService (Sublime Text)" asn:0x0-395395 pid:797 refs=4 @ 0x7ffab0a25d40, pid=797, from port=(MACH_PORT_NULL) fExitStatus=0.
default 16:34:59.885605-0400 Sublime Text -[NSSavePanel runModal] caught non-fatal NSObjectNotAvailableException 'The operation couldn’t be completed. (com.apple.ViewBridge error 16.)' with user dictionary {
error = "Error Domain=com.apple.ViewBridge Code=16 \"(null)\" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError}";
} and backtrace (
0 CoreFoundation 0x00007fff3207fbe7 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6ae575bf objc_exception_throw + 48
2 AppKit 0x00007fff2fc70a7d -[NSSavePanel beginServicePanel] + 801
3 AppKit 0x00007fff2fc71268 -[NSSavePanel runModal] + 98
4 Sublime Text 0x00000001034f4e08 _Z19px_show_save_dialogP11px_window_tRKNSt3__16vectorINS1_4pairI9substringNS2_IS4_NS1_9allocatorIS4_EEEEEENS5_IS8_EEEES4_S4_S4_PNS1_12basic_stringIcNS1_11char_traitsIcEENS5_IcEEEE + 1076
5 Sublime Text
Not sure what it means to "advance an Open/Save panel to run phase", but apparently that's what's failing. (Also not sure why that's failing, but maybe someone with macOS app development experience would know.)
Having the same issue when trying to save a file of syntax type JavaScript (Rails). Changing the syntax of the file to just "JavaScript" allowed the save to occur.
Using Sublime Text 3.2.2, Build 3211 on macOS Catalina 10.15.5.
Same issue with file type 'CMake'. Changed Syntax to Plain Text and save window pops up.
Same issue with 'dotenv' file extension package as well.
So far this seems somewhat configuration dependent, as I haven’t reproduced it yet.
The error message appears to be some sort of Catalina error - although it isn’t clear exactly what causes/triggers it. If anyone does find some more info about this error and how to work around it, or what causes it, that would be helpful. The error itself is coming from macOS and isn’t something that Sublime Text is causing to be shown.
@wbond Thanks for checking in!
I updated my comment above with some macOS console logs I found, and looked into a few possible causes of the error.
Searching for the error text Could not advance an Open/Save panel to run phase
led me to this issue:
looks like passing python array to NSOpenPanel.openPanel().setAllowedFileTypes_ no longer works, have to pass a NSArray instance.
Looks like the fix there is just:
- dialog.setAllowedFileTypes_(["pdf"])
+ dialog.setAllowedFileTypes_(NSArray.arrayWithObjects_("pdf"))
This API change/regression also affected AutoDMG, and seems to originate from macOS' modified version of PyObjC:
it is a regression on the pyobjc version that comes with the system python of Mac OS X 10.15 beta. NSOpenPanel.openPanel().setAllowedFileTypes_ used to accept a python array, but no longer does. so we now have to pass an NSArray instance
This error might affect users differently based on their version of PyObjC:
I cannot reproduce this problem with PyObjC 6 on macOS 10.15.1
W.r.t. PyObjC in macOS: Apple ships an ancient version of PyObjC, with significant local changes to the framework wrappers (with no communication about that).
Not sure why it would only affect certain syntaxes, though.
This comment indicates there might be a slightly different underlying cause:
This is actually a macOS bug! The fix is to remove the leading
.
in the filetypes variable.
The comment links to this issue, which clarifies:
Showing an NSSavePanel where allowedFileTypes contain leading dots hangs the app when the app is sandboxed.
(The actual fix indicates that the freeze is triggered by a dot anywhere in the file types, not just at the start.)
That matches the behavior I observe: the app hangs for about 15 seconds after saving before displaying the error dialog, and the logs seem to indicate that appleeventsd
eventually gives up on it:
debug 16:34:59.881942-0400 appleeventsd Event:0x7fc9f1d07090 which means aePort ( port:67923/0x10953 rcv:0,send:0,d:1 limit:0) has gone dead for app "com.apple.appkit.xpc.openAndSavePanelService (Sublime Text)"
info 16:34:59.882307-0400 appleeventsd CONNECTION: releasing app App:"com.apple.appkit.xpc.openAndSavePanelService (Sublime Text)"/"com.apple.appkit.xpc.openandsavepanelservice"/"com.apple.appkit.xpc.openAndSavePanelService" 797/0x0:0x395395 ????0010 sess=100007 because we received error on its connection.
default 16:34:59.882867-0400 Sublime Text -[NSSavePanel beginServicePanel]_block_invoke : Could not advance an Open/Save panel to run phase due to error: Error Domain=com.apple.ViewBridge Code=16 "(null)" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError}
I'm not sure what's involved in macOS sandboxing, but the "when the app is sandboxed" condition might explain why you haven't been able to reproduce the error yourself.
Previous commenters mentioned a few different syntaxes that trigger this error. I haven't checked the third-party ones yet, but all three built-in syntaxes include a file_extensions
value containing a dot:
Pipfile.lock
js.erb
include
in this syntax file correctly)I can't figure out how to activate the JSON (Sublime)
syntax, but I can reliably reproduce the error by saving a new buffer with JavaScript (Rails)
syntax (or one with Shell-Unix-Generic
syntax, obtained by pasting text from a file named .env
into a new buffer).
BUT, I can't reproduce the error with any of the other built-in syntaxes which have file_extensions
values containing a dot (CSS, several Git- and Rails-related syntaxes, the Bash syntax itself). So I'm not sure whether that's a red herring.
I think this error is caused by a macOS API regression involving the allowedFileTypes
property of NSOpenPanel
/NSSavePanel
, its setter method, or its PyObjC bindings; possibly related either to the type of the provided array, or to the presence of .
characters in its values. But since there's at least two distinct regressions related to this one API, there may be others as well. (Also, apparently that property is deprecated, although I can't find what's supposed to replace it.)
I think that's all the debugging I have in me today, but I hope something in there proves useful, either to you or to other puzzled developers attempting to navigate the web of linked GitHub issues.
I can reliably reproduce this error, so let me know if additional experiments would be helpful.
AHA! I caught my second wind, and have isolated the error by making a copy of the JavaScript (Rails).sublime-syntax
file in my User packages:
%YAML 1.2
---
name: JavaScript (Rails) (copy)
file_extensions:
- js.erb
scope: source.js.rails
contexts:
main:
- match: "<%+#"
scope: punctuation.definition.comment.erb
push:
- meta_scope: comment.block.erb
- match: "%>"
pop: true
- match: "<%+(?!>)[-=]?"
scope: punctuation.section.embedded.ruby
push:
- meta_scope: source.ruby.rails.erb
- match: "-?%>"
pop: true
- match: (#).*?(?=-?%>)
scope: comment.line.number-sign.ruby
captures:
1: punctuation.definition.comment.ruby
- include: "Ruby on Rails.sublime-syntax"
- include: 'scope:source.js'
If I create a new buffer, switch to this syntax, and attempt to save, the error is triggered; but not if I remove the .
from js.erb
.
I can't quite make out the exact conditions that cause the error, but it looks like it depends only on the first value of the file_extensions
list, with a few extra requirements:
.
.
(so the values js.erb.
, or just .
on its own do not trigger the error)1.1
does not trigger the error (gets parsed as a float by the YAML parser?), but "1.1"
does0.1
does not trigger the error, but .1
does (?)-.1
does not trigger the error, but +.1
does (??)!!float 0.1
does not trigger the error, but !!float .1
does (maybe the YAML parser ignores tags?)Pipfile.lock
does not trigger the error (?!?)I'm really not sure what's happening here, but I'm guessing Sublime uses a nonstandard YAML parser, and performs some amount of manipulation/sanitization of the file_extensions
list before passing it to setAllowedFileTypes
(including some kind of special handling of Pipfile.lock
); and if a dot remains in the sanitized first value of that list, then the macOS API bug described in Possibility 2 above is triggered.
(If Sublime doesn't special-case the string Pipfile.lock
, I really can't fathom why it would be immune to the macOS bug. Something to do with macOS' modified PyObjC?)
I also encountered the issue today (Mac OS X 10.15.5.)
My new file only had plaintext info.
When VS Code tried to save the new file, it seemed to take (part of?) the first line content as the file name, which caused the trouble as the first line of my file is
BA 3.1:
Since Mac OS file system takes : as the path separator, I removed the : and the file can be saved without problem.
In my case I encountered this error when creating a abc.spec.js
, the default selected syntax highlight was UnitTest (Javascript)
(which is wired because there is no such option available in the syntax highlight list). After changing syntax highlight to regular Javascript
, the file was saved without error.
@doctaphred Thanks for your work in looking into this and helping reproduce. I was able to reproduce and skipping extensions containing a period seems to fix it!
I tested in Sublime Build 4090, #3735 bug not appears in safe-mode.
This should be fixed in build 4092
Latest and greatest Mar 2, 2021 issue still persists. This time working on JSON syntax... and just trying to save, triggering Save results in error. BTW. Changing to Markdown syntax solved the problem.
I should mention, this occurs when working on untitled/unsaved file. As soon as the file is saved I can change syntax to JSON and all is OK.
Same here, I'm having issues with the HTML (Jinja2) in build 3211 on macOS 10.15.7. Is there any chance that this will be fixed in the v3 stable as well as the alphas?
Encountered it today: resolved by changing the initially empty file type to plain text in the editor before triggering Save.
Ran into this today when saving a new buffer set to nginx syntax. Like @whitezo, I set to plain text to do the initial save. Syntax package details:
Description
Unable to save newly created tab.
Steps to reproduce
Expected behavior
Should display pop up asking where to save file.
Actual behavior
Beach ball for about 15 sec then the message from the screenshot
Environment
Log
(not sure if relevant)