1

I tried installing rubocop by adding the suggested line to my Rails project's Gemfile:

gem 'rubocop', require: false

After running bundle, it installs and is visible in my Gemfile.lock.

However when running $ rubocop from my application's root I receive this error:

-bash: rubocop: command not found

I tried running $ which rubocop, and nothing comes up.

I've also tried running $ gem install rubocop, with no difference in behavior.

Here is the excerpt from my Gemfile.lock:

rubocop (0.27.0)
  astrolabe (~> 1.3)
  parser (>= 2.2.0.pre.6, < 3.0)
  powerpack (~> 0.0.6)
  rainbow (>= 1.99.1, < 3.0)
  ruby-progressbar (~> 1.4)
4

1 回答 1

6

你必须运行这个命令:

source ~/.bashrc

在运行$ bundle命令之后,gem 已安装并且其环境已在您~/.bashrcrubocop. 因此,要么重新登录 bash(关闭然后再次打开终端),要么运行上述命令。

于 2014-11-05T19:16:05.317 回答