How do I make Octopress use the system version of Ruby? - ruby

I am trying to setup Octopress on my Mac. The default version of Ruby on my Mac was 1.8.7 but I have upgraded it to 2.0.0.
If I do:
which ruby
it prints:
/Users/liqiushi/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
After cloning my existed sources from github and 'cd'ing into that folder, I got the following error:
You are using '.rvmrc', it requires trusting, it is slower and it is
not compatible with other ruby managers, you can switch to
'.ruby-version' using 'rvm rvmrc to [.]ruby-version' or ignore this
warning with 'rvm rvmrc warning ignore
/Users/liqiushi/Documents/photosynthesiis.github.com/.rvmrc', '.rvmrc'
will continue to be the default project file in RVM 1 and RVM 2, to
ignore the warning for all files run 'rvm rvmrc warning ignore
all.rvmrcs
ruby-1.9.3-p448 is not installed.
To install do: 'rvm install ruby-1.9.3-p448'
If I do:
ruby -v
in the Octopress folder it prints:
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
And, if I do:
which ruby
It prints:
/usr/bin/ruby
Can anyone tell how to make Octopress use the Ruby I just upgraded in my Mac instead of using 1.8.7?

Octopress is using your system ruby, ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0].
You're using RVM, the ruby-2.0.0-p247 is a ruby you've installed. The repository has an .rvmrc file saying it wants ruby-1.9.3-p448. Try installing it, or change what the .rvmrc wants.
edit: The error message tells you what to do:
ruby-1.9.3-p448 is not installed.
To install do: 'rvm install ruby-1.9.3-p448'

RVM has a "default" Ruby that, immediately after installation, you should have set using:
rvm use 2.0.0 --default
See RVM's rvm help use command and "Setting the default Ruby" for more information. That covers the cases where you don't have a .rvmrc file in the directory.
For directories where it exists, you can remove the file:
rm ./.rvmrc
Or edit it to contain the information for the version you do want RVM to use when you cd into the directory. See RVM's "RVM Best Practices" for good tips on dealing with RVM in general and the tip of the discussion about using .rvmrc files. RVM's "rvmrc" capability is pretty nice. The previous link 'splains it nicely and details settings you can adjust to make your life a lot easier.
In that page you'd find:
As of RVM 1.8.0, after a survey where greater than 80% of respondants wanted the feature on by default, automatic loading of project .rvmrc files is opt-out by default (therefore on). In order to disable this feature, set the following value in either /etc/rvmrc or ~/.rvmrc:
rvm_project_rvmrc=0

Related

installing RubyGem on CentOs 5

