Komodo / KomodoEdit

Komodo Edit is a fast and free multi-language code editor. Written in JS, Python, C++ and based on the Mozilla platform.
http://www.komodoide.com/komodo-edit
Other
2.16k stars 303 forks source link

Perl code formatting fails with exception #2376

Open vrurg opened 7 years ago

vrurg commented 7 years ago

Short Summary

Perl formatting via menu Code->Format->Document using ... fails with the following entry in notifications:

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [koIFormatter.format]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://komodo/content/formatters/formatters.js :: _formatViewWithFormatterAndContext :: line 132" data: no]

Steps to Reproduce

Define a generic command line Perl formatter, try to use it via menu or a keyboard shortcut.

Expected results

Formatted Perl code, apparently.

Actual results

An exception.

Platform Information

Komodo Edit or IDE? IDE Komodo Version? 10.2 Operating System (and version)? macOS Sierra 10.12.3

Additional Information

A chunk of log file:

ERROR:xpcom:Unhandled exception calling 'int8 * format(in nsISomething);'
Traceback (most recent call last):
  File "/Applications/Komodo IDE 10.app/Contents/Resources/python/xpcom/server/policy.py", line 303, in _CallMethod_
    return 0, func(*params)
  File "/Applications/Komodo IDE 10.app/Contents/Resources/components/koGenericFormatter.py", line 85, in format
    context.prefset)
TypeError: Interpolate1() takes exactly 10 arguments (9 given)
ERROR:xpcom:Unhandled exception calling 'int8 * format(in nsISomething);'
Traceback (most recent call last):
  File "/Applications/Komodo IDE 10.app/Contents/Resources/python/xpcom/server/policy.py", line 303, in _CallMethod_
    return 0, func(*params)
  File "/Applications/Komodo IDE 10.app/Contents/Resources/components/koGenericFormatter.py", line 85, in format
    context.prefset)
TypeError: Interpolate1() takes exactly 10 arguments (9 given)
th3coop commented 7 years ago

This is fixed in the latest nightly: http://downloads.activestate.com/Komodo/nightly/komodoide/latest-10.2.x/

vrurg commented 7 years ago

I have downloaded the build 89939 and – no, it's not fixed:

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [koIFormatter.format]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://komodo/content/formatters/formatters.js :: _formatViewWithFormatterAndContext :: line 132" data: no] Mon Feb 27 2017 22:27:45 GMT-0500 (EST)

On the other hand, it's not being recorded in the log file any more.

th3coop commented 7 years ago

That's a different error. Share your entire log file after you reproduce the issue then try Help > Troubleshooting > Restart in Safe-Mode and see if the issue continues.

vrurg commented 7 years ago

Here is the log following. Unfortunately, cannot test it in safe mode because perltidy is a manually added formatter for Perl. Adding it in safe mode doesn't help: it is not appearing in the menu and I currently don't know if there is an alternative way to exec the command.

[2017-02-28 09:23:05,672] [INFO] Startup: Welcome to Komodo IDE 10.2.1 build 89839 (platform macosx, running on Darwin 16.4.0 version Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64)
[2017-02-28 09:23:05,672] [INFO] Startup: /Applications/Komodo IDE 10.app/Contents/MacOS/komodo built on Mon Feb 27 01:51:40 2017
[2017-02-28 09:23:05,838] [WARNING] koInitService: Unable to determine the current locale settings, defaulting to mac-roman
[2017-02-28 09:23:05,850] [WARNING] koEnviron: skipping environment string: 'COM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/VRURG/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET=/private/tmp/com.apple.launchd.okfrk1LYMa/ServiceProcessSocket'
[2017-02-28 09:23:06,293] [WARNING] console-logger: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create (1) in resource://gre/modules/Preferences.jsm:381
[2017-02-28 09:23:06,472] [WARNING] root: ko.logging has been converted to a CommonJS module; use require("ko/logging") instead (since Komodo 9.0.0a1).
    @chrome://komodo/content/komodo.js:15:1

