Install ruby gem from private gitlab repository


I have ruby on rails project and I can not figure out how to add gem from private gitlab’s repo to Gemfile.
Any ideas?

Have you tried something along these lines?

The problem is that I can not authenticate to a repo, when I am trying to install gem.

Github allows you to do this:
gem ‘my_gem’, git: “https://#{ENV[‘GITHUB_TOKEN’]}”
gem ‘my_gem’, git: “”

But it does not work for gitlab.
I generated access token here:
git lab/profile/personal_access_tokens

and then pass this token as:
gem ‘my_gem’, git: ‘’
but no success.


In temrinal:
bundle config user:pass

And when i try to run bundle install, it still asks for username and password

Solved with next code.
In Gemfile:
gem 'my_gem', git: ''

Then in terminal:
bundle config username:password