What is the best way to load /etc/profile in Capistrano?

687 views
Skip to first unread message

Huiming Teo

unread,
Feb 21, 2013, 10:30:19 AM2/21/13
to capis...@googlegroups.com
Hi,

Is there a way to tell Capistrano to load or source /etc/profile ?

I'm setting up a Ubuntu server, with rbenv installed system-wide. rbenv is initialized via /etc/profile.d/rbenv.sh. 

Ruby environment is not available when /etc/profile is not loaded. I understand Capistrano doesn't load /etc/profile, but is there a way to make it happens?


Craig White

unread,
Feb 21, 2013, 10:55:27 AM2/21/13
to capis...@googlegroups.com
----
I found that adding this near the top of the deploy script should handle it…

default_run_options[:shell] = '/bin/bash --login'

Craig

Teo Hui Ming

unread,
Feb 21, 2013, 5:44:53 PM2/21/13
to capis...@googlegroups.com
Thanks Craig, it works!

$ ssh host1 'bash -l -c "echo \$PATH && ruby --version"'
/opt/rbenv/shims:/opt/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-linux]

Is there any disadvantage to run Capistrano in bash login shell?
> --
> --
> * You received this message because you are subscribed to the Google Groups "Capistrano" group.
> * To post to this group, send email to capis...@googlegroups.com
> * To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "Capistrano" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Huiming

Lee Hambley

unread,
Feb 22, 2013, 3:28:40 AM2/22/13
to capis...@googlegroups.com
Only that it's a less clean environment. Doesn't RVM include a package for Capistrano so that one doesn't have to cross the streams?

(chiefly, if you load your dotfiles, what's to say "git" isn't an alias for something else, or that `ls` works the same way, or that your path isn't hugely modified… it's better to let cap run in a clean environment as it was designed to do. Tools like RVM are hacks, because Ruby doesn't provide a decent way to switch envs, and play nicely with other versions of itself. This is fairly normal as far as scripting languages go, but by and large, if you use a binstubs approach, which I'm sure rvm supports, and export the correct two/three environmental variables, then rvm should work just fine.)

Cassiano Leal

unread,
Feb 22, 2013, 6:40:33 AM2/22/13
to capis...@googlegroups.com

Works like a charm. :)

- cassiano

Teo Hui Ming

unread,
Feb 23, 2013, 10:15:11 AM2/23/13
to capis...@googlegroups.com
Ya, rvm-capistrano works just fine. But i'm using rbenv, not rvm :)

Lee Hambley

unread,
Feb 23, 2013, 10:18:45 AM2/23/13
to capis...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages