Rvm Ruby + Chef + Code Intelligence

I’ve been trying to get code intelligence working with the following setup on Linux with Komodo X:

  • CentOS 7
  • ruby installed with rvm
  • Chef

However, I can’t get Code Intelligence working. I’ve tried manually adding the Chef libraries to the project settings under Ruby but no luck. The Activity window shows a lot of errors. The code intelligence log doesn’t show anything helpful.
It’s not even tab-completing variable names declared in the same .rb file. Is Ruby a more troublesome language for code intel?
It generally works fine for me with Python code.
Is there a trick to getting such a setup working?

Thanks,
John

Hi John,

First of all, do you get code intelligence with just a simple Ruby file? (Variable completions, stdlib completions, etc.)

Would you please share the errors in the activity window? I suspect they’ll be in Help > Troubleshooting > View Log File.

Thanks!

Hi, Mitchell:

Yes, with a simple Ruby file, code completion works fine.

I noticed when I begin typing:

require ’

that ‘chef’ is not in the list of libraries that are presented.

Help -> Troubleshooting -> View Log File failed with a file not found. I found a debug log under .komodoide/10.1/ but the IDE was looking under .komodoide/10.2/.
I restarted the IDE from the command-line instead of the Linux desktop menu and then it created a debug log under .komodoide/10.2/. I’ll paste the contents below.

The simple Ruby file I used for testing is:

 #!/usr/bin/env ruby

 require 'chef/knife'

 puts "testing"

 class Chef
    class Knife
      class TestKnife < Knife
      end
    end
 end

Chef files are installed under /usr/local/rvm/gems/ruby-2.4.1/gems/chef-13.1.31/lib/chef/

