capistrano / rvm

MIT License
140 stars 47 forks source link

Executing code locally with mixed rvm types #62

Open rkrdo opened 9 years ago

rkrdo commented 9 years ago

I'm trying to run a task that involves the run_locally method, but whenever Capistrano tries to execute this task, it tries to use the server's rvm type which is different from my type (system vs user), is there a way to tell Capistrano to check what type to use during a run_locally block?

betesh commented 9 years ago

This is part of a much wider issue, which is that capistrano-rvm assumes all servers you are deploying to have the same RVM environment. I would like to see the more general issue addressed. Has anyone put any thought into how we would do that?

I realize it's a limitation of capistrano that it uses a single SSHKit command map for all servers/roles, so capistrano-rvm might be the wrong place to address this. Are there any open tickets for this at the moment?

fabn commented 9 years ago

I just got the same issue. I don't know capistrano internals, however I think that run_locally should not use rvm wrapper at all. The local env is developer responsibility and he should care to make commands working with no prefix or anything else. Is this something that can be fixed in this gem?

betesh commented 9 years ago

@fabn A good workaround is to use a String instead of a Symbol, i.e.

run_locally do
  execute "rake my_task" # instead of execute :rake, :my_task
end
jeremywadsack commented 8 years ago

Also just ran into this. Thanks @betesh for the workaround.

It seems to me that capistrano-rvm would need to determine the rvm environment (system or user or no rvm) on each server as it connects to it, and keep a hash that maps the server to the rvm command. However, I don't know how to work around the single prefix for all servers.

betesh commented 8 years ago

Most capistrano plugins seem to have made the assumption that the needed command prefixes are the same on all servers--as I mentioned above, there's a limitation in SSHKit which doesn't give them much of an option.

For instance, there is a limitation in capistrano-passenger when you are running multiple instances of passenger and need to specify an instance ID--the instance ID is different on every server. capistrano-rvm assumes you are running the same version of rvm on every server. You can work around that by setting rvm_ruby_version to default, but that assumes you have the ability to make the targeted RVM version the default on each respective server, and that all servers use RVM.