Bjoernsen
Bjoernsen

Reputation: 2418

Wrong ruby/gemset/local variable version using capistrano

Currently, I try to deploy my Rails 4 project with capistrano. At the moment, the server is the same as the host, but different users are used. The issue is that capistrano does not load RVM AND local variables correctly, at the same time. The local variable is set in /etc/profile.d/oracle.sh

set :default_shell, "bash -l"
set :rvm_ruby_string, "ruby-2.0.0-p0@rails4"
require "rvm/capistrano"
set :use_sudo: false
...
...
desc "tester"
task :tester, hosts: "localhost" do
  run "echo $TNS_ADMIN"
  run "ruby -v"
  run "gem list"
end

If I use this settings, I get:

echo $TNS_ADMIN --> "correct path"
ruby -v --> 2.0.0p195 (wrong version)
gem list --> 5 gems (wrong)

If I do not use set :default_shell, "bash -l", I get:

echo $TNS_ADMIN --> "" (wrong)
ruby -v --> 2.0.0p0 (correct version)
gem list --> > 100 gems (correct)

If I use set :default_shell, :bash, I get:

echo $TNS_ADMIN --> "" (wrong)
ruby -v --> 1.9.3p194 (wrong version = ruby version of the system)
gem list --> > 5 gems (wrong)

If I do not use set :rvm_ruby_string, I get the same wrong result like using both lines (set :default_shell, "bash -l" and set :rvm_ruby_string, "...")

But I would like to have the local variable $TNS_ADMIN set and the correct ruby/gemset (2.0.0p0@rails with > 100 gems). What did I miss?

Upvotes: 0

Views: 702

Answers (1)

mpapis
mpapis

Reputation: 53158

remove the first line:

set :default_shell, "bash -l"

it disables rvm-capistrano integration.

You can read the variable with:

run "source  /etc/profile.d/oracle.sh; echo $TNS_ADMIN"

Upvotes: 1

Related Questions