Home » Ruby » Gem file with git remote failing on heroku push

Gem file with git remote failing on heroku push

Posted by: admin November 30, 2017 Leave a comment

Questions:

I have the following line in my gemfile:

gem 'client_side_validations', :git => "[email protected]:Dakuan/client_side_validations.git", :branch => "master", ref: '2245b4174ffd4b400d999cb5a2b6dccc0289eb67'

The repo it’s pointing at is public and I can run bundle install / update locally just fine. When I try to push to Heroku I get the following error:

   Fetching [email protected]:Dakuan/client_side_validations.git
   Host key verification failed.
   fatal: The remote end hung up unexpectedly
   Git error: command `git clone '[email protected]:Dakuan/client_side_validations.git' "/tmp/build_1xa9f06n4k1cu/vendor/bundle/ruby/1.9.1/cache/bundler/git/client_side_validations-56a04875baabb67b5f8c192c6c6743df476fd90f" --bare --no-hardlinks` in directory /tmp/build_1xa9f06n4k1cu has failed.

!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app

Anyone got any ideas about what’s going on here?

Answers:

Use this GitHub URL instead: git://github.com/Dakuan/client_side_validations.git

The [email protected]:… URL is the writable SSH version, which requires authentication with an SSH key connected to a GitHub account that has write access to the repository.

The git://github.com/… URL is the public, read-only version.

Since the gem you’re using is in a public GitHub repository, you can also use this shorthand in your Gemfile:

gem 'client_side_validations', :github => 'Dakuan/client_side_validations'

See the Bundler Git documentation for more information.

Questions:
Answers:

A late second answer, as I ran into some confusing output from Heroku’s build logs which stumped me for a while.

If you have multiple Github hosted gems in your Gemfile, and one of them is inaccessible (in my case, I had accidentally pointed to a private repo of mine), the build logs throw an error like Username not found or Repository not found for all the Github hosted gems – even those that are available.