[2017-02-28 09:23:07,093] [WARNING] keybindings: [Meta+Shift+Down] was used for 'cmd_selectDocumentHome', overriding to use 'cmd_selectDocumentEnd'
[2017-02-28 09:23:07,097] [WARNING] keybindings: [Ctrl+P,P] was used for 'cmd_completeWordBack', overriding to use 'cmd_publishingPushCurrentFile'
[2017-02-28 09:23:07,099] [WARNING] keybindings: [Ctrl+D] was used for 'cmd_addNextWordToCaretSet', overriding to use 'cmd_vim_scrollHalfPageDown'
[2017-02-28 09:23:07,316] [WARNING] console-logger: Empty string passed to getElementById(). (1) in chrome://komodo/content/keybindings/keybindings.js:1594
[2017-02-28 09:23:14,532] [WARNING] ko.widgets: Could not restore widget unittest-widget
[2017-02-28 09:23:16,047] [INFO] koInitService: Adding pre startup service for 'koFileStatusService': '@activestate.com/koFileStatusService;1'
[2017-02-28 09:23:16,133] [INFO] komodospellchecker: Spell checker loaded.
[2017-02-28 09:23:16,133] [INFO] komodospellchecker: Using dictionary en-US
[2017-02-28 09:23:16,181] [INFO] elastic_tabstops: Elastic tabstops loaded.
[2017-02-28 09:23:16,260] [ERROR] koScopeDocs-Py: Could not find cix for ext
[2017-02-28 09:23:16,268] [ERROR] koScopeDocs-Py: Could not find cix for html5
[2017-02-28 09:23:20,493] [INFO] koInitService: Adding pre startup service for 'KoMemoryReporter': '@activestate.com/koMemoryReporter;1'
[2017-02-28 09:23:20,495] [INFO] koInitService: Adding pre startup service for 'koCommandmentService': '@activestate.com/koCommandmentService;1'
[2017-02-28 09:23:20,497] [INFO] koInitService: Adding pre startup service for 'koDBGPManager': '@activestate.com/koDBGPManager;1'
[2017-02-28 09:23:20,579] [ERROR] console-logger: Exception while registering Focus Mode (0) in resource://gre/modules/addons/XPIProvider.jsm -> file:///Applications/Komodo%20IDE%2010.app/Contents/Resources/extensions/focusmode@activestate.com/bootstrap.js:11
Traceback (most recent call last):
  File "resource://gre/modules/addons/XPIProvider.jsm -> file:///Applications/Komodo%20IDE%2010.app/Contents/Resources/extensions/focusmode@activestate.com/bootstrap.js", line 11, in 

[2017-02-28 09:23:20,582] [ERROR] console-logger: [object Object] (0) in resource://gre/modules/addons/XPIProvider.jsm -> file:///Applications/Komodo%20IDE%2010.app/Contents/Resources/extensions/focusmode@activestate.com/bootstrap.js:12
Traceback (most recent call last):
  File "resource://gre/modules/addons/XPIProvider.jsm -> file:///Applications/Komodo%20IDE%2010.app/Contents/Resources/extensions/focusmode@activestate.com/bootstrap.js", line 12, in 

[2017-02-28 09:23:20,921] [ERROR] CT::tracker.js: Scc error Error 128 running '/opt/local/bin/git show HEAD:./ExtensionsTests.pm'
  in '/Users/vrurg/src/foswiki/Item14237/core/test/unit': 
fatal: Path 'core/test/unit/ExtensionsTests.pm' exists on disk, but not in 'HEAD'.
Traceback from ERROR in 'CT::tracker.js' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    exports.ChangeTracker.prototype.onError@chrome://trackchanges/content/tracker.js:200:5

[2017-02-28 09:23:20,939] [ERROR] CT::tracker.js: Scc error Error 128 running '/opt/local/bin/git show HEAD:./FoswikiTestCase.pm'
  in '/Users/vrurg/src/foswiki/Item14237/core/test/unit': 
