Reputation: 2622
I am trying to test out a simple local gem that I am working on but I am getting an error when testing the gem locally. I set the path to the local gem in my project's Gemfile.
Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "rake"
gem "valet-tasks", path: "../../Gems/valet-tasks"
Rakefile
require 'valet-tasks'
The is the error I get:
rake -T --trace
rake aborted!
LoadError: cannot load such file -- valet-tasks
/Users/myuser/Sites/mysite/Rakefile:2:in `<top (required)>'
Here is how my valet-tasks Gem looks like:
Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in valet-tasks.gemspec
gemspec
gem "rake", "~> 13.0"
lib/valet-tasks.rb
# frozen_string_literal: true
require 'rake'
require 'rake/tasklib'
require_relative "valet-tasks/version"
require_relative 'valet-tasks/hello'
module ValetTasks
class Error < StandardError; end
# Your code goes here...
end
lib/valet-tasks/hello.rb
module ValetTasks
module Task
include Rake::DSL if defined? Rake::DSL
class Hello < ::Rake::TaskLib
def initialize
super
namespace :hello do
desc 'Prints hello'
task :one do
puts 'Testing one two three'
end
end
end
end
end
end
ValetTasks::Task::Hello.new
I feel like everything is set up correctly. Could it be that this is not possible inside a Rakefile?
Upvotes: 1
Views: 544