【问题标题】:Using "bundle install --local" on Heroku Cedar在 Heroku Cedar 上使用“bundle install --local”
【发布时间】:2012-10-11 15:54:21
【问题描述】:

我有一个最初在 Bamboo 上的应用程序。我已经将它更新到 ruby​​ 1.9 并摆脱了所有的依赖。我正在尝试在 Heroku 上进行部署,但失败了。

-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.1
   Running: bundle install --without development:test --path vendor/bundle --binstubs bin/
   Fetching git@github.com:WaterfallFMS/deployment.git
   Host key verification failed.
   fatal: The remote end hung up unexpectedly
   Git error: command `git clone 'git@github.com:WaterfallFMS/deployment.git' "/tmp/build_2q1m86r0nc31g/vendor/bundle/ruby/1.9.1/cache/bundler/git/deployment-5959a7fb9f44c5cab5d6966441639b4e711bfc6b" --bare --no-hardlinks` in directory /tmp/build_2q1m86r0nc31g has failed.

我追踪到捆绑器没有缓存 git repos (https://github.com/carlhuda/bundler/issues/67)。如果您使用“bundle package --all”标志,它已被修复。

问题是您必须使用“Bundle install --local”,否则它仍然会在缓存之前引用 git repo。我不知道如何强制 heroku 使用“--local”。

【问题讨论】:

    标签: ruby-on-rails heroku bundle bundler


    【解决方案1】:

    bundle install 命令被硬编码为the Ruby buildpack

    # runs bundler to install the dependencies
    def build_bundler
      log("bundle") do
        bundle_without = ENV["BUNDLE_WITHOUT"] || "development:test"
        bundle_command = "bundle install --without #{bundle_without} --path vendor/bundle --binstubs bin/"
        # ...
        bundle_command += " --deployment"
        # ...
        puts "Running: #{bundle_command}"
        bundler_output << pipe("#{env_vars} #{bundle_command} --no-clean 2>&1")
    

    最终,这很痛苦,因为您试图从存储库外部获取私有代码到您的 slug 中,这意味着 slug 编译器必须能够以某种方式获取代码。在我看来,您的选择是:

    1. fork 构建包以使用 bundle package。请参阅Buildpacks documentation 了解更多信息。
    2. 点捆绑器到https://username:password@github.com/username/repo。是的,这些是明文凭据。是的,它们会受到源代码控制。
    3. 将代码放入公共存储库中。可能不是一个选择。
    4. 以另一种方式将代码放入您的 Heroku 存储库。您可以自己提供外部代码(不使用 Bundler)并手动将其添加到加载路径。
    5. 将代码放在私有 gem 存储库中。 Gemfury addon 最近进入了 beta 测试阶段,并且正是这样做的,但你可以使用任何你想要的私有 repo。

    【讨论】:

    • 有点自责,甚至没有考虑使用私人 gem 服务器。我最终可能会使用 Gemfury 作为一项完整服务,因为我实际上有 10 多个 heroku 部署需要相同的一组私有 gem。
    猜你喜欢
    • 2012-07-11
    • 2011-12-08
    • 1970-01-01
    • 2013-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-13
    • 1970-01-01
    相关资源
    最近更新 更多