我编写了一个创业板弹力豆柄,它将在rails项目文件结构中使用,以及在rails dir和文件不可用的独立CI环境中使用(没有解压缩等)。也就是说,运行eb:package的竹构建过程将产生一个主要工件app.zip,其中部署计划稍后可能在另一个代理上接管并执行eb:deploy。
目标
当在rails项目结构中运行时,这一切都很好,所以我的目标是在独立的CI环境中也运行它。
给定的
一个空的dir (CI环境),只包含app.zip、eb.yml、创建的binstub,以及gem可用。
什么时候
我运行elastic-beanstalk eb:deploy
然后
它应该使用这个gem的依赖项和库文件运行相当于rake eb:deploy的文件。
最新情况- Bin Stub
看来我要找的就是垃圾桶存根。在探索另一篇这样的文章时,我已经尝试过(到目前为止没有用) bin/elastic-beanstalk
gem_dir = File.expand_path('..',File.dirname(__FILE__))
$LOAD_PATH.unshift gem_dir# Look in gem directory for resources first.
lib = File.expand_path('lib', gem_dir)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'elastic/beanstalk'
require 'rake'
require 'pp'
pwd=Dir.pwd
Dir.chdir("#{gem_dir}/bin") # We'll load rakefile from the gem's bin dir.
Rake.application.init
Rake.application.load_rakefile
Dir.chdir(pwd) # Revert to original pwd for any path args passed to task.
Rake.application.invoke_task(ARGV[0])因此,这是运行的,但仍然失败与我从undefined method 'safe_load_file' for Psych:Module (NoMethodError)开始的依赖问题。虽然我认为一个二进制存根是要走的路:
如何使用bin存根解决依赖关系问题?
发布于 2013-08-21 15:44:48
最终,我需要调用Bundler.setup来解决依赖关系。
清理完后,下面的文件是我唯一需要调用的一个rake任务,这个任务中有一个bin文件在gem中(外部bin stub利用这个文件):
料仓/弹性豆柄
#!/usr/bin/env ruby
require 'rake'
require 'bundler'
raise "Bundler is required. Please install bundler with 'gem install bundler'" unless defined?(Bundler)
#
# Example:
#
# elastic-beanstalk eb:show_config
# elastic-beanstalk eb:show_config[1.1.1]
#
# init dependencies
Bundler.setup
# init rake
Rake.application.init
# load the rake tasks
gem_dir = File.expand_path('..',File.dirname(__FILE__))
load "#{gem_dir}/lib/elastic/beanstalk/tasks/eb.rake"
# invoke the given task
Rake.application.invoke_task(ARGV[0])https://stackoverflow.com/questions/18340795
复制相似问题