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

Support for `chruby` #1205

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

Support for `chruby` #1205

sandstrom opened this issue Jun 2, 2014 · 4 comments

Comments

@sandstrom
Copy link

@sandstrom sandstrom commented Jun 2, 2014

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
Copy link
Member

@FooBarWidget FooBarWidget commented Jun 2, 2014

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

@sandstrom
Copy link
Author

@sandstrom sandstrom commented 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.

@FooBarWidget
Copy link
Member

@FooBarWidget 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
Copy link
Author

@sandstrom sandstrom commented 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.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.