RVM can't set ruby as default - rvm

I have no idea why but RVM can't seem to change the default Ruby. I'm using Oh My Zsh and tried everything I've found but nothing seems to work.
➜ Sites rvm use 2.0.0 --default
Using /Users/anahkiasen/.rvm/gems/ruby-2.0.0-p247
➜ Sites rvm list
rvm rubies
=* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
➜ Sites rvm reload && rvm list
RVM reloaded!
rvm rubies
* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Now the Ruby is set as default but RVM doesn't load it as "current", which means it does not load the gemsets that are affiliated to it.
➜ Sites rvm use 2.0.0
Using /Users/anahkiasen/.rvm/gems/ruby-2.0.0-p247
➜ Sites gem list
*** LOCAL GEMS ***
backports (3.3.3)
bson (1.9.1)
bson_ext (1.9.1)
bundler (1.3.5)
bundler-unload (1.0.1)
eventmachine (1.0.3)
genghisapp (2.3.7)
json (1.8.0)
mongo (1.9.0)
mustache (0.99.4)
rack (1.5.2)
rack-protection (1.5.0)
rack-test (0.6.2)
rake (10.1.0)
rubygems-bundler (1.2.2)
rvm (1.11.3.8)
sass (3.2.10)
sass-globbing (1.1.0)
sinatra (1.4.3)
sinatra-contrib (1.4.0)
sinatra-mustache (0.1.0)
tilt (1.4.1)
vegas (0.1.11)
➜ Sites rvm reload && gem list
RVM reloaded!
*** LOCAL GEMS ***
Nothing.
I have no .bashrc nor .bash_profile. There is no RVM reference in my .zprofile and here is my .zshrc :
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
ZSH_THEME="robbyrussell"
DEFAULT_USER="anahkiasen"
# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
plugins=(git bower brew composer gem laravel sublime)
## RVM and Rubygems
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
source $ZSH/oh-my-zsh.sh
I've tried swapping the above two lines, tried moving the RVM loading into .zprofile, nothing. Everytime I open a new instance of the terminal, the default is gone.
It loads the correct ruby, meaning if I do ruby -v I get the version I want, but for RVM it's not loaded and thus I have none of the gemsets.
I've also tried rvm --default use 2.0.0, rvm use 2.0.0#develop --default but same result.
I've reinstalled RVM, I've set recursively the permissions of the .rvm folder to the current user, nothing.
I'm kind of desperate at that point.

As you are using OH-MY-ZSH you might be hitting issue similar to this: https://github.com/robbyrussell/oh-my-zsh/pull/1359
RVM has a "fix" function, run:
rvm get head --auto-dotfiles
It will reorganize your dot files - it is important to read the output and follow instructions.
Make sure to use login shell for best effect.

Ah ha !! I just faced the same problem and resolved it eventually.
Let me reiterate my issue: Everytime i start my terminal, i had to first do a bundle install each time. Then i figured, Its not correct. So i tried sourcing my zshrc.
So everytime i had to do source ~/.zshrc or simply zsh also did the same and my gemset would get identified. Ofcourse assuming RVM and all other dependencies are installed correctly
Finally i figured i needed to do the following:
$ vim ~/.zlogin
The contents of the .zlogin should be
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
zsh #to initiate zsh (you could also replace this with 'source ~/.zshrc')
This resolved my problem. Now everytime i start my terminal, my defaults are all set.
Let me know if this works for you.

Related

Ruby cannot find gem in gemset

I apologize if I've missed something obvious. I am new to Ruby.
My overall goal is to add functionality to an existing script, which is using rvm and gemsets.
When I install new gems to a particular gemset, the requires in my scripts fail to find them. I am using the following rvm instance:
$ rvm current
jruby-1.6.7.2#preflight
To confirm:
$ which ruby
/Users/user/.rvm/rubies/jruby-1.6.7.2/bin/ruby
$ ruby -v
jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.8.0_11) [darwin-x86_64-java]
I specified the gemset into I install a given gem (let's say xml-simple).
$ rvm #preflight do gem install xml-simple
Successfully installed xml-simple-1.1.5
1 gem installed
To verify the gem installed correctly:
$ gem list
*** LOCAL GEMS ***
...
xml-simple (1.1.5)
...
We see the module I installed there.
Following the xml-simple instructions to include the module, I run this script:
require 'xmlsimple'
which, results in:
$ ruby testver.rb
LoadError: no such file to load -- xmlsimple
require at org/jruby/RubyKernel.java:1033
(root) at testver.rb:1
One suspicious thing I have seen is that printing out RUBY_VERSION and $LOAD_PATH shows me this:
$ ruby testver.rb
1.8.7
/Users/user/.rvm/rubies/jruby-1.6.7.2/lib/ruby/site_ruby/1.8
/Users/user/.rvm/rubies/jruby-1.6.7.2/lib/ruby/site_ruby/shared
/Users/user/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.8
.
Adding require "rubygems" is required prior to Ruby version 1.9.2, per this stackoverflow answer. This resolved my issue.

Passenger on Apache 2 Installation fails with Your RVM wrapper scripts are too old

I'm trying to install passenger on a virtual rootserver (which has multiple user accounts) but running 'passenger-install-apache2-module' results always in the following error:
Your RVM wrapper scripts are too old. Please update them first by running 'rvm get head && rvm reload && rvm repair all'.
Following this given instructions does not take any effect.
Before installing passenger, i installed RVM as multiuser / mixed mode according to https://rvm.io//rvm/install/
After that I did (using a non root-account):
rvmsudo rvm user gemsets
rvm install 1.9.3
gem install rails
gem install passenger
and lastly passenger-install-apache2-module
I searched for hours on this problem but could not find any working solution yet.
Any suggestions ? Thanks in advance!
Try to install passenger-install-apache2-module like this :
rvmsudo passenger-install-apache2-module
I just encountered this very same issue. I'm using ZSH, but switching to Bash also failed on first attempt.
My solution was to switch to Bash with the --login flag:
/bin/bash --login
Then I noticed that my RVM ruby had become unset, so I re-set using:
rvm use ruby-1.9.3 --default
Once this was done, the following worked as expected:
passenger-install-apache2-module
Rich
I have had similar issue and have taken extreme steps on my centos 6.3 system after struggling for days! In specific, I failed to install standalone phusion passenger apache2 module on gemsets other than default and global. I have taken the following steps and now, it works for me:
Login as root (I hope you know what you're dealing with)
To completely uninstall existing rvm, invoke
[root#] rvm implode
Install stable rvm, invoke
[root#] curl -L get.rvm.io | bash -s stable
run rvm shell,
[root#] source /etc/profile.d/rvm.sh
check rvm requirements, invoke
[root#] rvm requirements
and install all requirements.
Install ruby 1.9.3, invoke
[root#] rvm install 1.9.3
Install current rubygems, invoke
rvm rubygems current
Set default to ruby 1.9.3, invoke
[root#] rvm use 1.9.3 --default
Add other users who are using rvm to rvm group, invoke
[root#] usermod -a -G rvm USERNAME
If USERNAME is currently logged in, pls logout so the group add will take effect.
Make sure rvm group added, invoke
[USERNAME#] groups
Create and Switch to a new gemset on ruby 1.9.3, invoke
[USERNAME#] rvm use 1.9.3#mygemset --create
Confirm that you're on the right gemset, invoke
[USERNAME#] rvm gemset name
Install passenger gem, invoke
gem install passenger
To skip gem documentation instead, invoke
[USERNAME#] gem install passenger --no-ri --no-rdoc
or specify them in your .gemrc file
To install apache2 mod, invoke
[USERNAME#] passenger-install-apache2-module
Hope that helps!

How do I generate documentation using rvm after a reinstall?

I installed RVM as per the instructions on http://rvm.io. Here's what I've done: rvm list:
rvm rubies
=* ruby-1.9.3-p194 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Followed by a ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
And then a rvm docs generate:
Currently 'rvm docs ...' does not work with non-rvm rubies.
I then tried rvm reinstall 1.9.3 && rvm docs generate. This resulted in the rvm giving me the above error.
How do I generate docs with rvm?
you need to use ruby first:
rvm use 1.9.3
I am using the rvm binary (i.e. I did not build it from sources). See this git issue for more details. Doing a rvm reinstall 1.9.3 --disable-binary will build rvm from source and allow you to generate docs with rvm. (At least for version 1.9.3)

I can't seem to get rails installed on my Mac (10.6.5). Following Ruby on Rails Tutorial 3

I'm trying to get Rails 3 up and running by following the steps outlined in "Ruby on Rails Tutorial" by Michael Hartl (http://ruby.railstutorial.org/ruby-on-rails-tutorial-book).
The details start in section 1.2.2 (http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec:rubygems). Here you go through the following steps:
Installing Git
Installing Ruby (version 1.9.2) using Ruby Version Manager (RVM)
Creating different gemsets for environments using Ruby 1.8.7 and 1.9.2
Installing RubyGems
and finally, installing Rails.
I run the following command [sudo] gem install rails --version 3.0.7
Everything seemed to install correctly (based on no errors). However, when I type "rails -v", rails cannot be found.
I am a Rails newbie. I'm trying to install Rails on a machine running Mac OS X 10.6.7.
Thanks.
If you are using RVM you probably don't want to use sudo when installing gems. If you have Git installed only steps needed to get Rails are:
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.zshrc
# Reload your shell now (open a new terminal for example)
rvm install 1.9.2
rvm 1.9.2 --default
gem install rails --version 3.0.7
hash -r
This skips the gemsets part (you don't need it if you are just starting learning Rails) and assumes that you use Zsh (I think it's Mac OS X default, if you use Bash then you have to alter .bashrc, not .zshrc).
If you want to remove your previous installation and start over use rvm implode.

Need help setting up passenger with RVM

I'm trying to setup passenger with rvm. I keep getting this error
Your RVM wrapper scripts are too old.
Please update them first by running
'rvm update --head && rvm reload &&
rvm repair all'.
I did that still same problem
GNU C++ compiler... found at /usr/bin/g++
Curl development headers with SSL support... found
OpenSSL development headers... found
Zlib development headers... found
Ruby development headers... found
OpenSSL support for Ruby... found
RubyGems... found
Your RVM wrapper scripts are too old.
Please update them first by running 'rvm update
--head && rvm reload && rvm repair all'.
I'm using Fedora 14, Ruby 1.9.2, Rails 3.0.7
RVM is installed for multiuser
I also get this error when I do 'passenger start'
Cannot execute
'/home/antarr/.passenger/standalone/3.0.7-x86_64-ruby1.9.2-linux-gcc4.5.1-1002/support/helper-scripts/prespawn
http://0.0.0.0:3000': Permission
denied (13)
I was having the same issue but found that using the rvmsudo command worked. Instead of
sudo passenger-install-apache2-module
try using:
rvmsudo passenger-install-apache2-module
It looks like Passenger 3.0.7 is confused by newer versions of rvm, but it seems like the instructions are incorrect and it's causing trouble. If the GEM_HOME environment variable is not set you get this error.
The correct instructions should be to use your particular version first:
rvm use 1.9.2
Although I got the same error as you, after that it worked for me.
If none of the above solutions work for you and you're getting the GEM_HOME warning
delete everything in .rvmrc
rvm get head && rvm reload && rvm repair all
gem install passenger
passenger-install-apache2-module
copy/paste the end message into your apache.conf
I am still having the same issue with passenger 3.0.19 if I tried to install on gemsets other than default and global. This is soooo troublesome. I have tried many suggestions and even rvm implode, then have everything brand new. but still hitting the brick wall. my forehead almost flatten. Hope not to lose my head!
Luckily, I found myself a fix. I found out that in i am in rvm multiuser envrioment and the issue arised if I switch to user gemset using command: "rvm user gemsets" which basically will create and use .rvm folder in user's home folder. e.g.: /home/.rvm instead of /ur/local/rvm folder. Since I do not know how to switch back and could not find any documention on how to, I did the following steps:
remove .rvm folder in the user home folder,
rm -rf ~username/.rvm
added back the user to rvm group (in multi enviroment, every new user need to be added to rvm group)
sudo usermod -a -G rvm username
re-login.
Now, as long as I am using shared rvm gemset folder, phusion passenger wont complaint.
Hope that helps someone.
I fixed the Permission Denied issue with:
chmod a+x /Users/tvd/.passenger/standalone/3.0.7-x86_64-ruby1.9.2-macosx-10.6/support/helper-scripts/*
Found it in comment section on the phusion.nl blog:
Goto Comment on Phusion Blog