9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windows7のAtomでrubocopを使えるようになるまで

Last updated at Posted at 2016-03-01

はじめに

WindowsのAtomでjavascriptなどをBeautifyで自動楽ちんコードフォーマットをしていました。
しかしrubyのファイルでは"rubocop"が見つからないなど言われてだめだったのでできるようにしました。
これの統合された情報が見つからず、rubyのインストールからやったので共有します。
MacやLinuxだともっと簡単なはずです。

ATOMのプラグイン

  • atom-beautify
  • linter-rubocop
  • 関係無いですが
  • japanese-menu
    を入れてメニューを日本語化しています。

プラグインを入れた後

1. windowsにruby環境を入れる必要

http://rubyinstaller.org/downloads/
からrubyの2.3.0のバイナリをインストールしました。

  • このとき管理者権限でインストールになりました。
  • コマンドラインでrubyが実行できるか確認

3. rubucopのインストール

gem install rubocop --no-ri --no-rdoc

のようにgemインストールするだけなのですが、コマンドプロンプトを開くとき"管理者として実行"で
やらないとgem installが権限の問題で失敗したことがありました。

>gem install rubocop --no-ri --no-rdoc
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - C:/Program Files/Ruby-2.3-x64/lib/ruby/gems
/2.3.0/gems/rubocop-0.37.2/LICENSE.txt

4. ATOMのconfig.cson

ファイルメニューから個人設定で開き、

    ruby:
      rubocop_path: "C:\\Ruby23-x64\\bin\\rubocop.bat"

          ↑rubucop.batというファイルがあるパスを設定する

5. ATOM再起動

ようやく、*.rbでコードフォーマットができるようになりました。

まとめ

  • このためだけにWindowsにrubyを入れました。
    • 今後の管理が面倒なのでできればATOMで完結してほしい
9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?