My ultimate goal is to install Sass.
To do this I need to install RubyGems
To do this I need to install Ruby.
I installed Ruby with yum.
I then tried to install gem with yum yum install rubygem
The response is "nothing to do" and yet when I write gem install sass I get:
gem: command not found
I decided to try to install rubygems 2.2.2 manually. After downloading it, I tried to run ruby setup.rb and in response I get:
Rubygems now requires Ruby 1.8.7 or later
But yum does not seem to be able to install anything later than 1.8.5.
So now I'm trying to do this manually.
I downloaded Ruby 1.9.2 to my home directory and followed these instructions: http://howboring.com/post/1226760251/centos-5-and-rails-3-and-ruby-1-9-2
This seems to work, but the problem is ruby1.9.2 is installed in my home directory (i.e. ~/ruby1.9.3 not system wide.
Thus in the directory where I installed ruby 1.9.2 ruby -v still gives 1.8.5 but ./ruby -v returns 1.9.2. And which ruby returns /usr/bin/ruby (I suppose I could replace this with a symlink that points to ~/ruby1.9.2/ruby but this doesn't seem like a "best practice")
So my main question is where should install ruby 1.9.2 with Root Permissions so that 1.8.5 is replaced with 1.9.2 system wide.
My corollary question is: is there any easier way to do this? (perhaps install sass without install rubygems??)
I then tried to install gem with yum yum install rubygem
You have a typo in the package name, it is actually named rubygems.
Can i suggest Wayne Seguins excellent rvm (ruby version manager). As the home page states:
"RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems".
Site has comprehensive installation instructions. I've posted a truncated Set of instructions for installing on POSIX systems below, but please refer to the projects' home page as:
"we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods."
Install RVM (development version):
\curl -sSL https://get.rvm.io | bash
Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command:
user$ source ~/.rvm/scripts/rvm
test the installation was successful:
user$ type rvm | head -n 1
this should output "rvm is a function"
List all known rubies:
rvm list known //this will output a large list of rubies shortened here
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1[.1]
[ruby-]2.1-head
ruby-head
...
install the version you want:
rvm install 1.9.2
You can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby:
rvm use 2.1 --default
You can also temporarily use another version of your ruby versions
rvm list known //lists system available rubies
Choose to use another ruby
rvm use 1.9.3
RVM is a great tool, well documented, and actively developed, it handles a wider scope of functionality than i can list here, and it's a tool I use everyday.
You can use rbenv to install ruby and rubygems that you need
https://gist.github.com/jpfuentes2/2002954

How do I associate a new rvm install with existing ruby versions?

I was having a problem with RVM, so I uninstalled and re-installed it.
The truth is I actually tried rbenv, but that didn't work out for me so I am trying to get rvm up and running again - without having to install duplicate versions of Ruby.
I have at least 1 existing version of Ruby installed:
ruby --version
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
But when I do rvm list I get a blank list:
bash-3.2$ rvm list
rvm rubies
# Default ruby not set. Try 'rvm alias create default <ruby>'.
# => - current
# =* - current && default
# * - default
So my question has two parts:
How do I see all the versions of Ruby on my system (given that rvm is not showing me any)?
How do I associate the new RVM install with the existing versions of Ruby?
Or am I better off removing all existing versions of Ruby and re-installing everything? That seems like a pain in the ass though.
You can add an existing ruby to rvm using:
rvm mount /path/to/ruby
or:
rvm automount
but be careful as ruby installed in system might have hardcoded paths for gems - so gemsets would not work with it.
There is also new way of adding binary rubies (already compiled), for list of available builds for your platform run:
rvm list remote
and you can install those rubies using:
rvm mount -r 1.9.3
This might be default way of installing ruby to avoid compilation in next stable release of RVM - but it will work only for ruby 1.9.3+.
You don't want to associate RVM with an existing Ruby, you just want to install a new Ruby.
You don't want to remove the system Ruby, either; OS X depends on it.
Install a new 1.8.7 under rvm, this way you can associate your own gemsets with it. Let OS X manage the default system Ruby, you just ignore it and use your own, managed solely by rvm.
(If you decide to go the rvm route.)

rvm does not set ruby version

i am new to linux. i have kubuntu 11.10 , i have installed ruby 1.9.2 and only after this i have installed rvm. after this i made
rvm install 1.9.2
and
rvm install 1.8.7
and when i use
rvm use 1.8.7
ruby -v
it writes
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
i tryed to use another versions but it writes same anyway, so i think that rvm dont have priority to choose ruby version. how to solve this problem? It's cause i have installed ruby and only after this i have installed rvm?
looking at the output of your rvm list, you have two rubies installed, none of them default.
Looks like you just missed the step to make 1.9.2 the default.
And it seems you didn't modify your .bash_profile file
See Step 3 on this page:
http://beginrescueend.com/rvm/install/
Your file ~/.bash_profile should contain this line:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
(make sure to start a new shell, after modifying .bash_profile)
Then run this: (to set the default Ruby version)
rvm --default use 1.9.2
ruby -v
See also:
http://beginrescueend.com/rubies/default/
First you should establish if rvm is installed correctly, you can determine that by entering type rvm | head -1 in your terminal. If you get the response rvm is a function then rvm is installed correctly.
If it's an installation problem carefully go back over each step, if you still can't figure out what's wrong I highly recommend visiting the #rvm channel on freenode (irc). The creator and other knowledgeable rvmers are almost always available, friendly and willing to help you troubleshoot. If you end up using ruby extensively, you're going to start needing more of the functionality rvm offers (gemsets, etc.) and #rvm can be a great resource when you get tripped up.

Make RVM ignore ruby patch level

Currently, my rvm based projects specify rvm 1.8.7#gemset in .rvmrc. This means that when I am installing the gemset of a new project, it will default to the latest patch level of 1.8.7, eg. ruby-1.8.7-p352 . Now I don't want to hard code '1.8.7-p352' in the rvmrc as other developers(or other projects) might have some other patch levels installed on their machine(from other projects) and also I don't want to install different patch levels of ruby on my machine.
Is there a way to make rvm ignore the patch level and just make it use any version of 1.8.7 installed - so that I can use one patchlevel of Ruby 1.8.7 across all projects.
The thing you want to set up is called an rvm alias. See: http://rvm.io/rubies/alias
For your example the commands would be:
rvm alias create 1.8.7 ruby-1.8.7-p352

Install Rails 3 on OSX with RVM

Trying to install the new Rails 3 release on OSX 10.6.
Have never touched Ruby or Rails on this machine since purchased.
I was able to get rvm and get Ruby 1.9.2. installed. From there, I am stuck.
I tried:
rvmsudo gem install rails -v 3.0.0
sudo gem install rails --pre
sudo gem install rails
sudo gem update rails
And I get the same result error each time:
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - /Users/kevin/.rvm/gems/ruby-1.9.2-head#rails3/cache/activesupport-3.0.0.gem
If I do gem list, it says LOCAL GEMS and doesn't list anything.
I have read a few walkthroughs but honestly none of them address this issue and its kind of pissing me off. Why is this so difficult to install? Would love to learn it if someone could help me get it running.
I was trying to follow this:
http://eddorre.com/posts/installing-rails-3-beta-4-using-rvm
and this:
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard
Which is actually linked from the ROR guides website. Am I missing dependencies? How do I get them in?
If I do rails -v I get:
rails -v
/Library/Ruby/Site/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:214:in `activate'
from /Library/Ruby/Site/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
Older versions of rvm had a bug that can cause your ruby versions to get crosswired because the OS can cache executable paths for the which command (particularly if you are using zsh). See this long, detailed, mind blowing post by Yehuda Katz on the subject.
What I had to do this morning:
rvm update && rvm reload # update rvm
rvm gemset delete rails3 # delete old gemset
rvm install 1.9.2
rvm use 1.9.2
rvm gemset create rails3
rvm use 1.9.2#rails3
which ruby # check to be sure the ruby interpretter is properly set to 1.9.2
hash -r # if ruby interpretter is not pointing to 1.9.2
gem install rails
which rails # check to be sure we are using rvm version of rails
Note: On newer versions of rvm, you will have to use rvm get stable instead of rvm update
You don't need to use sudo when installing gems with rvm. If you follow the directions here to get RVM installed, you should be able to just do rvm use 1.9.2; gem install rails --version 3.0.0.
You don't have to specify version 3. If you have 1.9.2-p0, it will automatically get rails 3 when you rvm gem install rails 3. note: no sudo. I think when you use sudo it makes it use the system-installed ruby. If you think you need sudo, use rvmsudo.
Things probably got messy because you were following guides based on the pre-stable release of rails, which involved many other things. If you like, you can try uninstalling rvm and re-doing everything. It really isn't all that difficult.
Remember, you need 1.9.2, 1.9.1 won't work.
curl -O http://rvm.beginrescueend.com/releases/rvm-install-head
sh rvm-install-head
rvm install 1.9.2-p0
# also remember to edit your bash profile and add the required lines
# verify that 1.9.2-p0 shows up there
rvm list
# makes it so you're using it, and sets it as the default
rvm use 1.9.2-p0 --default
# verify this happened. should have => 1.9.2-p0 in the list
rvm list
# verify the version
ruby --version
# should automatically get 3.0
# `rvm gem install` installs it for every single installed ruby version
# in my experience
gem install rails
When you did rvm gem install, I think it installs it for every ruby version you have registered with rvm (at least it happened in my experience), so my assumption is that it was trying to force install rails 3 for an older ruby installation, which was missing the required gems.
Take it easy, not many commands are required. If you find yourself having to do 'hacks' or workarounds, then you're doing it wrong. Thankfully it's easy to start over. To remove rvm, just do rm -rfv ~/.rvm and also rm ~/.rvmrc if it's there.
Let me know how it goes.
working through this myself as new user mac osx blah blah
seems like a cache directory doesn't get made, try
mkdir $HOME/.rvm/gems/cache
so far so good after that...
I am running into the same problem (tried uninstalling and installing like Blaenk suggested)
rvm -v
rvm 1.0.2 by Wayne E. Seguin (wayneeseguin#gmail.com) [http://rvm.beginrescueend.com/]
ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
gem install rails
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - /Users/pragnesh/.rvm/gems/ruby-1.9.2-p0/cache/activesupport-3.0.0.gem
After doing "rvm update && rvm reload" rvm got updated to 1.04 (instead of 1.02 which I got via the recommended GIT install yesterday!?) it worked nicely.
The solution worked for me, with a few tweeks:
Instead of using rvm update, I had to use rvm rubygems. Then, after doing all the work from post 2, I had to execute bundle install and I entered rvm use 1.9.2#rails3 to my .rvmrc file. Everything now works like a charm, even when starting a new shell or terminal session. The full list of commands I used is:
>> NEW >> rvm rubygems
rvm reload # update rvm
rvm gemset delete rails3 # delete old gemset
rvm install 1.9.2
rvm use 1.9.2
rvm gemset create rails3
rvm use 1.9.2#rails3
which ruby # check to be sure the ruby interpretter is properly set to 1.9.2
>> DID NOT NEED >> hash -r # if ruby interpretter is not pointing to 1.9.2
gem install rails
which rails # check to be sure we are using rvm version of rails
>> NEW >> bundle install
>> NEW >> cat 'rvm use 1.9.2#rails3' > .rvmrc
Followed these instructions, and found them very useful for rvm installation. Hope they work for you.
http://adventuresincoding.com/2010/01/taking-the-helm-of-ruby-with-ruby-version-manager/
Doing this after the rvm update and reload worked for me:
rm -rf .bundle && bundle install

Resources