简体   繁体   English

似乎无法使用Rails 4安装rubocop gem

[英]Can't seem to install rubocop gem using Rails 4

I tried installing rubocop by adding the suggested line to my Rails project's Gemfile: 我尝试通过将建议的行添加到我的Rails项目的Gemfile中来安装rubocop:

gem 'rubocop', require: false

After running bundle , it installs and is visible in my Gemfile.lock. 运行bundle ,它将安装并在我的Gemfile.lock中可见。

However when running $ rubocop from my application's root I receive this error: 但是,当从应用程序的根目录运行$ rubocop ,我收到此错误:

-bash: rubocop: command not found

I tried running $ which rubocop , and nothing comes up. 我尝试运行$ which rubocop ,但没有任何反应。

I've also tried running $ gem install rubocop , with no difference in behavior. 我也尝试过运行$ gem install rubocop ,在行为上没有区别。

Here is the excerpt from my Gemfile.lock: 这是我的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)

You have to run this command: 您必须运行以下命令:

source ~/.bashrc

As right after running $ bundle command the gem was installed and its environment was set in your ~/.bashrc , but since you continued to use the old bash session you didn't get rubocop available as a command in your bash. 在运行$ bundle命令之后,就正确地安装了gem,并且在~/.bashrc设置了它的环境,但是由于您继续使用旧的bash会话,因此bash中没有rubocop作为命令可用。 Hence, either re-login in your bash(close and then open the terminal again) or run the command stated above. 因此,请重新登录bash(关闭然后再次打开终端)或运行上述命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM