LoginSignup
2
1

More than 3 years have passed since last update.

VScodeでrubocopを使ったらエラーが出た

Last updated at Posted at 2020-02-04

前提

・rbenvでrubyのバージョンを2.6.0に指定

system
* 2.6.0 (set by /PATH/)
2.7.0

・2.6.0の環境下でrubocopをインストール

gem install rubocop

・VSCode拡張機能であるruby-rubocopをインストール

エラー

VSCodeの右下に以下のようなエラーが出てきた

rbenv: rubocop: command not found
The `rubocop' command exists in these Ruby versions: 2.6.0

問題の原因

以下の2つのファイルが置いてある場所に問題があった
~/.vscode
~/project/.ruby-version

VScode上でruby-rubocopを実行する時にデフォルトのruby環境(rbenv versionsコマンドを打った時のsystem)のままであり、rubocopがインストールされていない状況であった

解決方法

以下のどちらかの方法で解決できる

1.VScodeのruby実行環境を2.6.0にする
.ruby-versionを.vscodeがある~/に置く

2. デフォルトのruby環境にrubocopをインストールする

2
1
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
2
1