Joseph DePompeis
Joseph DePompeis

Reputation: 21

Beautify Ruby Sublime package "Check your ruby interpreter settings"

I am currently running Sublime Text 3 and use rbenv with ruby version 2.3.0. I installed Beatify Ruby from Package Control but it will not run correctly. I am currently getting an error every time I run BeautifyRuby in Sublime, it states: Error: invalid output. Check your ruby interpreter settings

What is the best way to go about getting Beautify Ruby to work?

Upvotes: 2

Views: 1197

Answers (2)

Mayinx
Mayinx

Reputation: 374

If you get this error, BeautifyRuby doesn't seem to know where your ruby-interpreter resides (which it needs to run ruby-scripts that perform the "Beautifying"). To solve this, you need to specify your ruby interpreter by providing a correct interpreter-path in the BeautifyRuby-Package-settings:

  1. If you don't know the path to your ruby interpreter, just run which ruby in your terminal. This gives you something like /home/<yourusername>/.rbenv/shims/ruby (if you use rbenv) or ~/.rvm/bin/rvm-auto-ruby (if you use rvm)
  2. Open the BeautifyRuby-Package-settings-file in Sublime by selecting Preferences > Package Settings > BeautifyRuby > Settings - Default
  3. Now specify your ruby-interpreter (and while you're on it other useful settings like tab-size etc.) - e.g. like this:
    {
      // Specify your ruby interpreter:
      "ruby": "~/.rvm/bin/rvm-auto-ruby",

      // Examples for other settings:

      // Use 2 Spaces instead of tabs:
      "translate_tabs_to_spaces": true,
      "tab_size": 2,

      // You can change the file patterns handled by this plugin:
      "file_patterns": ["\\.html\\.erb", "\\.rb", "\\.rake", "Rakefile", "Gemfile", "Vagrantfile"],
      "html_erb_patterns": ["\\.html\\.erb"],

      // This package offers a pre-save hook; when activated, your ruby and erb files will
      // be reformatted automatically before saving (deactivated by default)
      "run_on_save": false,

      // The sublime command "beautify_ruby" performs a save after formatting.
      // (activated by default)
      "save_on_beautify": false
    } 
  1. Hit save, head over to a (badly formatted) ruby-file that's opened in your Sublime Text and try the keyboard-shortcut (per default ctrl+alt+k if I'm not mistaken) - and your code should have been "beautified".

For more details, check the project-pages - on GitHub or packagecontrol.io

Upvotes: 1

Marat Amerov
Marat Amerov

Reputation: 406

Try open sublime from shell cd project_forler && subl .

or open Preferences -> Package Settings -> BeautifyRuby -> Settings Default find "ruby": "ruby" and replace to your ruby path

Upvotes: 0

Related Questions