atmos / heaven

:walking: Rails app for GitHub Flow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

capistrano provider doesn't let you use gems in your cap tasks

tcrayford opened this issue · comments

e.g: we use a campfire gem inside our cap tasks (to do deploy notifications), so our deploys fail like this:

`require': cannot load such file -- sparks 

I guess the right thing to do here would be to check for the existence of a Gemfile in the checked out repo, then run bundle install before running the capistrano task? I am happy whipping up a PR, just wanna check that approach sounds sane to you.

We'd also need to update the BUNDLE_GEMFILE attribute to point to the repo's Gemfile instead of inheriting the Gemfile from heaven. This may be a useful solution to #62 too.

I'm running into the same problems. Unless @tcrayford (or anyone else) already has a PR ready to go, I'd like to take a crack at it.

You'll probably want to use bundler-capistrano provider. It has support for adding gems to the :deploy group in Gemfile and running the deploy job in a new bundler context.

Thanks, @Mumakil. I got the bundler_capistrano to work with a Capistrano 3 deploy for one of my Rails apps.

I do have one problem, though. This app precompiles assets locally on deployment and rsyncs them with the server. Of course, in this case, "locally" means on the Heaven server. Since precompiling is a rake task, it has to load the entire app first, which creates a dependency on any gems required during initialization. Since the bundler_capistrano provider only loads the :heaven and :deployment bundler groups by default, most of those gems aren't loaded and the precompile task fails.

So, there are a few ways around this. If I precompile assets on the app server, it works. I could also include all of the dependencies in the :deployment group, but that adds a lot duplication to the Gemfile. The other way would be to provide an option for the bundler_capistrano provider to load other bundler groups. I'm happy to take a shot at implementing this unless it sounds like a bad idea.

Thoughts?

I guess the best option would be if the loaded bundler groups were configurable and would default to :deployment, :heaven. Rails 4 seems to have dropped the :assets bundler group but you could also bring that back.

I'm not gonna be working on this project in the foreseeable future.