Atom Beautify Ruby使用rubocop doens工作

时间:2018-03-13 18:42:14

标签: ruby-on-rails ruby atom-editor atom-beautify

我在Atom中安装了Atom Beautify插件,并在我的应用程序中安装了rubocop gem。即使经过这些步骤,美化也无法奏效。

我的rubocop位置:

  $ which rubocop 
  /home/leonardo/.rbenv/shims/rubocop

在我的config.cson中,我有代码:

...
    ruby:
      rubocop_path: "/home/leonardo/.rbenv/shims/rubocop"
...

当我尝试使用Beatify( Ctrl + Alt + B )时,返回错误:

Error: rbenv: rubocop: command not found
The `rubocop' command exists in these Ruby versions:
  2.4.3
    at /home/leonardo/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:182:23
    at tryCatcher (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:143:10)
    at Async.drainQueues (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
    at process._tickCallback (internal/process/next_tick.js:103:7)

1 个答案:

答案 0 :(得分:3)

我遇到了同样的问题。我的项目的版本为2.2.2,而该版本上安装了rubocop gem。

Atom正在运行File "C:\Users\Aswathi\Anaconda3\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\project\application.py", line 6, in hello return render_template('hello.html') File "C:\Users\Aswathi\Anaconda3\lib\site-packages\flask\templating.py", line 134, in render_template return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list), File "C:\Users\Aswathi\Anaconda3\lib\site-packages\jinja2\environment.py", line 869, in get_or_select_template return self.get_template(template_name_or_list, parent, globals) File "C:\Users\Aswathi\Anaconda3\lib\site-packages\jinja2\environment.py", line 830, in get_template return self._load_template(name, self.make_globals(globals)) File "C:\Users\Aswathi\Anaconda3\lib\site-packages\jinja2\environment.py", line 804, in _load_template template = self.loader.load(self, name, globals) File "C:\Users\Aswathi\Anaconda3\lib\site-packages\jinja2\loaders.py", line 113, in load source, filename, uptodate = self.get_source(environment, name) File "C:\Users\Aswathi\Anaconda3\lib\site-packages\flask\templating.py", line 58, in get_source return self._get_source_fast(environment, template) File "C:\Users\Aswathi\Anaconda3\lib\site-packages\flask\templating.py", line 86, in _get_source_fast raise TemplateNotFound(template) ,但是使用的是全局atom-beautify版本(在我的情况下是2.4.0),这导致了错误。因此解决方案是:

rbenv

然后重新启动Atom,运行$ cd ~ $ rbenv version 2.4.0 $ gem install rubocop ,现在一切正常。