Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.8.0 breaks capistrano-rbenv due to "~" in environment variable values no longer being expanded #303

Closed
rudylee opened this issue Dec 3, 2015 · 17 comments

Comments

@rudylee
Copy link

rudylee commented Dec 3, 2015

I am using capistrano-rbenv in my project for deployment

I just ran a bundle update which updates the sshkit version to 1.8.0 and my capistrano deployment starts to break.

Here is the full output of my failed deployment: https://gist.github.com/rudylee/5f560d70e6a2fe9eaad0 ( see line 238 )

DEBUG [81d1a12e] Command: cd /home/deploy/version/releases/20151203100835 && ( export RBENV_ROOT="~/.rbenv" RBENV_VERSION="2.2.0" ; ~/.rbenv/bin/rbenv exec bundle install --path /home/deploy/version/shared/bundle --without development test --jobs=3 --retry=3 --deployment --quiet )
DEBUG [cb8f1d7e]    rbenv: version `2.2.0' is not installed (set by RBENV_VERSION environment variable)

I think the problem is related to this commit de492dd ( previous version doesn't have export in front of the command )

In the meantime, I can fix it my specifying the sshkit version in my Gemfile to 1.7.1

@leehambley
Copy link
Member

Your server doesn't have the Ruby ver specified installed, SSHKit is now
using your system rbenv
On 3 Dec 2015 12:40 p.m., "Rudy Lee" [email protected] wrote:

I am using capistrano-rbenv in my project for deployment

I just ran a bundle update which updates the sshkit version to 1.8.0 and
my capistrano deployment starts to break.

Here is the full output of my failed deployment:
https://gist.github.com/rudylee/5f560d70e6a2fe9eaad0 ( see line 238 )

DEBUG [81d1a12e] Command: cd /home/deploy/version/releases/20151203100835 && ( export RBENV_ROOT="~/.rbenv" RBENV_VERSION="2.2.0" ; ~/.rbenv/bin/rbenv exec bundle install --path /home/deploy/version/shared/bundle --without development test --jobs=3 --retry=3 --deployment --quiet )
DEBUG [cb8f1d7e] rbenv: version `2.2.0' is not installed (set by RBENV_VERSION environment variable)

I think the problem is related to this commit de492dd
de492dd
( previous version doesn't have export in front of the command )

In the meantime, I can fix it my specifying the sshkit version in my
Gemfile to 1.7.1


Reply to this email directly or view it on GitHub
#303.

@rudylee
Copy link
Author

rudylee commented Dec 3, 2015

Thanks for the answer, probably it's the issue with my rbenv installation.

This is the output if run rbenv versions in my server

[user@server ~]# rbenv versions
  system
  2.1.4
* 2.2.0 (set by /home/user/.ruby-version)
[user@server ~]#

and this is the output if I run it with export

[user@server ~]# export RBENV_ROOT="~/.rbenv" RBENV_VERSION="2.2.0" ; ~/.rbenv/bin/rbenv versions
rbenv: version `2.2.0' is not installed (set by RBENV_VERSION environment variable)
  system
[user@server ~]#

using the system ruby won't work for us because we have 2 Rails app running with 2 different ruby versions.

@leehambley
Copy link
Member

SSHKit now picks up things defined in your shell (I think) so it's entirely possible that this login shell already has rbenv, and/or that the export/subshell change to env vars breaks something... I don't tend to run things like rbenv/rvm in production, so I can't many any reasonable suggestions. Unfortunately.

@leehambley
Copy link
Member

There should be no difference in the end with/without export is should have the same effect, unless export RBENV_ROOT="~/.rbenv"; rbenv versions leaves any clues...

@rudylee
Copy link
Author

rudylee commented Dec 3, 2015

same issue with just export, I have to use exec $SHELL -l to fix it

[user@server ~]# export RBENV_ROOT="~/.rbenv"; rbenv versions
rbenv: version `2.2.0' is not installed (set by /home/dev/.ruby-version)
  system
[user@server ~]# rbenv versions
rbenv: version `2.2.0' is not installed (set by /home/dev/.ruby-version)
  system
[user@server ~]# exec $SHELL -l
[user@server ~]# rbenv versions
  system
  2.1.4
* 2.2.0 (set by /home/dev/.ruby-version)
[user@server ~]#

that's fine, I'll just stick with 1.7.1 for now. thanks.

@McRip
Copy link

McRip commented Dec 3, 2015

Same issue here. downgrading to 1.7.1 solves this.

@leehambley
Copy link
Member

if # export RBENV_ROOT="~/.rbenv"; rbenv versions causes errors, this is an rbenv problem, not a SSHKit one, but maybe you can pick that up with the author of rbenv-capistrano see if he has any idea why rbenv doesn't like to read it's variables from RBENV_ROOT, or if indeed your user's ~/.rbenv is empty.

It strikes me that one potential problem is that ~ isn't being expanded, which I can't comment on at the moment, just a thought... hard code the full path?

@mattbrictson
Copy link
Member

@leehambley You nailed it. Replacing ~ with the full path seems to fix the issue (I'm testing locally on my development machine, which exhibits the same behavior).

The introduction of the export in de492dd seems to be a red herring. If I have time today I will do some more digging to see what change is triggering this problem for those upgrading 1.8.

In any case, the workaround you suggested does work.

@mattbrictson
Copy link
Member

Aha. The culprit is the introduction of double-quotes around environment variables, introduced in 9120312. Without quotes, ~ is expanded (1.7.1). With quotes, ~ is not expanded (1.8.0).

@leehambley
Copy link
Member

Ah, nice work @mattbrictson :) as always, you seem to be the master of debugging! … any thoughts on a fix, I can see the case for both, actually, and I'm hesitant to make it configurable - perhaps this is a problem of the capistrano-rbenv gem needing to update it's docs, or maybe call out as the deploy user first to get the whole path ?

@mattbrictson
Copy link
Member

@leehambley For capistrano-rbenv (and other plugins/tasks affected by this), do you think replacing ~ with $HOME be a good fix? I've tested it and it seems to work. I could open a PR for capistrano-rbenv to that effect.

@leehambley
Copy link
Member

Nice, I think that's sane, I suppose it makes sense too, which is
reassuring!
On 3 Dec 2015 6:01 p.m., "Matt Brictson" [email protected] wrote:

@leehambley https://github.com/leehambley For capistrano-rbenv (and
other plugins/tasks affected by this), do you think replacing ~ with $HOME
be a good fix? I've tested it and it seems to work. I could open a PR for
capistrano-rbenv to that effect.


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

@mattbrictson mattbrictson changed the title 1.8.0 breaks my deployment 1.8.0 breaks capistrano-rbenv due to "~" in environment variable values no longer being expanded Dec 3, 2015
@mattbrictson
Copy link
Member

@rudylee I renamed the title of this issue to better summarize the problem. I hope that's OK!

@mattbrictson
Copy link
Member

I've opened a PR for capistrano-rbenv to use $HOME: capistrano/rbenv#59

@rudylee
Copy link
Author

rudylee commented Dec 3, 2015

@mattbrictson that's fine, thanks for the help by the way.

@mattbrictson
Copy link
Member

This has been fixed in capistrano-rbenv 2.0.4.

@fguillen
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants