使用Sublime Build时“无法确定现有gemspec的名称”

时间:2016-12-24 18:53:55

标签: ruby sublimetext3 developer-tools build-system

我有一个需要一些Bundler任务的Rakefile

Rake文件:

require "bundler/gem_tasks"
require "rake/testtask"
.
.
.

加载Rakefile的minitest文件,以便我可以测试我的任务:

load File.expand_path("../../Rakefile", __FILE__)
require 'minitest/autorun'
require 'rake'

class RakeTest < Minitest::Test
  def test_rake_just_works
    assert_output("Running some_namespace:some_task...\n") do 
      Rake::Task["some_namespace:some_task"].invoke
    end
  end
end

问题是Sublime不喜欢require "bundler/gem_tasks"并且出现以下错误:

/Users/max/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/gem_helper.rb:30:in `initialize': Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it. (RuntimeError)
  from /Users/max/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/gem_helper.rb:14:in `new'
  from /Users/max/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/gem_helper.rb:14:in `install_tasks'
  from /Users/max/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/gem_tasks.rb:6:in `<top (required)>'
  from /Users/max/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `require'
  from /Users/max/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
  from /Users/max/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
  from /Users/max/Dropbox/work/src/github.com/mbigras/some_gem/Rakefile:1:in `<top (required)>'
  from /Users/max/Dropbox/work/src/github.com/mbigras/some_gem/test/rake_test.rb:1:in `load'
  from /Users/max/Dropbox/work/src/github.com/mbigras/some_gem/test/rake_test.rb:1:in `<main>'
[Finished in 0.5s with exit code 1]
[shell_cmd: /Users/max/.rbenv/shims/ruby "/Users/max/Dropbox/work/src/github.com/mbigras/some_gem/test/rake_test.rb"]
[dir: /Users/max/Dropbox/work/src/github.com/mbigras/some_gem/test]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

如果我从命令行运行ruby test/rake_test.rb(保留require语句),则没有错误:

➜  some_gem master ✗ ruby test/rake_test.rb
Run options: --seed 45743

# Running:

.

Finished in 0.002035s, 491.4005 runs/s, 491.4005 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

如果删除require语句,Sublime会有效,但是我丢失了所有的Bundler rake任务。

我发现issue在使用多个宝石的Bundler任务的上下文中引用了这个问题。似乎与我的用例不同,但我尝试了解决方案,但它不起作用,并给出了同样的错误:

Rake文件:

require "bundler/gem_tasks"
Bundler::GemHelper.install_tasks :name => "some_gem"
require "rake/testtask"

我认为这可能与Sublimes构建系统的路径有关。我尝试使用我的rbenv红宝石垫片,但它也不起作用:

{
  "shell_cmd": "/Users/max/.rbenv/shims/ruby \"$file\"",
  "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
  "selector": "source.ruby"
}

0 个答案:

没有答案