I have a Rakefile that requires some Bundler tasks
Rakefile:
require "bundler/gem_tasks"
require "rake/testtask"
.
.
.
And a minitest file that loads the Rakefile so I can test my tasks:
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
The problem is Sublime doesn't like the require "bundler/gem_tasks"
and gives the following error:
/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]
There is no error if I run ruby test/rake_test.rb
from the command-line (leaving the require statement as is):
➜ 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
Sublime does work if I remove the require statement, but then I lose all my Bundler rake tasks.
I found an issue that references this problem in the context of using the Bundler tasks for multiple gems. Seems different than my use-case but I tried the solution anyways and it doesn't work, and gives the same error:
Rakefile:
require "bundler/gem_tasks"
Bundler::GemHelper.install_tasks :name => "some_gem"
require "rake/testtask"
I think it might have to do with the path for Sublimes build system. I tried using my rbenv
ruby shim but it also didn't work:
{
"shell_cmd": "/Users/max/.rbenv/shims/ruby \"$file\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}