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

Conflict between system ruby and rvm1-capistrano3 installed ruby #67

Open
Rudikza opened this issue Oct 19, 2015 · 1 comment
Open

Conflict between system ruby and rvm1-capistrano3 installed ruby #67

Rudikza opened this issue Oct 19, 2015 · 1 comment

Comments

@Rudikza
Copy link

Rudikza commented Oct 19, 2015

Hi,

I am trying to use rvm1-capistrano3 on a Centos server which already has system ruby installed.
The system ruby is needed by the sysadmin for puppet and he has asked that I dont mess with it.

The problem is that most capistrano tasks use /usr/bin/env and when that happens it defauls to the system, ruby 2.0.0p598, instead of the specified version of jruby-9.0.1.0.

Here is the output from cap staging rvm1:check

DEBUG [e6ce521c] Command: /app/rvm1scripts/rvm-auto.sh rvm version
DEBUG [e6ce521c]  rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [e6ce521c] Finished in 0.586 seconds with exit status 0 (successful).
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [16772925] Running /app/rvm1scripts/rvm-auto.sh rvm list as app_deploy@x.x.x.x
DEBUG [16772925] Command: /app/rvm1scripts/rvm-auto.sh rvm list
DEBUG [16772925]
DEBUG [16772925]  rvm rubies
DEBUG [16772925]
DEBUG [16772925]  =* jruby-9.0.1.0 [ x86_64 ]
DEBUG [16772925]
DEBUG [16772925]  # => - current
DEBUG [16772925]  # =* - current && default
DEBUG [16772925]  #  * - default
DEBUG [16772925]
DEBUG [16772925] Finished in 0.754 seconds with exit status 0 (successful).
rvm rubies

=* jruby-9.0.1.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
DEBUG [3b561ebc] Running /app/rvm1scripts/rvm-auto.sh rvm current as app_deploy@x.x.x.x
DEBUG [3b561ebc] Command: /app/rvm1scripts/rvm-auto.sh rvm current
DEBUG [3b561ebc]  jruby-9.0.1.0
DEBUG [3b561ebc] Finished in 0.279 seconds with exit status 0 (successful).
jruby-9.0.1.0
DEBUG [56ed4fd2] Running /usr/bin/env if test ! -d /app/releases/20151019141431; then echo "Directory does not exist '/app/releases/20151019141431'" 1>&2; false; fi as app_deploy@x.x.x.x
DEBUG [56ed4fd2] Command: if test ! -d /app/releases/20151019141431; then echo "Directory does not exist '/app/releases/20151019141431'" 1>&2; false; fi
DEBUG [56ed4fd2] Finished in 0.042 seconds with exit status 0 (successful).
DEBUG [a0eb5962] Running /usr/bin/env ruby --version || true as app_deploy@x.x.x.x
DEBUG [a0eb5962] Command: cd /app/releases/20151019141431 && /usr/bin/env ruby --version || true
DEBUG [a0eb5962]  ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
DEBUG [a0eb5962] Finished in 0.061 seconds with exit status 0 (successful).
ruby 2.0.0p598 (2014-11-13) [x86_64-linux]

The problem here is that /usrbin/env is using ruby 2.0.0p598 instead of jruby.

I have tried using 'rvm1:hook' but that doesn't seem to make a difference.

Is there some way to force all commands to use rvm-auto.sh instead of /usr/bin/env or am I holding this thing wrong?

@Rudikza
Copy link
Author

Rudikza commented Oct 20, 2015

Ok so the problem here is that rvm1-capistrano3 is not setting rvm1_map_bins correctly when used with capistrano-puma.

Capistrano-puma sets rvm_map_bins to ["puma", "pumactl'] and then rvm1-capistrano3 uses the following code to merge what ever is in rvm_map_bins with "rake", "gem", "bundle", "ruby".

set :rvm1_map_bins,   -> { fetch(:rvm_map_bins, %w{rake gem bundle ruby}) }

The problem is that it only returns back what is already in rvm_map_bins and does not append the new string elements in the array.

For example:

pry(main)> set(:rvm_map_bins, %w{peach apple})
=> ["peach", "apple"]
pry(main)> fetch(:rvm_map_bins, %w{rake gem bundle ruby})
=> ["peach", "apple"]

One way to do this would be to use the same method as capistrano-puma by doing a to_a.concat

pry(main)> set(:rvm_map_bins, %w{grape banana})
=> ["grape", "banana"]
pry(main)> fetch(:rvm_map_bins).to_a.concat(%w{ rake gem bundle ruby })
=> ["grape", "banana", "rake", "gem", "bundle", "ruby"]

So the new code in lib/rvm1/tasks/capistrano3.rake:41 would look like this:

set :rvm1_map_bins, -> { fetch(:rvm_map_bins).to_a.concat(%w{ rake gem bundle ruby }) }

I would be happy to write the code, just let me know if you are happy with this way of doing it?

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

1 participant