Kirti Thorat
Kirti Thorat

Reputation: 53038

BeautifyRuby works for .rb and not for .erb files

I am using ST2 on OSX 10.9.1. I have htmlbeautifier gem installed.I installed BeautifyRuby using Package Control. I have set the ruby path and file patterns in the Default Settings of BeautifyRuby as follows :

{
"tab_or_space": "space",
"ruby": "/Users/(username)/.rvm/rubies/ruby-2.1.0/bin/ruby",
"file_patterns": ["\\.html\\.erb", "\\.rb", "\\.rake", "Rakefile", "Gemfile"],
"html_erb_patterns": ["\\.html\\.erb"],
"run_on_save": true,
"save_on_beautify": false
}

For me BeautifyRuby works for only files with extension .rb and not for files with extension .erb.

When i try to beautify a .erb file i get the following error :

"error: invalid output. check your ruby interpreter settings"

I also tried the same thing with manual installation of BeautifyRuby directly from git. Still gives me the same result.

Upvotes: 9

Views: 2063

Answers (4)

Pranav Prakash
Pranav Prakash

Reputation: 869

I was facing the same issue and I was able to resolve the issue by installing an older version of htmlbeautifier gem:

gem uninstall htmlbeautifier
gem install htmlbeautifier -v 0.0.12

It seems latest version of htmlbeautifier is not compatible with BeautifyRuby.

Upvotes: 1

user1322092
user1322092

Reputation: 4280

I assume you are using RVM. If you added a new ruby version and changed the RVM ruby deault, it will break the sublime BeautifyRuby package because your default ruby is now different from the one referenced in your BeautifyRuby setting.

First remove BeautifyRuby. Close sublime and re-open it then re-add the package.

Second, in your rails/ruby project folder, run which ruby and note the path.

Third, open preferences > package settings > beautify ruby > settings default and add the following:

{
...
"ruby":"path_printed_in_which_ruby_command",
...
}

Upvotes: 1

pontiac_ventura
pontiac_ventura

Reputation: 79

I see this question is several months old but I ran into the same problem and have a solution that worked for me that I think is worth sharing. In sublime text 3, under Preferences | Package Settings | BeautifyRuby | Settings - Default, the file_patterns value was corrupted slightly, merging .html and .erb file types together and in so doing breaking functionality for both of them.

What I found:

  "file_patterns": ["\\.html\\.erb", "\\.rb", "\\.rake", "Rakefile", "Gemfile"],

What I changed it to:

"file_patterns": ["\\.html", "\\.erb", "\\.rb", "\\.rake", "Rakefile", "Gemfile"],

That seemed to do the trick for me. Also, you'll want to make sure that the settings for 'ruby' are set to your current version of ruby, as mentioned above. Run 'which ruby' at the command line to get the current path to ruby on your machine, and use that value for your ruby setting. In my case it was:

"ruby": "/Users/bob/.rvm/rubies/ruby-2.1.2/bin/ruby",

(note there is a trailing comma at the end, since it's not the last config in the file).

Upvotes: 0

Azzurrio
Azzurrio

Reputation: 1330

If using rvm:

1- In your BeautifyRuby.sublime-settings

"ruby": "/Users/(user)/.rvm/rubies/ruby-(version)/bin/ruby"

2- Install htmlbeautifie in global gemset.

rvm use (version)@global     
gem install htmlbeautifier

This'll fix your problem..

Upvotes: 13

Related Questions