Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7088759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:50:25+00:00 2026-05-28T07:50:25+00:00

I have a private repository on Github that I want to use. I deploy

  • 0

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" 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:50:25+00:00Added an answer on May 28, 2026 at 7:50 am

    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.

    gem 'my_gem', :git => 'https://my_username:my_password@github.com/my_github_account/my_repo.git', :ref => 'revision_no'
    

    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 Gemfile is to put the password into an environment variable; on Heroku you do this with heroku config:add VAR=value, and then in the Gemfile you’d use this variable, e.g.:

    gem 'my_gem',
      :git => "https://#{ENV['var_private_gem_username']}:#{ENV['var_private_gem_password']}@github.com/my_github_account.git",
      :ref => 'rev'
    

    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:

    private_repo_credentials = %w(var_private_gem_username var_private_gem_password).
      map { |var| ENV[var] }.compact.join(':')
    private_repo_credentials << '@' unless private_repo_credentials.empty?
    # private_repo_credentials will be "" if neither var is set
    # private_repo_credentials will be "username:password@" if they are set
    gem 'my_gem',
      :git => "https://#{private_repo_credentials}github.com/my_github_account.git",
      :ref => 'rev'
    

    I’ve not tested this last part. Please provide feedback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a private repository in github that has 5 collaborators.Now when the collaborators
I have a private SVN repository that I use for all of my projects.
Here's the situation: I have a public repository for my open-source app on github.com.
I have a project on GitHub behind a private repository. I want to make
I have a private repository on GitHub that contains an ASP.Net MVC project and
Why can NHibernate create a proxy for classes with properties that have private setters
I have a Private property that I want to access in my MS Test
I have a project on a private github repository (but this should work for
I have a private Rails app that I'm trying to install locally. It's currently
I have a github private repository, in which I have been working with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.