从 Capistrano 任务创建 gem
Creating a gem from a Capistrano task
我有一个 capistrano 任务,我正试图将其变成 gem,这样我就可以在多个项目中使用它。此 gem 的存储库位于此处:
https://github.com/FoamFactory/capistrano-monorepo-assets/tree/jwir3/initial-commit
我基本上使用 https://github.com/sheharyarn/capistrano-rake 作为创建我的 gem 的基础。
我已经测试了实际的 rake 脚本,但实际上我现在并没有将它导入到项目中。相反,我试图让它真正成功地导入 gem 。当我将 gem 添加到我的 Gemfile 时:
gem 'capistrano-monorepoassets','0.0.6', path: "~/Source/capistrano-monorepo-assets/pkg"
运行 bundle install
,然后尝试在我的 Capfile
中使用以下命令导入它:
require 'capistrano/monorepoassets'
当我 运行 cap --tasks --trace
:
时出现错误
cap aborted!
LoadError: cannot load such file -- capistrano/monorepoassets
/home/scottj/Source/foamfactory/designsystem/Capfile:37:in `require'
/home/scottj/Source/foamfactory/designsystem/Capfile:37:in `<top (required)>'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:104:in `block in load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:103:in `load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:82:in `block in run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/capistrano-3.11.0/lib/capistrano/application.rb:14:in `run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/capistrano-3.11.0/bin/cap:3:in `<top (required)>'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/cap:23:in `load'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/cap:23:in `<main>'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `eval'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `<main>
我似乎无法使用 require
加载模块,这就是我卡住的地方。有人可以告诉我我做错了什么吗?
所以这实际上发生了,因为我不明白 bundle install
不支持通过在 Gemfile 中指定路径来安装本地 gem。 This question actually covers the problem, and, more specifically, the answer here 帮我解决了。
我有一个 capistrano 任务,我正试图将其变成 gem,这样我就可以在多个项目中使用它。此 gem 的存储库位于此处:
https://github.com/FoamFactory/capistrano-monorepo-assets/tree/jwir3/initial-commit
我基本上使用 https://github.com/sheharyarn/capistrano-rake 作为创建我的 gem 的基础。
我已经测试了实际的 rake 脚本,但实际上我现在并没有将它导入到项目中。相反,我试图让它真正成功地导入 gem 。当我将 gem 添加到我的 Gemfile 时:
gem 'capistrano-monorepoassets','0.0.6', path: "~/Source/capistrano-monorepo-assets/pkg"
运行 bundle install
,然后尝试在我的 Capfile
中使用以下命令导入它:
require 'capistrano/monorepoassets'
当我 运行 cap --tasks --trace
:
cap aborted!
LoadError: cannot load such file -- capistrano/monorepoassets
/home/scottj/Source/foamfactory/designsystem/Capfile:37:in `require'
/home/scottj/Source/foamfactory/designsystem/Capfile:37:in `<top (required)>'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:104:in `block in load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:103:in `load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:82:in `block in run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/capistrano-3.11.0/lib/capistrano/application.rb:14:in `run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/capistrano-3.11.0/bin/cap:3:in `<top (required)>'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/cap:23:in `load'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/cap:23:in `<main>'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `eval'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `<main>
我似乎无法使用 require
加载模块,这就是我卡住的地方。有人可以告诉我我做错了什么吗?
所以这实际上发生了,因为我不明白 bundle install
不支持通过在 Gemfile 中指定路径来安装本地 gem。 This question actually covers the problem, and, more specifically, the answer here 帮我解决了。