【问题标题】:Creating a gem from a Capistrano task从 Capistrano 任务创建 gem
【发布时间】:2019-12-18 12:16:33
【问题描述】:

我有一个 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 加载模块,这就是我卡住的地方。谁能告诉我我做错了什么?

【问题讨论】:

  • 也许你应该将 gem 的基本目录从 capistrano-monorepo-assets 重命名为 capistrano-monorepoassets
  • @LyzardKyng 是的,我确实这样做了,但还没有将它推送到 github 存储库。对于陈旧的存储库,我深表歉意。

标签: ruby rubygems rake capistrano


【解决方案1】:

所以这实际上正在发生,因为我不明白bundle install 不支持通过在 Gemfile 中指定路径来安装本地 gem。 This question 实际上解决了这个问题,更具体地说,answer here 为我解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 1970-01-01
    • 1970-01-01
    • 2010-11-30
    • 2014-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多