Using Sidekiq Pro in a public Repo
How to use Sidekiq-Pro with a public repo..with Heroku
Only because we didn't try it anywhere else.
tldr;
TLDR Solution
Story behind problem
In a recent project in which we are using a public repo we made the mistake of including our source url for access to the Sidekiq-Pro Gem within minutes Mark Perham was knocking our digital door(email) giving us a wag of the finger.
We where then faced with a dilemma the client insisted we kept an open repo but we needed the power of sidekiq-pro. Having to edit in the url into our Gemfile everytime we pulled from Git would be a pain.
After much googling and StackOverflow no simple answer bubbled up. It wasn't until we came across this RubyGems Doc -Gem Sources
Solution:
Just create a .gemrc in root of the rails app directory, remove the source url from the gemfile and add the source like so.
./.gemrc
sources: - https://user:[email protected]/
This solved our problem in development and keeping the repo open but then we came across another issue in that our heroku server wouldn't build becuase bundle wouldn't pass after some experimentation we found out that the Enviroment Variables are available at the start of each build and since a Gemfile is just ruby anyway.
./Gemfile
# If production use sidekiq pro url if ENV['RACK_ENV'] == 'production' gem 'sidekiq-pro', :source => "https://#{ENV['sidekiq_url']}" else gem 'sidekiq-pro', '~> 1.9.2' end
Tldr Solution
./.gemrc
sources: - https://user:[email protected]/
./Gemfile
# If production use sidekiq pro url if ENV['RACK_ENV'] == 'production' gem 'sidekiq-pro', :source => "https://#{ENV['sidekiq_url']}" else gem 'sidekiq-pro', '~> 1.9.2' end