[2017-07-17 19:00:10,829] [INFO] Startup: Welcome to Komodo IDE 10.2.2
build 89895 (platform linux-x86_64, running on Linux
3.10.0-514.21.2.el7.x86_64 version #1 SMP Tue Jun 20 12:24:47 UTC 2017)
[2017-07-17 19:00:10,829] [INFO] Startup: /usr/bin/python built on Fri
Apr 28 17:38:33 2017
[2017-07-17 19:00:10,901] [INFO] koInitService: Setting LC_CTYPE to utf-8
[2017-07-17 19:00:11,424] [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-07-17 19:00:11,994] [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-07-17 19:00:12,881] [WARNING] keybindings: [Ctrl+0] was used for
'cmd_goToQuickBookmark_0', overriding to use 'cmd_fontZoomReset'
[2017-07-17 19:00:13,888] [WARNING] ko.widgets: Could not restore widget
unittest-widget
[2017-07-17 19:00:14,132] [INFO] koInitService: Adding pre startup
service for 'koFileStatusService': '@activestate.com/koFileStatusService;1'
[2017-07-17 19:00:14,193] [INFO] elastic_tabstops: Elastic tabstops loaded.
[2017-07-17 19:00:14,328] [INFO] komodospellchecker: Spell checker loaded.
[2017-07-17 19:00:14,328] [INFO] komodospellchecker: Using dictionary en-US
[2017-07-17 19:00:15,463] [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:///home/vagrant/Komodo-IDE-10/lib/mozilla/components/koamAddonManager.js:138
[2017-07-17 19:00:18,023] [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-07-17 19:00:18,024] [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-07-17 19:00:18,024] [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-07-17 19:00:18,043] [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-07-17 19:00:18,043] [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-07-17 19:00:18,044] [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-07-17 19:00:18,117] [INFO] koInitService: Adding pre startup
service for 'KoMemoryReporter': '@activestate.com/koMemoryReporter;1'
[2017-07-17 19:00:18,119] [INFO] koInitService: Adding pre startup
service for 'koCommandmentService':
'@activestate.com/koCommandmentService;1'
[2017-07-17 19:00:18,122] [INFO] koInitService: Adding pre startup
service for 'koDBGPManager': '@activestate.com/koDBGPManager;1'
[2017-07-17 19:00:19,199] [ERROR] koToolbox2: Couldn't load json data
for path
/home/vagrant/.komodoide/10.2/tools/Tutorials/Getting_Started.komodotool
Traceback (most recent call last):
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/koToolbox2.py",
line 1716, in _testAndAddItem
     data = json.load(fp, encoding="utf-8")
   File
"/home/vagrant/Komodo-IDE-10/lib/python/lib/python2.7/json/__init__.py",
line 290, in load
     **kw)
   File
"/home/vagrant/Komodo-IDE-10/lib/python/lib/python2.7/json/__init__.py",
line 351, in loads
     return cls(encoding=encoding, **kw).decode(s)
   File
"/home/vagrant/Komodo-IDE-10/lib/python/lib/python2.7/json/decoder.py",
line 366, in decode
     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
   File
"/home/vagrant/Komodo-IDE-10/lib/python/lib/python2.7/json/decoder.py",
line 384, in raw_decode
     raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
[2017-07-17 19:00:19,438] [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-07-17 19:00:19,439] [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-07-17 19:00:19,440] [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-07-17 19:00:23,572] [WARNING] console-logger: Key event not
available on GTK2: key="u" modifiers="control,shift" (1) in
chrome://komodo/content/komodo.xul:0
[2017-07-17 19:00:23,585] [WARNING] console-logger: Key event not
available on some keyboard layouts: key="w" modifiers="control,alt" (1)
in chrome://komodo/content/komodo.xul:0
[2017-07-17 19:00:23,586] [WARNING] console-logger: Key event not
available on some keyboard layouts: key="n" modifiers="control,alt" (1)
in chrome://komodo/content/komodo.xul:0
[2017-07-17 19:00:23,586] [WARNING] console-logger: Key event not
available on some keyboard layouts: key="s" modifiers="control,alt" (1)
in chrome://komodo/content/komodo.xul:0
[2017-07-17 19:00:23,587] [WARNING] console-logger: Key event not
available on some keyboard layouts: key="d"
modifiers="control,alt,shift" (1) in chrome://komodo/content/komodo.xul:0
[2017-07-17 19:00:30,343] [ERROR] koScopeDocs-Py: Could not find cix for ext
[2017-07-17 19:00:30,417] [ERROR] koScopeDocs-Py: Could not find cix for
html5
[2017-07-17 19:01:24,566] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:361
[2017-07-17 19:01:24,567] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:366
[2017-07-17 19:01:24,635] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:361
[2017-07-17 19:01:24,636] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:366
[2017-07-17 19:02:21,461] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:361
[2017-07-17 19:02:21,462] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:366
[2017-07-17 19:02:21,544] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:361
[2017-07-17 19:02:21,545] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:366
[2017-07-17 19:02:30,678] [ERROR] codeintel.tree: Unexpected error with
evaluator: 'Kni' at test1.rb#9
Traceback (most recent call last):
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/codeintel2/tree.py",
line 281, in eval
     cplns = self.eval_cplns()
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/codeintel2/tree_ruby.py",
line 236, in eval_cplns
     cplns = self._cplns_from_hits(hits, allowed_cplns)
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/codeintel2/tree_ruby.py",
line 518, in _cplns_from_hits
     ref_hits = self._hits_from_classref(classref)
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/codeintel2/tree_ruby.py",
line 636, in _hits_from_classref
     hit_list = [x for x in blob if x.get("name") == expr]
TypeError: 'NoneType' object is not iterable
[2017-07-17 19:02:31,779] [ERROR] codeintel.tree: Unexpected error with
evaluator: 'end' at test1.rb#10
Traceback (most recent call last):
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/codeintel2/tree.py",
line 281, in eval
     cplns = self.eval_cplns()
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/codeintel2/tree_ruby.py",
line 236, in eval_cplns
     cplns = self._cplns_from_hits(hits, allowed_cplns)
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/codeintel2/tree_ruby.py",
line 518, in _cplns_from_hits
     ref_hits = self._hits_from_classref(classref)
   File
"/home/vagrant/Komodo-IDE-10/lib/mozilla/python/komodo/codeintel2/tree_ruby.py",
line 636, in _hits_from_classref
     hit_list = [x for x in blob if x.get("name") == expr]
TypeError: 'NoneType' object is not iterable
[2017-07-17 19:03:20,416] [WARNING] console-logger: Key event not
available on GTK2: key="u" modifiers="control,shift" (1) in
chrome://komodo/content/tail/tail.xul:0
[2017-07-17 19:03:20,417] [WARNING] console-logger: Key event not
available on some keyboard layouts: key="w" modifiers="control,alt" (1)
in chrome://komodo/content/tail/tail.xul:0
[2017-07-17 19:03:20,417] [WARNING] console-logger: Key event not
available on some keyboard layouts: key="n" modifiers="control,alt" (1)
in chrome://komodo/content/tail/tail.xul:0
[2017-07-17 19:03:20,418] [WARNING] console-logger: Key event not
available on some keyboard layouts: key="s" modifiers="control,alt" (1)
in chrome://komodo/content/tail/tail.xul:0
[2017-07-17 19:03:20,418] [WARNING] console-logger: Key event not
available on some keyboard layouts: key="d"
modifiers="control,alt,shift" (1) in chrome://komodo/content/tail/tail.xul:0
[2017-07-17 19:03:53,431] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:361
[2017-07-17 19:03:53,432] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:366
[2017-07-17 19:03:53,487] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:361
[2017-07-17 19:03:53,488] [WARNING] console-logger: Empty string passed
to getElementById(). (1) in
chrome://global/content/bindings/richlistbox.xml:366

Hi, thanks for the detailed response. So Ruby codeintel is working. It just doesn’t recognize Chef yet. Have you added /usr/local/rvm/gems/ruby-2.4.1/gems/chef-13.1.31/lib/chef/ to Edit > Preferences > Languages > Ruby > Additional Import Directories?

Hi Mitchell, thanks for the suggestion. Yes, I tried both of these variations:
/usr/local/rvm/gems/ruby-2.4.1/gems/chef-13.1.31/lib/chef/
and
/usr/local/rvm/gems/ruby-2.4.1/gems/chef-13.1.31/lib

I also tried completely resetting my configuration (delete ~/.komodoide) then entering the above options (one at a time) in the Additional Import Directories, tested on a test Ruby file but still no luck. I watched the Notifications window to make sure the code intel data was fully populated before trying.

Another thing I tried doing was changing the Ruby interpreter to /usr/local/rvm/bin/rvm-auto-ruby but that didn’t help. Starting the /require '/ line still doesn’t find Chef.

Hi, I think I have reproduced a similar issue with codeintel, rvm, and ruby gems. Do you mind filing an issue on our issue tracker with a link to this forum topic? https://github.com/Komodo/KomodoEdit/issues/

By doing so I can keep this issue on our radar for further investigation. We are a bit swamped at the moment. Thanks!

Hi, Mitchell. I’ve filed https://github.com/Komodo/KomodoEdit/issues/2715
Thanks for your help.