I have a private repository on Github that I want to use. I deploy my app to Heroku. How can I specify a private repository as the source on my gemfile? I imagine it wouldn’t be enough to simply say
gem "mygem", :git=>"my github address"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As per suggestion from Heroku tech support, the easiest way to do this is by putting the username and password into the URL, as in Basic HTTP Auth, e.g.
This worked for us. This is still somewhat dissatisfying as we had to put a password into the Gemfile. We dealt with this by adding a new github user account and adding that account as collaborator on the gem project. Still not foolproof security, but the impact is more narrow.
Other options I read about are to set up your own gem server or to vendor the gem.
Update 5/16/2012:
Another way to get around putting the password into the
Gemfileis to put the password into an environment variable; on Heroku you do this withheroku config:add VAR=value, and then in theGemfileyou’d use this variable, e.g.:This is the standard on Heroku to avoid putting passwords, API keys and any credentials into the code. For local development/test, you can set these environment variables. Or, assuming your development machine is set up for SSH access to github, you won’t need the credentials for local development (the SSH credentials will be in effect already). So you could set up some conditional logic:
I’ve not tested this last part. Please provide feedback.