Rails 3 on Fedora issues - ruby

I have been trying to get Rails 3 installed in Fedora, it requires Ruby to be 1.8.7 or 1.9.2. Fedora official yum repos have Ruby 1.8.6 which is of no use. So I decided to compile it myself from the source, downloaded the source, compiled it and installed it successfully.
But this weird thing happens after the install, sudo gem or sudo ruby are not working, it just returns saying command not found.
which ruby
/usr/local/bin/ruby
ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
sudo ruby
sudo: ruby: command not found
sudo echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
Am I missing something, why doesnt it find ruby when its in the PATH?

check your PATH variable (set in your .bash_profile or .bashrc file, add /usr/local/bin to the front of the PATH:
PATH=/usr/local/bin:$PATH
I'd recommend that you check out RVM -- so far the best way to install and switch between different Ruby versions and to maintain Gems independently for each version!
https://rvm.io
Using RVM is much easier than compiling by hand, and it keeps all your Gems organized by Ruby version!
There's also a RailsCast on it: http://railscasts.com/episodes/200-rails-3-beta-and-rvm

Related

Can't find ruby or gem commands after doing ruby-install in Ubuntu

I have installed ruby 1.9.3 in my Ubuntu 12.04 machine following the instructions in https://github.com/postmodern/ruby-install and executing the following command:
sudo ruby-install ruby 1.9.3
I was assuming this would link from my /usr/bin or somewhere else visible from my path ruby or gem, but it doesn't. When I try for example: gem install bundler, I get:
sudo: gem: command not found
It also can't find ruby when I try ruby -v.
If I install with sudo apt-get install ruby1.9.3, I'm able to execute both ruby and gem:
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ gem -v
1.8.11
I was expecting from ruby-install the same output I got from apt-get. Am I looking in the wrong place? How do I run ruby and gem after installing with ruby-install?
I know there are other installers for ruby like rvm and rbenv, but I'm following some installations instructions and they clearly instruct to use ruby-install.
Thanks in advance!
OK, found the answer.
After running
sudo ruby-install ruby 1.9.3
the last line from the log is:
>>> Successfully installed ruby 1.9.3-p547 into /opt/rubies/ruby-1.9.3-p547
Which I have no excuse for not paying attention to since it's in bold colourfull letters.
Erm, anyway, adding /opt/rubies/ruby-1.9.3-p547 to the PATH makes ruby and gem work.
export PATH=$PATH:/opt/rubies/ruby-1.9.3-p547/bin

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

two versions of ruby installed, how to fix that?

I found out that I have two versions of ruby installed on OSX 10.6.2 how can I uninstall the older version and make sure that everything is fine, the path point to the other one?
bash-3.2$ /usr/local/bin/ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]
bash-3.2$ /usr/bin/ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
bash-3.2$ $PATH
bash: /usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec: No such file or directory
bash-3.2$ whereis ruby
/usr/bin/ruby
The version of Ruby in /usr/bin is the system-installed version, and should be left in place.
The version you have in /usr/local/bin can probably be safely removed. Was it installed using a package manager (ie, MacPorts, Homebrew?). If so, remove it using your package manager.
If you compiled and installed it manually, you can try removing the binaries from /usr/local/bin, but you may still have gems and other files lying around (most likely in /usr/local/lib/ruby.)
Alternatively, you can leave them in place and manage your Ruby environment through RVM: http://rvm.beginrescueend.com/
You should locate the Ruby you're actively using with which ruby, not whereis ruby. My whereis ruby outputs /usr/bin/ruby, but which ruby gives /Users/BinaryMuse/.rvm/rubies/ruby-1.9.2-p136/bin/ruby, because I manage my Ruby versions with RVM. Since /usr/local/bin is first in your PATH, which ruby will probably return /usr/local/bin/ruby, which appears to be what you want. A quick ruby -v can confirm this too.
All that being said, I second the recommendation of using RVM to manage version of Ruby and also what RVM calls gemsets, allowing you to have "buckets" of gems that you can use one at a time. It's quite a powerful and extremely useful tool.
You don't have to uninstall the the older version. ALternatively you can use alias like and save it in the ~/.profile file of your the OSX directory.
alias ruby="<path_to_ruby_version_that_you_want_to_use>"
That should call ruby from the proper directory that you want.
Alternatively you can use symlink like this post suggests here How to uninstall Ruby from /usr/local?. Hope it helps!

Ubuntu | Ruby - Can't Remove Ruby 1.9.2 from system

I'm new to ubuntu, and might have had a couple of
false starts updating ruby / rails. I'm trying
to start clean by removing all versions of every
thing ruby from my system
I think I've installed everything through either
Synaptic, or aptitude purge, but I can still do the
following:
jwally#jwally-laptop:~$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
jwally#jwally-laptop:~$ gem -v
1.3.7
jwally#jwally-laptop:~$ irb
irb(main):001:0> RUBY_VERSION
=> "1.9.2"
but when I type "dpkg -l | grep ruby,
I only get the following:
rc ruby1.8-elisp 1.8.7.249-2 ruby-mode for Emacsen
thanks in advance
You may have installed an instance of Ruby without using Ubuntu's package system. Try:
which ruby
If this yields something other than /usr/bin/ruby (such as /usr/local/bin/ruby), then this is the case. Ubuntu can't uninstall locally installed stuff. You need to do that manually.
To see which package ruby is owned by run:
dpkg -S `which ruby`
If it can't find the package, then Ruby was installed outside of the Ubuntu package manager. You'll have to remove it manually.
I'll once again recommend this blog post for instructions on the best way to install Ruby on Ubuntu: Ubuntu, Ruby, RVM, Rails, and You.

how to change ruby path from /usr/bin/ruby to /usr/local/bin/ruby

reading around the various ruby install tutorials it's required to change path from /usr/bin/ruby to /usr/local/bin/ruby but i cant seem to be able to do it. Ultimately i want to install Ruby 1.9.2, should i uninstall 1.8.7 or what? i tried to install Ruby 1.9.2 with macports, the installation seemed to go ok, but i cant find the new version, i seem to be stuck with 1.8.7
iMac:~ rebel$ which ruby
/usr/bin/ruby
rebel$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
.profile
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
From your shell I notice you are on a Mac. If that's true, I recommend you to have a look to Homebrew. Then follow the instructions and install RVM for Ruby. With RVM you don't need to uninstall ruby, you can have several versions encapsulated in their own directory. You simply switch from one version to another according to your needs.
For example you can have ruby 1.9.2 with rails 3.0.1 in one setup and in another one you can have ruby 1.8.7 with rails 2.3.8...
In Mac, Homebrew with RVM is the easiest way...
Homebrew installation:
https://github.com/mxcl/homebrew/wiki/installation
Here is a nice screencast with RVM:
http://railscasts.com/episodes/200-rails-3-beta-and-rvm

Resources