[BeautifyRuby] 遇到 Check your ruby interpreter setting(only with ERB files)

在 sublime 上,想要一鍵 Beautify Ruby ?

必然會找上這個開源:BeautifyRuby
你已經從 package install 下載
發現在這套件可以正常使用.rb
卻無法正常使用 .erb 檔 ,WTF???????????

BeautifyRuby works for .rb and not for .erb files??

其實可以猜到,你是否使用 rvm 管理套件?
我們很想要強大的切換 ruby 版本,必然會踩到,這個地雷
因為我們 ruby 路徑跟別人不一樣阿!
….(背後音樂《我們不一樣》–大壯)

指令 檢查你的版本和路徑

check ruby version and path

1
2
$ rvm ls
$ which ruby

Sep1 找 BeautifyRuby 的設定檔

sublime 打開設定檔

Preferences -> Package Settings -> BeautifyRuby -> Settings Default

Step2 添加到設定裡:

In your BeautifyRuby.sublime-settings
"ruby": "/Users/(user)/.rvm/rubies/ruby-(version)/bin/ruby",

記得替換(user)、(version)放到設定檔,範例:

default.json
1
2
3
4
5
6
7
8
9
10
11
{
// Would you prefer a tab or two spaces to represent a tab
// The default is two spaces represented by 'space'
// anything else will use one tab character

"ruby": "/Users/(user)/.rvm/rubies/ruby-(version)/bin/ruby",
"file_patterns": ["\\.html\\.erb", "\\.rb", "\\.rake", "Rakefile", "Gemfile", "Vagrantfile"],
"html_erb_patterns": ["\\.html\\.erb"],
"run_on_save": true,
"save_on_beautify": false
}

Step3 到根目錄底下,全局環境,新增這支gem

Install htmlbeautifier in global gemset.

1
2
$ cd 
$ gem install htmlbeautifier

Step4 重開你的 sublime ,試試 .erb

快捷鍵:ctrl+ super + k(預設)

1
2
3
4
[{
"keys": ["ctrl+super+k"],
"command": "beautify_ruby"
}]

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×