Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Ctags for Sublime Text 3

I'm using the Sublime Text 3 with Ruby On Rails projects.

Some time ago, I setup CTags using this tutorial.

It was fine, but suddenly stopped to work. I'm getting the following error when try to rebuild the tags of project.

/bin/sh: ctags_for_ruby: command not found

These are my files:

/usr/local/bin/ctags_for_ruby:

#!/usr/bin/env ruby
system "find . -name '*.rb' | ctags -f .tags -L -"

if File.exist? './Gemfile'
  require 'bundler'
  paths = Bundler.load.specs.map(&:full_gem_path).join(' ')
  system "ctags -R -f .gemtags #{paths}"
end

~/Library/Application Support/Sublime Text 3/Packages/User/CTags.sublime-settings

{
    "debug"           :  false,
    "autocomplete": false,
    "command"   :  "ctags_for_ruby",
    "filters"         :  {
        "source.python": {"type":"^i$"}
    },
    "definition_filters": {
        "source.php": {"type":"^v$"}
    },
    "definition_current_first": true,
    "show_context_menus": true,
    "extra_tag_paths" :  [ [["source.python", "windows"], "C:\\Python27\\Lib\\tags"]],
    "extra_tag_files" : [".gemtags", ".tags"]
}

And the $PATH variable includes /usr/local/bin directory.

Why Sublime can't find/execute the ctags_for_ruby file?

like image 570
Rodrigo Avatar asked Oct 20 '22 18:10

Rodrigo


1 Answers

/usr/local/bin may be in your shell's $PATH, but it is not getting picked up by Sublime. To fix this, edit ~/Library/Application Support/Sublime Text 3/Packages/User/CTags.sublime-settings and change the "command" setting to "/usr/local/bin/ctags_for_ruby". Also, unless you are using the system Ruby in /usr/bin, you might want to edit the first line of /usr/local/bin/ctags_for_ruby from #/usr/bin/env ruby to the direct path of your Ruby interpreter - you can find this by running which ruby on the command line.

like image 185
MattDMo Avatar answered Nov 01 '22 14:11

MattDMo