documentation icon indicating copy to clipboard operation
documentation copied to clipboard

default_env not working as intended

Open palominoz opened this issue 13 years ago • 12 comments

I noticed some strange behaviour while working on a remote server w/rbenv system-installed. I was trying to fix the default PATH variable removing the comment on the line

 set :default_env, { path: '/opt/rbenv/shims:opt/rbenv/bin:$PATH' }

my console outputs:

me@localhost > bundle exec cap staging deploy:restart
INFO [c501cf64] Running rbenv on some.ip.address
DEBUG [c501cf64] Command: ( PATH=/opt/rbenv/shims:opt/rbenv/bin:$PATH rbenv )
DEBUG [c501cf64]    bash: rbenv: command not found

lurking on sources i can confirm that capistrano is correctly setting the default_env variable. So it is probably related on the sshkit dependancy or some misconfiguration in the capistrano sources.

palominoz avatar Oct 07 '13 18:10 palominoz

bad place to post this issue. I am moving it.

palominoz avatar Oct 07 '13 18:10 palominoz

I've got the same problem, where did you move this post?

DonGiulio avatar Nov 28 '13 22:11 DonGiulio

This is a wrong way of using rbenv over modified PATH. You can easily add https://github.com/capistrano/rbenv to your config and the problem will be solved.

kirs avatar Nov 29 '13 06:11 kirs

@DonGiulio the issue was moved here https://github.com/capistrano/capistrano/issues/675

palominoz avatar Nov 29 '13 07:11 palominoz

@kirs I've got the same problem of $PATH in default_env not being translated when executing mkdir.

As I mentioned in capistrano/capistrano#675. For this reason I believe the problem goes beyond the rbenv.

@palominoz thanks

DonGiulio avatar Nov 29 '13 11:11 DonGiulio

Don't, you're doing it wrong expanding path that way will NEVER be supported.

Sent from my Nexus 4. On 29 Nov 2013 12:59, "DonGiulio" [email protected] wrote:

@kirs https://github.com/kirs I've got the same problem of $PATH in default_env not being translated when executing mkdir.

As I mentioned in capistrano/capistrano#675https://github.com/capistrano/capistrano/issues/675. For this reason I believe the problem goes beyond the rbenv.

@palominoz https://github.com/palominoz thanks

— Reply to this email directly or view it on GitHubhttps://github.com/capistrano/documentation/issues/30#issuecomment-29512300 .

leehambley avatar Nov 29 '13 12:11 leehambley

@leehambley thanks, I don't understand what I'm supposed to do, I'm trying to get RVM with https://github.com/fnichol/chef-rvm to install rubies and gems.

What am I supposed to do instead in order to use it?

DonGiulio avatar Nov 29 '13 12:11 DonGiulio

Sorry, I can't get the idea of how chef cookbook is connected with PATH variable in Capistrano.

If you mean you want to deploy with RVM support, there is a great capistrano-rvm extension to do that. It will add wrappers to your commands so you won't need to modify PATH.

kirs avatar Nov 29 '13 13:11 kirs

Hi, I'm sorry I should have explained better.

I'm using chef to install ruby and the bundler gem, I'm incurring in an issue where the bundle is installed nicely for all users and it works, though capistrano runs it with sudo, and I'm getting the following problem:

 vagrant@berkshelf:~$ which bundle 
 /home/vagrant/.rvm/gems/ruby-2.0.0-p353@global/bin/bundle
 vagrant@berkshelf:~$ sudo which bundle
 /usr/bin/bundle

the sudo user uses the default bundler, which doesn't work. I was told that by specifying the default_env I could solve this, but really only got in more troubles.

any clue?

DonGiulio avatar Nov 29 '13 18:11 DonGiulio

I figured that it wasn't the sudo, but the fact that capistrano runs the commands in a non interactive shell, where the .bashrc script quits right at the beginning.

I moved the init scripts of RVM at the beginning of .bashrc and now the problem is fixed.

thanks a lot for the support,

DonGiulio avatar Nov 29 '13 23:11 DonGiulio

There's a lot more about that in the FAQ. see the "why SSH" link on the left, capistranorb.com

Sent from my Nexus 4. On 30 Nov 2013 00:42, "DonGiulio" [email protected] wrote:

I figured that it wasn't the sudo, but the fact that capistrano runs the commands in a non interactive shell, where the .bashrc script quits right at the beginning.

I moved the init scripts of RVM at the beginning of .bashrc and now the problem is fixed.

thanks a lot for the support,

— Reply to this email directly or view it on GitHubhttps://github.com/capistrano/documentation/issues/30#issuecomment-29541647 .

leehambley avatar Nov 30 '13 08:11 leehambley

@leehambley Thank you for pointing this out, I've spent hours hunting this issue down, what you said was the real cause for me.

yingdongzhang avatar Aug 29 '17 12:08 yingdongzhang