Closed AstonJ closed 9 years ago
When running ruby-install
as a normal user, it installs into ~/.rubies
. When running ruby-install as root (or via sudo), it will install into /opt/rubies/
and be available to all users. Try sudo ruby-install ruby ...
. Also consider configuring chruby globally.
Thanks for the reply @postmodern.
I installed 2.2.2 with the root user (and it is there in /opt/rubies/
) however when I ssh in to the server with a different user, ruby -v
shows the default OS installed Ruby. I can chruby 2.2.2
but if I log out and back in again it has reverted to the OS installed default.
Is there anyway I can get it to use 2.2.2 for this user and the apps installed for it? I have added the three lines to /etc/profile.d/chruby.sh
to configure it globally, and the two lines to .bashrc
(source /usr/local/share/chruby/chruby.sh
and source /usr/local/share/chruby/auto.sh
) for both root and this user.
Am I missing something else?
(I am running CentOS 7)
I'm so sorry @postmodern - I hadn't run ./scripts/setup.sh
after make install
(it's working fine now :)
However can you please confirm that the following needs to be added for additional (non-root) users on the system once Chruby has been installed please?
- Configure linux users (SSH as user)
vim ~/.bashrc #And lines below
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
vim ~/.bash_profile #Add line below
chruby ruby-2.2.2
vim ~/.ruby-version #Add line below
ruby-2.2.2
If you want chruby to be available by default for all users, do the system wide configuration. If you just want a newer version of ruby for all users, install ruby into /usr/local
via ruby-install --system ...
or use brightbox's ruby-ng packages.
Thanks for the reply @postmodern.
We need different Ruby versions for different apps, which run under different Linux users:
/home/app_one/ /home/app_two/ /home/app_three/ Where 'app' is the name of the linux user._
I've done the sys wide config and the steps as per my last post (also added a .ruby-version in the root of the Rails app) but Passenger is still using the OS installed Ruby.
Are there additional steps I am missing for Passenger? Sorry to keep replying here, please let me know if you would prefer I post this as a question on SO.
Edit: Just seen this https://github.com/phusion/passenger/issues/1205#issuecomment-44840445 :(
Passenger will use whatever ruby is currently in the $PATH
. So if you have chruby setting the ruby in ~/.bashrc
(at the top, as Ubuntu's .bashrc
will abort if it's not in interactive mode) Passenger should use it. However, it's usually easier to explicitly set the desired PassengerRuby
in the Apache configuration for the app. Deploying the apps would just require invoking chruby MY_RUBY
or explicitly calling /opt/rubies/.../bin/ruby -S bundle install --deployment
. Imho, explicit always trumps implicit when it comes to server configuration and deployment.
I think I know what was wrong - I installed passenger with yum install passenger
which used the OS installed Ruby. I'm not sure whether I tried PassengerRuby
now, but I started again and installed passenger with:
gem install passenger
passenger-install-apache2-module
And used PassengerRuby /opt/rubies/ruby-2.2.2/bin/ruby
and it's working fine :)
Thanks for all your help! :+1:
In case it's of any use to anyone else in future, here are my set-up notes:
======
CHRUBY
======
yum install curl
- install chruby
wget -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz
tar -xzvf chruby-0.3.9.tar.gz
cd chruby-0.3.9/
make install
./scripts/setup.sh
- configure chruby
vim ~/.bashrc #And two lines below
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
- system wide config
vim /etc/profile.d/chruby.sh #Add three lines below
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
source /usr/local/share/chruby/chruby.sh
fi
- install ruby-install
wget -O ruby-install-0.5.0.tar.gz https://github.com/postmodern/ruby-install/archive/v0.5.0.tar.gz
tar -xzvf ruby-install-0.5.0.tar.gz
cd ruby-install-0.5.0/
make install
- install rubies
ruby-install ruby 2.2.2
- default ruby
vim ~/.bash_profile #Add line below
chruby ruby-2.2.2
#Setup sites
- put a .ruby-version file in directory to specify ruby version for apps
vim ~/.ruby-version #Add line below
ruby-2.2.2
- in Passenger apache config specify ruby with:
PassengerRuby /opt/rubies/ruby-2.2.2/bin/ruby
- bundle with:
/opt/rubies/ruby-2.2.2/bin/ruby -S bundle install --deployment
I've run the following as the root user:
However when I log in to the server as a different linux user, the ruby that shows with
ruby -v
is the OS installed Ruby (Yet I have installed 2.2.2 with Chruby). I have added the two lines as per the first step to this users own.bashrc
, but still, it's showing the default OS installed Ruby.Do I need to install Rubies with each linux user? (We have different sites/apps per linux user). When I do that I get: "user_account is not in the sudoers file. This incident will be reported. !!! Installing dependencies failed!"
I assume that I need to run
bundle install
when logged in with each user?Not sure what I am doing wrong here, but any help appreciated.