Ruby Installation on Mac OSX fails - please help! - ruby-on-rails

I am extremely frustrated with ruby on Mac OS X. I have tried RVM and regular installations of ruby, and nothing seems to get it to work well. With RVM, rails throws errors at me, and with a regular installation of ruby 1.9.2-p180, somehow my computer reverts back to ruby 1.8.7 over time. Can someone please help? A detailed instruction on how to just reset my ruby installation from a clean slate would be very helpful.
Thanks so much in advance!

I'm using macports for all my needs:
go to www.macports.org
download installation dmg
install it
open a new Terminal windows (or source ~/.profile )
port selfupdate
port search ruby
pick what one want (ruby for 1.8.7, or ruby19 for 1.9.2)
sudo port install ruby
port search rb-
pick what want and install
everything will install into /opt - so does not interfere with your standard system binaries.
Note, than everything will compile - and take a long time.

rvm --default use 1.9.2
This has been covered multiple times here. A simple search will find many questions.
See:
Installing RVM (Ruby Version Manager)
and
i installed ruby 1.9.2 with RVM, but when i type "ruby -v" is telling me the ruby v i have is 1.8.7 (mac)

Related

After Setting Up Ruby Installer What Command line tools do you use?

I've installed Ruby on a Windows computer
After Setting Up Ruby Installer What Command line tools do you use?
http://railsinstaller.org/en
I've tried the command
rvm use 1.9.3
using the command prompt ruby and rails
I get the error message
rvm is not a recognised command
From RVM’s FAQ:
Does RVM work on windows? Will it in the future?
NO. If you would like to manage multiple versions of ruby on windows please use pik which is an excellent tool by Gordon Thiesfeld. You can find it on GitHub. There are plans to include windows support in RVM 2.0.
https://rvm.io/support/faq#does-rvm-work-on-windows-will-it-in-the-future
Doing Rails development on Windows is a little bit more of a challenge and you may run into some annoyances, but it's definitely possible.
Uru worked well for me as a nice alternative to RVM, which doesn't run on Windows. However, if you just want to have one version of Ruby installed on your computer and work with it, you don't even need to bother with Uru.
Windows is not the best environment to develop with Ruby ...
RVM doesn't work and PIK hasn't updated for more than 2 years..
Github of Pik
This installer doesn't install RVM. It installs Ruby interpreter and Rails.
Since you've installed it, I assume you have your Ruby and libraries for it (called gems) rails and bundler. Execute gem list in your shell to verify (it should output a looong list).
Then you should create a new Rails project:
rails new project_name
...and then go into the folder that got created
cd project_name
bundle what you have:
bundle install
...and launch the server to see if it works:
rails server
or
rails s
You will likely run into issues with tzinfo gem if you're on 64-bit Windows, but that can be easily fixed by searching around StackOverflow, it's been discussed.
Gool luck to you. Developing Rails applications in Windows proved to be hard to me. Consider launching a virtual machine (using, for example, VirtualBox) with Linux aboard. That's what you could do in Linux:
install RVM as the site suggests:
curl -sSL https://get.rvm.io | bash -s stable
install the latest MRI available - feel free to replace ruby with the version you need, like rvm install 2.0.0
rvm install ruby
select and set as default the Ruby you need, you've tried a similar line apparently with Ruby 1.9.3
rvm --default use ruby
another long process
gem install rails
rails new project_name
(same as described above)
cd project_name
bundle install
rails s
That should work, and that's what you've probably seen. Again, I highly recommend using Linux in VirtualBox (or anything similar) for Rails development. A native Linux installation could only be a better environment, but most people are not ready for this just yet.

Ruby version did not get updated to 1.9.x

I installed ruby as per instructions given here but when I do ruby--version then it still shows 1.8.7. How do I make sure I use newly installed Ruby?
I would suggest you to use RVM (Ruby Version Manager). You may find a full installation guide here:
http://ryanbigg.com/2011/06/mac-os-x-ruby-rvm-rails-and-you/
If you get an error such as "ERROR: Error running ' ./configure...." after executing rvm install e.g.
rvm install 1.9.3
Then you may try to install it like this:
rvm install 1.9.3 --with-gcc=clang
Note: in the guide this possible error is not described
Did you properly setup your PATH? What's the output of echo $PATH? /usr/local/bin has to come first they way this tutorial sets up things. You see that everything worked right when which ruby displays /usr/local/bin/ruby.
Personally I'd recommend using a tool for managing Ruby versions though. RVM still seems to be the most popular choice, I prefer the combination of rbenv and ruby-build.

vim 7.3 compiled with ruby 1.8 while running in rvm with ruby 1.9.2

I am running my rails 3 project under ruby 1.9.2 with rvm. I use vim through zsh which was compiled using ruby 1.8 (the system ruby that comes with mac osx).
What's the best way to get these two ruby versions to match up?
Option 1: I can have rvm use ruby 1.8 but I don't want to be "stuck" on 1.8. Plus my 'bundle exec rails' commands don't seem to work with this option.
Option 2: Compile vim with ruby 1.9.2. But will this work ok?
I know using macvim compiled with 1.9.2 is an option but I really prefer the terminal vim.
You would try one of these:
You can use MacVim in Terminal. Just alias vim='mvim -v' if you already have mvim in your $PATH. I use this method personally, and I think it's the easiest way.
Compile vim yourself, with --with-ruby-command=[PATH TO YOUR RUBY 1.9.2] configuration option. I have not tried it on Mac OS; However in Ubuntu Linux I did --with-ruby-command=/usr/bin/ruby1.9.2 and it worked.
FYI: In Ubuntu they keep every program with version number separated and use update-alternatives to switch the default. The /usr/bin/ruby is just a symlink to the default one.
Rather than recompile vim, the easier solution is to change the /usr/bin/ruby symlink to point to your desired version of ruby. I use RVM / mac OSX leopard, and this worked for me.

RoR - RubyGems not installing?

trying to install bcrypt-ruby-2.1.4. I have to use rvm to remove ruby 1.9.2, then reinstall/compile, then I can install the bcrypt gem, however the gem is only active in that one terminal session. If I open another tab in terminal I get the following error "Could not find bcrypt-ruby-2.1.4 in any of the sources"
If I close the terminal, I will no longer be able to use the bcrypt gem (or json, or cucumber) unless I remove and recompile ruby again?
Not sure how to even google for help on this? Any ideas or help would be greatly appreciated.
Bobby
running osx 10.6.8
ruby 1.9.2-p180
You're probably using a different rvm set when you're opening a new terminal.
Since OS X doesn't come with Ruby 1.9.2, you are being defaulted to the system installation of Ruby.
http://beginrescueend.com/rubies/default/ Check out this link to learn how to set a default Ruby version.
Go to your terminal and type in
rvm --default use 1.9.2
This will make 1.9.2 the default Ruby in all Terminal windows.

ruby 1.9 and 1.8.7 installed how do I make app use 1.8.7

I have two version of ruby installed 1.9 and 1.8.7(via macports) how do I make my app run with 1.8.7?
And How can i uninstall 1.9?
TIA
Firstly: switch to rvm it's excellent for ruby management
If you don't want to then I believe you can remove the ruby package with (if installed with macports) with the following:
sudo port uninstall ruby19
To start using the new version of ruby you need to find where it is installed (it's something like /opt/local/<...>)
Then go to the Binary folder and add it to path.
export PATH=/opt/local/<...>:$PATH
Removing the old one, you might need to change some env variables as well.
Use RVM
EDIT: added sudo to port command and changed standard location

Resources