[英]Atom-Editor: Don't work rubocop with atom
I tried connect rubocop in atom and got error in atom.我尝试在 atom 中连接 rubocop 并在 atom 中出错。
linter-registry.js [sm]:144 [Linter] Error running RuboCop Error: /usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'rubocop' (>= 0.a) among 16 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/home/kurilovichay/.rvm/gems/ruby-2.3.1:/home/kurilovichay/.rvm/gems/ruby-2.3.1@global', execute `gem env` for more information
from /usr/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/rubocop:22:in `<main>'
at parseFromStd (/home/kurilovichay/.atom/packages/linter-rubocop/src/index.js:41:43)
at Object.<anonymous> (/home/kurilovichay/.atom/packages/linter-rubocop/src/index.js:212:27)
at next (<anonymous>)
at step (/home/kurilovichay/.atom/packages/linter-rubocop/src/index.js:11:273)
which rubocop return:哪个 rubocop 返回:
/usr/local/bin/rubocop
it's wrong?这是错的?
It seems that you're using rvm to manage your environment.您似乎正在使用 rvm 来管理您的环境。 What i did to get it to work was follow the instructions on their repo: https://github.com/AtomLinter/linter-rubocop#settings我所做的让它工作是按照他们的 repo 上的说明进行操作: https : //github.com/AtomLinter/linter-rubocop#settings
# make sure I'm in the global gemset
$ rvm gemset use global
# install the gem
$ gem install rubocop
configure atom to use the global.配置原子以使用全局。 Edit your atom's config file ( config.cson
) and add编辑您的 atom 的配置文件 ( config.cson
) 并添加
*:
"linter-rubocop":
executablePath: "~/.rvm/gems/ruby-2.3.1@global/wrappers"
"linter-ui-default": {}
Note: make sure that the ruby version is the one you're using.注意:确保 ruby 版本是您正在使用的版本。
I had this same issue when working on a Rails 6 application in Ubuntu 20.04 with rbenv as my ruby version manager.在Ubuntu 20.04 中使用rbenv作为我的 ruby 版本管理器处理Rails 6应用程序时,我遇到了同样的问题。
I already had rubocop installed in the project, but Atom editor was still throwing this error.我已经在项目中安装了 rubocop,但是 Atom 编辑器仍然抛出这个错误。
All I had to do was to install the rubocop gem to be available globally on the machine.我所要做的就是安装 rubocop gem 以便在机器上全局可用。 Open a new terminal and install it using:打开一个新终端并使用以下命令安装它:
gem install rubocop
That's all.就这样。
I hope this helps我希望这有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.