I just installed Rails on OSX. I used the stock version of Ruby and followed the following procedure:
Installed newest version of RubyGems
Ran sudo gem install rails --include-dependencies
Installed Mongrel using sudo gem install mongrel --include-dependencies
Rails is working just fine, but more reading led me to this setup guide:
http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx
This is essentially the exact same install I performed, except he compiles it from source code and installs to /usr/local -- I really like this idea, since it keeps the OSX install stock and confines all my dev stuff to one area.
So, assuming I want to follow these instructions, what do I need to do to revert my system back to "stock" ruby? Can I just uninstall the Rails and Mongrel gems? Will the upgraded RubyGems cause any issues?
Basically, my concern is that some other software unrelated to my development work will need to use OSX's stock Ruby, and I will have screwed it up somehow. Any advice to undo the 3 steps I listed above and get as close to stock as possible would be appreciated.
Thanks!
The article you are referring to is over three years old (which is outdated in the Rails community). My recommendation is:
Install XCode
Install Homebrew
Install MySQL, Postgres, Image Magick, etc. (brew install mysql, etc.)
Install RVM
Install Ruby 1.9.2 (rvm install 1.9.2)
Switch to default (rvm 1.9.2 --default)
Install Rails (gem install rails)
Install Passenger (gem install passenger)
Each step will have a few more substeps but you should be able to look them up or be promted with them.
I can't remember why I did this but I do know that it worked and has caused no problems since. I moved /Library/Ruby to /Library/Ruby.broken and then installed Ruby from source into /usr/local.
There's something fundamentally missing with the stock Ruby in OSX. I wish I could remember what that was.
Related
I recently started learning Rails using Ruby 1.9.3p385, and I'm trying to develop a small project with it.
I'm using Linux so I installed Ruby using RVM.
I developed a few pages, following some tutorials. I would like to upgrade my project to use Ruby 2.0.0. What do I have to do?
I installed Ruby 2.0.0 with RVM:
rvm install 2.0.0
Everything seems OK, so I tried to use it:
rvm use 2.0.0-p247
But when I try to run my Rails server using rails server, I get the following message:
bash: rails : command not found
I've read the RVM documentation about upgrading Ruby but I don't really understand what it does; I'm afraid of breaking everything.
Does it will upgrade my project in a way it will use Ruby 2.0.0 or what should I do?
Next, I will want to upgrade also to Rails v4.
Your gemset which comes with new Ruby version is empty. Try this:
gem install bundler # this will install bundler
bundle # this will use bundler to install required gems
rails server
Did you run rvm use 2.0.0-p247 or did you use rvm use 2.0.0-p247 --default? The later will set Ruby v.2.0 as the default for your system. Failure to do that will revert your Ruby to whatever RVM's default is the next time you log into your system or open a new terminal window.
When RVM installs a new version of Ruby, it installs only the default gems. It CAN upgrade a Ruby to another version, and optionally install the existing gems as it does so, but that's not what you asked it to do: rvm install 2.0.0 only installs Ruby. At that point you have to install the other gems you need, which would include Rails.
My general practice when installing various versions of Ruby and the gems I like is to use two command-line pipes to dump my existing gems, then (re)install them. First I switch to an existing Ruby whose gems I want to duplicate, then run:
gem list | cut -f1 -d' ' > ~/gem_list
Then I switch to the newly installed one, and run this:
xargs gem install < ~/gem_list
This does a completely clean install of the gems, outside of RVM's commands.
Why? Habit. Paranoia based on some "experiences" I had in the past with RVM.
Once that's all done and I have brand-spanking-new Ruby and gems, I'll proceed with running bundler or other housekeeping chores.
when you install a new ruby version, you have to reinstall all the gems for that version. start of by installing bundler first. Then run bundle in your rails root directory. When you encounter no errors, you're good to start the rails server. Good luck!
run bundle install on the application root, you need to reinstall all your dependencies for the new version of Ruby.
I am following a tutorial about Ruby on Rails, and the tutorial got updated to a new version of Rails, so I can't follow it anymore because I have an older version.
I would like to start new and uninstall Ruby on Rails and any related software on my Mac OS X 10.5.8, and follow it from ground up. If anyone would be willing to help me uninstall Ruby and Ruby on Rails, it would be much appreciated.
Download RVM or RBENV and upgrade to the latest Ruby (2.3.0 at this point). Don't touch your system Ruby.
Are you uninstalling Ruby on Rails, or Ruby AND Ruby on Rails?
If you want to uninstall Ruby on Rails it should be a simple matter of using gem uninstall rails or doing gem dependency rails and then gem uninstall for each of the listed gems that Rails depends on. If you installed them system-wide, using sudo originally, you'll have to use sudo again to uninstall them.
If you want to uninstall a system-wide Ruby you installed from source, well, I'd probably leave it alone and install any new versions of Ruby using RVM. The older version won't be visible to apps unless you want them to see it or set your path to include it. RVM's version will be found first unless you do rvm system.
Actually you could simply install RVM and have it install your new versions of Ruby, then from there install new versions of Rails, without even bothering to uninstall the old stuff. RVM really is that cool.
I am trying to get a Ruby on Rails app hosted free somewhere, and Heroku is looking like my last resource. It is supposed to work on Linux, and the gem installs with no errors, but whenever I run any Heroku command it spits out several errors, all connected, and talking about a failed 'require.' I looked it up in the code, and it says:
require 'readline'
That is it.
I have tried to install every variation of libreadline that I can find and think of, but none of it makes any difference. Any ideas here?
It could be that your system installed version of Ruby is not build with readline support. If so then you could reinstall it from source and select the correct configure parameters for readline support. That's not only annoying but means you'd have to manually maintain updates yourself.
Better still would be to abandon your system Ruby altogether in favor of one installed with RVM
Install RVM as described here
Install libreadline-dev
$ sudo apt-get install libreadline-dev
Install a version of ruby (e.g. 1.8.7)
$ rvm install 1.8.7
$ rvm --default 1.8.7
Install your rails and Heroku gems under the RVM ruby
$ gem install rails heroku taps ... # Note no sudo!
See if your problem persists
If so, then do this:
$ cd ~/.rvm/src/ruby-1.8.7-p299/ext/readline
$ ruby extconf.rb
$ make
$ make install
Ubuntu's ruby-full package depends on libreadline-ruby and should pull in everything both you and it needs. If you have tried installing ruby by installing a bunch of separate packages you might be missing something. If that's the case go back and install ruby-full.
I have a script I use to rebuild my Rails Environment whenever I install the latest Ubuntu. It installs everything you need for Heroku (which is where I host my apps) as well. You might want to take a peek at it and see if there is anything there that you are missing.
If ruby-full doesn't sort you out, I would second Bjg's advice and ditch the system ruby for RVM.
I got it to work, but it was rather a hack. I hunted down the readline.so file from where it was installed (in some strange spot) and did a hard link to where ruby was looking for readline, and it worked. Not optimum, and I will definitely try what you guys recommend next time. Thanks!
I've just gone to installed RoR on my snow leopard mac.. and found the rails gem was already installed..
is this normal? Does it need updating?
Does this get installed along with textmate?
It is installed with the Snow Leopard developer tools. Version 1.8.7 of Ruby is installed.
You should be fine for most your development needs. If you wish to upgrade just update the gems:
$ sudo gem install rubygems-update
$ sudo update_rubygems
$ sudo gem update
$ sudo gem update --system
$ sudo gem install rails
I found an incredibly well written install guide at The Pragmatic Studio called Installing Ruby 1.9 and Rails 3 on Mac OS X. It took about an hour to follow, including installing several prerequisites.
I'm hesitant to mess too much with OSX's native installation of ruby/rails, lest things get broken by an Apple system update, so I was very excited to learn about RVM (Ruby Version Manager) which is a cool tool for switching between different ruby/rails installations. The Pragmatic Studio tutorial walks you through installing rvm.
There are a few glitches with the guide, which I'll list here:
Git: I just installed git itself. You do not need to set up a github account.
Git: You may need to manually add /usr/local/git/bin to your PATH. (They don't explicitly tell you to)
RVM: The protocol for the rvm-install-head URL should be https, not http
RVM: The installer complained a lot, but it worked anyway.
RVM: The newly installed ruby 1.9.2 didn't activate until I ran 'rvm 1.9.2' in step 8
All told, this seems like a GREAT approach, and I'm really impressed with their install guide!
Yes, the rails gem is already installed along with Snow Leopard, because you installed developer tools, it's very normal.
But it's a little bit old, you need to update it.
TextMate did not bundle any RoR stuff with this. TextMate just included a lot of bundles which mainly consists of Python and Ruby scripts, if you do not have ruby, textmate will not work.
However, TextMate is originally made on Tiger 10.4, which bundled Ruby 1.8.2, and Snow Leopard bundled Ruby 1.8.7, so TextMate's bundles is not fully compatible with Snow Leopard
Refer to this and get some fix for these issues:
http://wiki.macromates.com/Troubleshooting/SnowLeopard
And also make sure you always keep your RoR bundle to the latest SVN is also a good habit
TextMate is just a text editor. It only understands Rails syntax and file structure making it easy to write Rails apps. That said, you still need to install Rails separately to create Rails apps.
well for me it worked this... I have mountain lion but it worked just fine...
I'm new to Ruby on Rails, and I'm in the process of setting it up on my OS X system. Most guides seem to recommend using MacPorts to install Ruby and RubyGems, then using RubyGems from there on to install gems. I've noticed that MacPorts also offers many gems (though they're missing some and others seem a few releases behind), and I'm worried that it will somehow conflict with the stuff I'm installing using RubyGems.
Does anyone have any experience working with this kind of setup? Any advice? I want to get this right the first time so I don't end up having things break later on.
Thanks,
Grant
I recommend using Macports to install Ruby, and then download and installing the latest version of Rubygems by following the instructions on http://rubyonrails.org/down. When you want to install a new gem, use Rubygems, not MacPorts.
I use MacPorts to install Ruby and RubyGems, but then I install gems using the gem command (not port). I've found that Ruby gems in MacPorts aren't well-maintained, and the latest MacPorts version is often significantly behind the "real" version (for lack of a better term).
MacPorts is great for lots of things. However, RVM is generally a more flexible way to install Ruby, because it makes it easy to install an appropriate Ruby interpreter per project.