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

Can't deploy if you're using Rbenv locally #1104

Closed
equivalentideas opened this issue Feb 9, 2017 · 1 comment
Closed

Can't deploy if you're using Rbenv locally #1104

equivalentideas opened this issue Feb 9, 2017 · 1 comment
Assignees

Comments

@equivalentideas
Copy link
Contributor

Currently, with the version of Ruby (2.3.1) we're using, people (me) using rbenv can't deploy to production.

Here's how our capistrano config decides which ruby version to deploy with set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") https://github.com/openaustralia/planningalerts/blob/master/config/deploy.rb#L7

if stage != "development"
  require 'rvm/capistrano'
  set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
end

The ENV['GEM_HOME'] is the path where RubyGems/bundler keeps your ruby gems. The gsub extracts what it expects to be the current ruby version out of that path. The problem is that why that seems to work for where RMV keeps it's ruby gems, it doesn't work for where rbenv keeps them.

Here's @henare’s description of the challenge:

work out how we get capistrano to understand we want to use 2.3.1
and to make it work on RVM machines and rbenv
and on the server 🙂
and no, hardcoding isn't the answer 🙂
however we do have the luxury of only using 1 Ruby version
so if that was specified in only one place that would be a very good thing
it's not bad right now. It's specified in .ruby-version
and I guess travis.yml
so if you can work out a solution that maintains that and works on rvm and rbenv that would be superfly

@equivalentideas
Copy link
Contributor Author

equivalentideas commented Feb 9, 2017

One idea is trying what rvm-capistrano recommends:

set :rvm_ruby_string, :local

Reading the code 🤓 , it appears that if it sees :local it checks if you're using rbenv, and finds the details it wants. If you're not using rbenv, if calls back to ENV['GEM_HOME'].gsub(/.*\//,""). This is the same statement we have hardcoded in our deploy.rb. I wonder why? It looks like that's pretty old, so maybe it predates the :local option in rvm-capistrano.

I'm going to open a PR for this.

The other idea I had was pulling the value out of the .ruby-version file—but it seems much much preferable to integrate with rvm and do what it wants since that's what we're using in production.

equivalentideas added a commit that referenced this issue Feb 9, 2017
In rvm-capistrano, if you use the :local flag here, it will first check to
see if you're using rbenv and detect the local ruby verion. If you're
not using rbenv it falls back to expect rvm and uses the same statement
I'm replacing here to detect the version.

See this https://github.com/readly/rvm-capistrano/blob/master/lib/rvm/capistrano/base.rb#L77-L88

Fixes #1104
@equivalentideas equivalentideas self-assigned this Feb 9, 2017
equivalentideas added a commit that referenced this issue Feb 13, 2017
Upgrading this gem because we need the rbenv support added in
rvm/rvm-capistrano@f3d25f1

Relates to #1104
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

2 participants