If you have a private gem, deploying to heroku can be frustrating.. In my case, I do not have even a server so I am not looking (yet) to set up a private rubygem server. I just have another project on my machine that I would like to reuse as a gem.
Could not find gem ‘pgw’ ( >= 0, runtime)’ in any of the gem sources listed in your Gemfile
I tried Ole Morten Amundsen’s method, but it didn’t ( quite ) work (see below)
Magic directory method
mkdir -p vendor/cache
bundle update
git add -A
git commit -m"whatever"
git push heroku master
All the gems public or private are installed into the vendor/cache directory.
Pros:
- Simple.
- It works.
- Also allows for a locked down deployment (? not completely certain on this because heroku does report “Installing …” for all the gems including the private gem)
Cons:
- All the gems used are installed, not just the single gem that is not available on rubyforge.
- Magicalness feels like a possible bug. (Note: I am using bundler 1.0.13) so it may not work in future
- git bloat – all the external gems and dependencies are now part of your repo.
- Possible issues with machine specific deployments with other gems? ( not certain about this – but flagging it as a possibility )
Ole Morten Amundsen variant
gem unpack pgw --target vendor/gems
- edit Gemfile to explicitly list the gem version and supply the path
gem "pgw", "0.0.3", :path =>"{#File.expand_path(__FILE__)}/../vendor/gems/"
bundle install --local
git add -A
git commit -m"whatever"
git push heroku master
The resulting Gemfile.lock will have this:
PATH
remote: vendor/gems
specs:
pgw (0.0.3)
GEM
...(everything else ) ...
Pros:
- Feels more like the intended process
- Only extra code is the private gem ‘pgw’ – none of the standard ruby gems are added to the project.
Cons:
- More typing
- Have to include specific version number in the Gemfile – so harder to ensure against an accidental release with old version of gem.
- “unpacking” seems lame. Is there a way to keep the ‘pgw’ gem as a .gem file?
Questions
- Is there an easy way to move the gems to my master project other than
gem unpack
? - should the gem be put in
vendor/bundle
since that is the defaultBUNDLE_PATH
?
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.