Rails commands should use bundle exec (rake activation error) #639

Closed
defeated opened this Issue Sep 7, 2013 · 13 comments

Comments

Projects
None yet
5 participants
Contributor

defeated commented Sep 7, 2013

opening here because capistrano/rails doesn't have issue tracking enabled?

DEBUG [30b95119] Command: cd /myapp/releases/20130907122620 &&
/usr/bin/env rake assets:precompile RAILS_ENV=production
DEBUG [30b95119]    rake aborted!
You have already activated rake 10.0.1, but your Gemfile requires rake 10.1.0.
Using bundle exec may solve this.
Owner

kirs commented Sep 8, 2013

Do you have capistrano-bundler required?

Contributor

defeated commented Sep 8, 2013

@kirs yes, this was my gemfile line gem 'capistrano-bundler', github: 'capistrano/bundler', ref: 'c6443d5'.

capistrano-bundler is currently strictly about running the bundle install command upon deployment. I don't see where capistrano-bundler sets :rake to use the bundle_cmd like the original Bundler plugin does https://github.com/bundler/bundler/blob/v1.3.5/lib/bundler/capistrano.rb#L10

Either way, Rails v3+ depends on Bundler, so in my opinion, this should probably be baked into the capistrano-rails gem. (Either as a dependency, or a simple check like "is there a Gemfile in root"). What do the maintainers think?

Owner

kirs commented Sep 9, 2013

Unfortunately, we probably can not redefine rake as bundle exec rake in capistrano/bundler because it can be already hooked from rvm or rbenv integration.

Although, rbenv integration have bundle hook:
https://github.com/capistrano/rbenv/blob/master/lib/capistrano/tasks/rbenv.rake#L8

What kind of ruby version manager do you use?

Contributor

defeated commented Sep 9, 2013

@kirs if you define a bundle_cmd option, you can set that via the rbenv or rvm Cap plugins. Similar to how they did it in the original plugin:

set :rake, lambda { "#{fetch(:bundle_cmd, "bundle")} exec rake" }

So capistrano/rbenv could then set:

set :bundle_cmd, -> { ... }

I'd be happy to send a PR if the maintainers are interested?

Owner

kirs commented Sep 9, 2013

That can be confusing because in v3 @leehambley introduced SSHKit.config.command_map.
Are we going to use command_map for all commands except rake which would use bundle_cmd? Seems not so good.

Contributor

defeated commented Sep 9, 2013

ah I see. I'm not terribly familiar w/ capistrano/sshkit, so there is some history I need to catch up on. I'll have a look and a think.

Owner

kirs commented Sep 9, 2013

Thanks!
I totally agree with you that there is an issue here with rake and bundler, but IMHO we can't just rewrite it using bundle_cmd like in v2.

Kir Shatrov
+7 (929) 631-46-35

On Monday, September 9, 2013 at 6:24 PM, eddie cianci wrote:

ah I see. I'm not terribly familiar w/ capistrano/sshkit, so there is some history I need to catch up on. I'll have a look and a think.


Reply to this email directly or view it on GitHub (#639 (comment)).

Owner

kirs commented Sep 9, 2013

BTW if you need a hotfix, just add SSHKit.config.command_map[:rake] = "bundle exec rake" at the top of your config.

Owner

leehambley commented Sep 10, 2013

I don't want to add a 'bundle cmd' or similar, with some clever work we can
make the command map work for interoperable plugins, it will just require a
little forethought
On Sep 9, 2013 10:39 PM, "Kir Shatrov" notifications@github.com wrote:

BTW if you need a hotfix, just add SSHKit.config.command_map[:rake] =
"bundle exec rake" at the top of your config.


Reply to this email directly or view it on GitHubhttps://github.com/capistrano/capistrano/issues/639#issuecomment-24116505
.

Any workaround on this issue?

Owner

kirs commented Nov 3, 2013

SSHKit.config.command_map[:rake] = "bundle exec rake"

@kryachkov does this snippet work for you?

ncherro commented Nov 6, 2013

@kirs I added that line to the top of my deploy.rb file and it worked for me. thanks!

Owner

kirs commented Nov 7, 2013

Great. I'm working on the new version of SSHKit which will be required in the next release of capistrano-rails and you won't need to use such hotfix. I apologize for this temporary issue.

kirs closed this Nov 7, 2013

@dgcliff dgcliff added a commit to NEU-Libraries/cerberus that referenced this issue Mar 29, 2017

@dgcliff dgcliff Trying capistrano/capistrano#639 as a solution 93b41d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment