Support for `chruby` #1205

Closed
sandstrom opened this Issue Jun 2, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@sandstrom

chruby1 is an excellent tool to set/switch among ruby versions. It would be good if Passenger would support it (afaik it does not).

The way I've understood it there are two related things that must work:

  1. Passenger must use the ruby executable designated by chruby and
  2. the environment variables ($GEM_PATH, $GEM_HOME, etc) set by chruby must be used.

My guess would be that passenger_load_shell_envvars2 would solve this, but it seems like it does not.

Somewhat related, nginx has support for loading /etc/default/nginx when starting, but on many OS (e.g. Ubuntu) this is a dash, not bash script. So one cannot source in chruby here.

What are your thoughts, is there a feasible way of using chruby already, and if not what steps would be needed to make it work?

Related issue in chruby: postmodern/chruby#258

@FooBarWidget

This comment has been minimized.

Show comment
Hide comment
@FooBarWidget

FooBarWidget Jun 2, 2014

Member

You can just set passenger_ruby to a wrapper script that does all that, can't you?

Member

FooBarWidget commented Jun 2, 2014

You can just set passenger_ruby to a wrapper script that does all that, can't you?

@sandstrom

This comment has been minimized.

Show comment
Hide comment
@sandstrom

sandstrom Jun 2, 2014

Good idea, thanks!

Got it working with a wrapper script (for reference below, in case it helps someone else).

#!/bin/bash

source /usr/local/share/chruby/chruby.sh
chruby ruby-2.1.2

exec "ruby" "$@"

You're better positioned to judge whether this falls within Passenger, chruby or the end-users [my] responsibility.

But if there was an easier way of getting chruby and Passenger to play well together it would be neat. Although it was an easy fix, I'm not well acquainted with bash/unix and the solution was far from obvious. I'm guessing there may be others in the same situation.

Good idea, thanks!

Got it working with a wrapper script (for reference below, in case it helps someone else).

#!/bin/bash

source /usr/local/share/chruby/chruby.sh
chruby ruby-2.1.2

exec "ruby" "$@"

You're better positioned to judge whether this falls within Passenger, chruby or the end-users [my] responsibility.

But if there was an easier way of getting chruby and Passenger to play well together it would be neat. Although it was an easy fix, I'm not well acquainted with bash/unix and the solution was far from obvious. I'm guessing there may be others in the same situation.

@FooBarWidget

This comment has been minimized.

Show comment
Hide comment
@FooBarWidget

FooBarWidget Jun 2, 2014

Member

I think it's the user's responsibility.

Also, I don't recommend chruby if you're not well acquainted with bash and Unix. Chruby's entire design assumes that the user is acquainted with how Unix works. Chruby makes extensive use of environment variables, paths, scripts, etc, all part of its philosophy of "simplicity" (in the implementation sense). That is a sound decision, but it does mean that the user must be knowledgeable enough to know about all the mechanisms involved. So you should either learn the necessary Unix skills, or you should use a solution that takes care of more things for you, like RVM.

Member

FooBarWidget commented Jun 2, 2014

I think it's the user's responsibility.

Also, I don't recommend chruby if you're not well acquainted with bash and Unix. Chruby's entire design assumes that the user is acquainted with how Unix works. Chruby makes extensive use of environment variables, paths, scripts, etc, all part of its philosophy of "simplicity" (in the implementation sense). That is a sound decision, but it does mean that the user must be knowledgeable enough to know about all the mechanisms involved. So you should either learn the necessary Unix skills, or you should use a solution that takes care of more things for you, like RVM.

@sandstrom

This comment has been minimized.

Show comment
Hide comment
@sandstrom

sandstrom Jun 2, 2014

@FooBarWidget Thanks for your help, and advice. Much appreciated!

I prefer chruby over rvm — I may not be an unix expert (evidently 😄), but I'm fairly quick to learn.

@FooBarWidget Thanks for your help, and advice. Much appreciated!

I prefer chruby over rvm — I may not be an unix expert (evidently 😄), but I'm fairly quick to learn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment