【问题标题】:Can't open files with spaces in them in RubyMine from better_errors gem无法从 better_errors gem 在 RubyMine 中打开带有空格的文件
【发布时间】:2015-04-11 23:05:00
【问题描述】:

我正在使用 better_errors gem (https://github.com/charliesome/better_errors) 在 Mac 上开发 Rails 应用程序。我已将 better_errors 配置为使用 Github wiki 上的说明在 RubyMine 中打开文件(BetterErrors.editor='x-mine://open?file=%{file}&line=%{line}' 如果已定义?BetterErrors)。

但是,当我从 better_errors 页面单击文件时,RubyMine 每次都会给我一个“找不到文件”错误。问题是我的项目位于一个名为“Google Drive”的目录下(“Google”和“Drive”之间的空格)。文件链接生成为:

<a href="x-mine://open?file=%2FUsers%2Fredacted%2FDocuments%2FGoogle+Drive%2FWork%2FReferrer%2FCode%2FPrototype%2Fapp%2Fhelpers%2Fusers_helper.rb&amp;line=6">app/helpers/users_helper.rb</a>

RubyMine 反过来尝试打开文件:

'/Users/redacted/Documents/Google+Drive/Work/Referrer/Code/Prototype/app/helpers/users_helper.rb'

正确的语法应该是:

'/Users/redacted/Documents/Google Drive/Work/Referrer/Code/Prototype/app/helpers/users_helper.rb'

比较:

$ ls -l '/Users/redacted/Documents/Google+Drive/Work/Referrer/Code/Prototype/app/helpers/users_helper.rb'
ls: /Users/redacted/Documents/Google+Drive/Work/Referrer/Code/Prototype/app/helpers/users_helper.rb: No such file or directory

对比:

$ ls -l '/Users/redacted/Documents/Google Drive/Work/Referrer/Code/Prototype/app/helpers/users_helper.rb'
-rw-r--r--  1 redacted  staff  282 Apr 11 15:29 /Users/redacted/Documents/Google Drive/Work/Referrer/Code/Prototype/app/helpers/users_helper.rb

有关如何解决此问题的任何建议(除了重命名我的 Google 云端硬盘主目录,这会带来比其价值更多的麻烦)。

这显然不是世界末日,但让文件在 RubyMine 中自动打开会很好。

【问题讨论】:

    标签: rubymine better-errors-gem


    【解决方案1】:

    在终端中,创建一个符号链接:

    ln -s ~/Google\ Drive/ ~/GD  
    

    在 development.rb 中:

    if defined?(BetterErrors)
        BetterErrors.editor = proc { |full_path, line|
          full_path = full_path.sub('Google Drive', 'GD')
          "x-mine://open?file=#{full_path}&line=#{line}"
        }
    end
    

    【讨论】:

      猜你喜欢
      • 2012-04-03
      • 1970-01-01
      • 1970-01-01
      • 2018-10-23
      • 2014-08-02
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      相关资源
      最近更新 更多