fatal: Path 'core/test/unit/FoswikiTestCase.pm' exists on disk, but not in 'HEAD'.
Traceback from ERROR in 'CT::tracker.js' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    exports.ChangeTracker.prototype.onError@chrome://trackchanges/content/tracker.js:200:5

[2017-02-28 09:23:20,952] [ERROR] CT::tracker.js: Scc error Error 128 running '/opt/local/bin/git show HEAD:./FoswikiFnTestCase.pm'
  in '/Users/vrurg/src/foswiki/Item14237/core/test/unit': 
fatal: Path 'core/test/unit/FoswikiFnTestCase.pm' exists on disk, but not in 'HEAD'.
Traceback from ERROR in 'CT::tracker.js' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    exports.ChangeTracker.prototype.onError@chrome://trackchanges/content/tracker.js:200:5

[2017-02-28 09:23:20,961] [ERROR] CT::tracker.js: Scc error Error 128 running '/opt/local/bin/git show HEAD:./FeatureSetTests.pm'
  in '/Users/vrurg/src/foswiki/Item14237/core/test/unit': 
fatal: Path 'core/test/unit/FeatureSetTests.pm' exists on disk, but not in 'HEAD'.
Traceback from ERROR in 'CT::tracker.js' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    exports.ChangeTracker.prototype.onError@chrome://trackchanges/content/tracker.js:200:5

[2017-02-28 09:23:20,969] [ERROR] CT::tracker.js: Scc error Error 128 running '/opt/local/bin/git show HEAD:./TestRunner.pl'
  in '/Users/vrurg/src/foswiki/Item14237/core/test/bin': 
fatal: Path 'core/test/bin/TestRunner.pl' exists on disk, but not in 'HEAD'.
Traceback from ERROR in 'CT::tracker.js' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    exports.ChangeTracker.prototype.onError@chrome://trackchanges/content/tracker.js:200:5

[2017-02-28 09:23:20,985] [ERROR] CT::tracker.js: Scc error Error 128 running '/opt/local/bin/git show HEAD:./ConfigTests.pm'
  in '/Users/vrurg/src/foswiki/Item14237/core/test/unit': 
fatal: Path 'core/test/unit/ConfigTests.pm' exists on disk, but not in 'HEAD'.
Traceback from ERROR in 'CT::tracker.js' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    exports.ChangeTracker.prototype.onError@chrome://trackchanges/content/tracker.js:200:5

[2017-02-28 09:23:21,127] [ERROR] CT::tracker.js: Scc error Error 128 running '/opt/local/bin/git show HEAD:./FileClassTests.pm'
  in '/Users/vrurg/src/foswiki/Item14237/core/test/unit': 
fatal: Path 'core/test/unit/FileClassTests.pm' exists on disk, but not in 'HEAD'.
Traceback from ERROR in 'CT::tracker.js' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    exports.ChangeTracker.prototype.onError@chrome://trackchanges/content/tracker.js:200:5

[2017-02-28 09:23:21,745] [WARNING] console-logger: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create (1) in file:///Applications/Komodo%20IDE%2010.app/Contents/Resources/components/koamAddonManager.js:138
[2017-02-28 09:23:23,245] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:23,246] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:23,247] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:23,251] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:23,251] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:23,251] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:24,210] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:24,210] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:24,210] [WARNING] console-logger: XUL box for tab element contained an inline #text child, forcing all its children to be wrapped in a block. (1) in chrome://unittest/content/views/panel.xul:0
[2017-02-28 09:23:35,745] [DEBUG] console: error: TypeError {}
[2017-02-28 09:23:35,906] [DEBUG] console: error: TypeError {}
th3coop commented 7 years ago

Did you reproduce the issue before you shared this log? There is no formatting error in this log.

th3coop commented 7 years ago

I've installed the latest nightly, installed perltidy and configured it in Komodo and it's working fine for me. Could you check your format configuration?

vrurg commented 7 years ago

Regarding the log: this is exactly what I told you few comments ago – there is no log entry. Yes, the exception happened before the log was copied over.

