【问题标题】:How to bundle local gem dependancies in IronWorker如何在 IronWorker 中捆绑本地 gem 依赖项
【发布时间】:2012-11-09 09:59:33
【问题描述】:

我有一个 Ruby IronWorker,它依赖于一个未发布到 RubyGems 的私有 gem。

有没有办法将这个本地 mygemname-0.0.1.gem 合并到我的 IronWorker 中的 .worker 文件中?

我希望能够在 myruby.worker 中指定以下内容:

gem 'mygemname', '>=0.0.1', :path=> 'vendor/bundle'

目前这给出以下错误

.rvm/gems/ruby-1.9.3-p0/gems/iron_worker_ng-0.12.2/lib/iron_worker_ng/code/base.rb:79 :in `eval':
   wrong number of arguments (3 for 2) (ArgumentError)

希望得到默认值:

 gem 'mygemname', '>=0.0.1'

出现以下错误

Could not find gem 'mygemname (>= 0.0.1) ruby' in the gems available on this machine. 

我是否在正确的轨道上尝试通过 .worker 文件使其工作?还是我应该考虑指定自定义构建步骤?

【问题讨论】:

    标签: ruby ironworker iron.io


    【解决方案1】:

    如果您未发布的 gem 本身有依赖项,您需要做一些按摩以使事情顺利进行。这是一种对我有用的技术:

    mygem.worker

    runtime "ruby"
    
    #Merge in an unpublished local gem
    dir '../opensource-cli-tools/facebook_exporter', '__gems__/gems'
    file '../opensource-cli-tools/facebook_exporter/mygem.gemspec', '__gems__/specifications'
    
    #Merge in a custom build script to fetch the unpublished gem's dependancies
    file "Gemfile"
    file "install_dependancies.sh"
    
    remote_build_command 'chmod +x install_dependancies.sh && ./install_dependancies.sh'
    
    #Run the puppy!
    exec "run.rb"
    

    install_dependancies.sh

    echo "Installing dependancies to __gems__/"
    gem install bundler --install-dir ./__gems__ --no-ri --no-rdoc
    bundle install --standalone --path ./__gems__
    cp -R ./__gems__/ruby/*/* ./__gems__
    rm -rf ./__gems__/ruby
    echo "Fixing install location of mygem"
    mv ./__gems__/gems/mygem ./__gems__/gems/mygem-0.0.1
    

    【讨论】:

      【解决方案2】:

      据我所知,目前不支持 git 和本地路径。 这是手动包含本地 gem 的方法: 将这些行添加到 .worker 文件中:

      dir '../vendor/bundle/mygemname', '__gems__/gems'
      file '../vendor/bundle/mygemname/mygemname.gemspec', '__gems__/specifications'
      

      【讨论】:

      • 我在下面添加了一些细节,展示了如何处理未发布的 gem 具有依赖项的情况
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-16
      • 2015-12-03
      • 2015-10-04
      • 2020-08-25
      • 2016-08-31
      • 2018-04-18
      相关资源
      最近更新 更多