John K
John K

Reputation: 385

Using "bundle install --local" on Heroku Cedar

I have an app that was originally on Bamboo. I have updated it to ruby 1.9 and gotten rid of the all the dependances. And I am trying to deploy on Heroku but it fails.

-----> 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 [email protected]:WaterfallFMS/deployment.git
   Host key verification failed.
   fatal: The remote end hung up unexpectedly
   Git error: command `git clone '[email protected]: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.

I tracked this down to bundler not caching git repos (https://github.com/carlhuda/bundler/issues/67). It was fixed if you use the "bundle package --all" flag.

The problem is that you HAVE to use "Bundle install --local" or it will still reference the git repo before the cache. I can't figure out how to force heroku to use "--local".

Upvotes: 0

Views: 1032

Answers (1)

willglynn
willglynn

Reputation: 11520

The bundle install command is hardcoded into 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")

Ultimately, this is painful because you're trying to get private code from outside your repository into your slug, meaning the slug compiler has to be able to get the code somehow. As I see it, your options are:

  1. Fork the buildpack to work with bundle package. See the Buildpacks documentation for more.
  2. Point Bundler to https://username:[email protected]/username/repo. Yes, those are plaintext credentials. Yes, they would be in source control.
  3. Put the code in a public repo. Probably not an option.
  4. Put the code into your Heroku repo another way. You could vendor the foreign code yourself (not using Bundler) and add it to the load path by hand.
  5. Put the code in a private gem repository. The Gemfury addon recently went into beta and does exactly this, but you could use whatever private repo you want.

Upvotes: 1

Related Questions