Meanwhile I tried to remove and reinstall the app, clean up caches and this is what i got right after the IDE restarted (sorry for the link, it doesn't want to upload the image directly): https://dl.dropboxusercontent.com/u/4321404/2017_02_28_KomodoException.jpg

Again, the full text of the exception on the screen shot is:

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [koIFormatter.format]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://komodo/content/formatters/formatters.js :: _formatViewWithFormatterAndContext :: line 132"  data: no]
                                         Tue Feb 28 2017 16:29:18 GMT-0500 (EST)

Yet I wonder what could be wrong about configuring the formatter as it is one of the simplest things in the wild jungle of Komodo settings. So, here is what it looks like in the prefs.xml:

<preference-set id="{3858deca-7df1-d343-a429-f09af7dcb617}">
  <string id="formatter_name">generic</string>
<preference-set id="genericFormatterPrefs">
  <string id="arguments"></string>
  <string id="executable">/opt/local/bin/perltidy</string>
</preference-set>
  <string id="lang">Perl</string>
  <string id="name">PerlTidy</string>
</preference-set>

And as a screenshot: https://dl.dropboxusercontent.com/u/4321404/2017_02_28_KomodoFormatterDialog.PNG

For now the only thing I didn't do is moving away the preferences directory, starting it over from the scratch and see if it helps somehow. But I'm gonna try it now.

vrurg commented 7 years ago

Done, fresh start with no configuration directory. The only change to the preferences is the new formatter. Still getting the exception.

Komodo IDE, version 10.2.1, build 89839, platform macosx. Built on Mon Feb 27 01:51:40 2017.

Naatan commented 7 years ago

Does running /opt/local/bin/perltidy from the command line work as expected?

vrurg commented 7 years ago

Sure it does. I've been using this feature for quite some time now and it was working up until the 10.2 upgrade.

vrurg commented 7 years ago

I found the exact cause of the failure. /opt/local/bin/perltidy is a symlink. /opt/local/bin/perltidy-5.24 is the actual file it points to (this is how MacPorts installs Perl scripts). Choosing the versioned file fixes the problem.

So, the bottom line would be: Komodo IDE doesn't handle symlinks properly.

If there be plans of fixing the matter I'd happily test the fixed version. Meanwhile I plan to stick to the workaround. ;)

Naatan commented 7 years ago

Thanks for reporting back @vrurg, that gives us something to go on! :)

Naatan commented 7 years ago

By the way, are you still saying that exact same executable (symlink) worked for you in 10.1?

vrurg commented 7 years ago

No, it was other way around. When I hit the original bug with wrong number of arguments the first suspicion was that the versioned file name doesn't work. So, I tried the symlink in an attempt find a workaround and left it this way since.

Naatan commented 7 years ago

Ok. So I'm gathering 10.1 worked but wasnt using the symlinked executable. That seems right, thanks for clarifying :)

vrurg commented 7 years ago

Correct. You're welcome!

ravenhall commented 6 years ago

I'm also seeing this using perltidy under plenv, which creates bash 'shims' to direct to the correct perltidy:

Komodo 11.0.2 build 90813

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [koIFormatter.format]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://komodo/content/formatters/formatters.js :: _formatViewWithFormatterAndContext :: line 135" data: no]

Here's the plenv perltidy shim: /home/nwaddell/.plenv/shims/perltidy

#!/usr/bin/env bash
set -e
[ -n "$PLENV_DEBUG" ] && set -x

program="${0##*/}"
if [ "$program" == "perl" ]; then
  for arg; do
    [[ "$arg" =~ ^(--$|-[0A-Za-z]*[eE].*) ]] && break
    if [[ "$arg" =~ / ]] && [ -f "$arg" ]; then
      export PLENV_DIR="${arg%/*}"
      break
    fi
  done
fi

export PLENV_ROOT="/home/nwaddell/.plenv"
exec "/home/nwaddell/.plenv/libexec/plenv" exec "$program" "$@"