Issue installing Rails - ruby-on-rails

I was working on a project with Rails3 and Ruby 1.9.3 when suddenly it said I don't have Rails installed.
Originally I used RVM and I tried to do it again to reinstall Rails, but when I run rails -v, it says Rails is not currently installed on this system.
Does anybody have an idea what I should do next to solve this problem?
I know it is not recommended to do rvm uninstall but what other option do I have?
I am using OSX 10.7.5.

Before doing this be sure that you installed RVM correctly.
Then check which Ruby is selected with this command:
rvm list
If the proper Ruby is not selected then select your desired Ruby using:
rvm 1.9.3
Then use:
gem install rails
to install Rails.
Or You can try this also
Create a default gemset to store your gems
$rvm use 1.9.3#mygemset --create --default
Then install Rails
$ gem install rails
I think this solve your issue

Use rvm info to see what RVM knows about your system and its settings.
Use rvm use 1.9.3 --default to set RVM's default to your 1.9.3 version of Ruby.
If you have multiple Rubies installed, it's possible you installed Rails under a different Ruby, so you'll need to try switching between them to find where it's living.
Using rvm implode or rvm uninstall <some version of ruby> are last-case measures when a Ruby or RVM is totally acting up, so don't go there unless you need to.
You can use gem list rails to see if a particular Ruby has Rails installed.
RVM is a very powerful tool, with a lot of features, which will let you shoot yourself in the foot if you don't pay attention or know what you're doing. 99% of the problems we see with RVM are directly tied to the user not having read the directions completely (or at all), thrashing around, or using the wrong instructions for RVM. READ the rvm.io pages to learn what it can do; Don't rely on non-RVM sites to give you instructions because they go stale quickly, and can give you bad advice. Trust the RVM folks for the information on how to use their own tool.

Related

Specifically stating the Ruby version in my Rails project (RVM)

I'm a little confused on using Ruby Version Manager. I was just wondering how to handle ruby updates for my web apps.
For example, I start a new Rails project and I tell RVM to use a specific version of Ruby like so:
rvm use ruby-2.0.0#my-project-name --create
Then say months down the road a new version of Ruby is released. What do I do then? Do I go back in and tell RVM to use the newer version? I want to build something that is always using the latest version of Ruby.
I'm assuming people build Rails apps, but don't always update to the newest version of Ruby and Rails?
Thanks, just starting out with all this, and trying to wrap my head around it.
There are three parts in this, Ruby, Gems and Rails Project, RVM can help organize everything in this order Ruby Interpreter/Version -> Gemset -> Rails Project
First Ruby:
You can use rvm list known to list all Ruby versions available in MRI, Rubinius, JRuby and others, after that you can install any version and interpreter like:
If you use MRI then rvm install 2.1 will install the latest in the 2.1 branch (2.1.1 being the latest).
For Rubinius rvm install rbx will install the latest stable Rubinius.
For JRuby rvm install jruby will install the latest stable JRuby.
After installing the version you're going to use, you need to specify that you're going to use it, like this for Rubinius: rvm rbx.
Second Gemset:
RVM gives you the ability to define different gemsets in each installed Ruby version that allows you to install gems for a specific project. For this Rubinius version I can:
Create a gemset like rvm gemset create latestRails.
Use a gemset rvm rbx#latestRails.
Show current Ruby/gemset rvm current.
Install latest Rails version in this gemset gem install rails.
Third Rails:
To keep Rails updated, you can use Bundler with a command like bundle update to keep all the gems updated (this are updated inside the current Ruby/gemset and the Gemfile) or a list/single gem of the project, for more info see "Bundle Update Documentation".
I hope I could help you.

Can't switch default version ruby for rails

I'm desperate, please help. I can't figure out how to change Ruby on Rails to run with 2.0.0, even though I think I've done everything to set 2.0.0 as the default, and rvm -list doesn't even show 1.8.7 as an option. I don't know what files I need to move/what pathways I need to change, and my attempts to uninstall rails have been unsuccessful as there's a "missingBundle" error.
$ ruby - v
returns ruby 2.0.0p247
$ rvm--default use 2.0.0
Using /Users/ericafischer-colbrie/.rvm/gems/ruby-2.0.0-p247
Then,
$ rails -s
Rails prefers to run ruby 2.0. You're running ruby 1.8.7 (2012-02-08 patchlevel 358)
[universal-darwin12.0]. Please upgrade to Ruby 1.9.3 or new to continue.
I've spent a lot of time looking at similar questions posted on stackoverflow and those solutions so far have not yielded any results.
Since you're using rvm, make sure you create a gemset and ruby-version file and install the version of rails you want to use.
E.g inside you're working dir tell rvm which ruby to use, which gemset to use, create both a gemset and ruby-version file:
rvm use ruby-2.0.0#my_cool_project --ruby-version --create
Then
gem install rails
To check run which ruby in that directory to make sure it's ruby 2 - - which rails will show you that it's using the gem of rails inside the ruby 2 my cool project gemset. Should be ok
Looks like you may have used something like sudo gem install rails.
When installing gems, you want to be sure to not use the sudo command.
Try sudo gem uninstall rails; rvm use ruby-2.0.0#myapp --create; gem install rails
Install rvm in your Macintosh
Then do rvm install 2.0.0 or rvm install version(whatever version you need)
Where ever you need a particular version of Ruby(say 2.0.0), do rvm use 2.0.0 and whichever version you need you can switch similarly.
If you are not sure how to install rvm or stuck with something else. Please see link for detailed explanation.
Updated, thanks #Momer.

Mac OS X Mountain Lion "Rails is not currently installed on this system."

I am on a fresh install of OS X Mountain Lion. I have installed rails via:
sudo gem install rails
Everything seems to install correctly, but when I type the rails command (rails s, rails -v, etc), I get this error:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
The result of 'which rails' is /usr/bin/rails
I thought it was a path issue, and perhaps it is, but I can see that /usr/bin is part of my PATH.
Any help? Thanks!
UPDATE: I noticed everything on my other mac with same exact OS works pretty well... I just can't remember how I got it to work that way. If I run 'which rails' I see it's in a totally different place /Users/username/.rvm/gems/ruby-1.9.3-p194/bin/rails
If you're using rbenv, don't forget to rbenv rehash after installing/updating ruby.
Use RVM http://rvm.io or rbenv to install newer Rails versions than what come pre-installed with OS X.
Follow examples on the site https://rvm.io/rvm/install/ but basically:
Install RVM: $ \curl -L https://get.rvm.io | bash -s stable
You can then $rvm list known to see what Rubies are available to you (lots). And simply $rvm install 1.9.3 to get the most current version of Ruby (which as of this writing is ruby-1.9.3-p327)
Set that ruby as your default $rvm --default use 1.9.3
Create a default gemset to store your gems $rvm use 1.9.3#mygemset --create --default
Then install Rails $ gem install rails will get you current which today is same as typing gem install rails -v 3.2.9
Just had this issue using rbenv, no idea how this happened, but figured that my ~/.rbenv/shims/rails was empty...
So to fix this:
Cleaned empty shims: find ~/.rbenv/shims -empty -delete
Then regenerate: rbenv rehash (was not overwriting empty one...)
I had the same problem.
After typing:
sudo gem install rails
and installing rails correctly, just close the Terminal window and open again. Then type:
~ $ rails -v
Rails 4.0.2
So, reseting the Terminal window fix the problem.
I think install rvm that will help you
rvm get head && rvm reload
rvm install 1.9.3
rvm use 1.9.3#current --create --default
The last line creates a gem set called current.
Now check to make sure you RubyGems was installed correctly by typing which gem in your terminal. Now update your gems.
gem update --system 1.8.24
Finally install rails.
gem install rails -v 3.2.3
I hope this works, let me know if you have any issues.
Yes, OSX comes standard with a lot of great software for Ruby on Rails, as well as PHP, Mysql, etc. However, sometimes it's better for sustainment purposes to use a 3rd party installer to get everything you want without digging through your /usr/ directory.
I recommend checking out http://railsinstaller.org/
With one easy install, you have everything you could want for a Rails project, including common software people use, and the site even has a tutorial. I recommend going this way. It saves you time. Plus, it comes with an easy uninstaller that it will put in your Applications folder to remove if you're not happy with the configuration. Enjoy.
Actually, /usr/bin/rails script is just a
# Stub rails command to load rails from Gems or print an error if not installed.
(Comment quoted from the very script's source)
If Rails is installed, then it is loaded. Else, the script will throw the error you pasted in your question.
Yet, another alternative to RVM is the awesome rbenv tool.
It is very easy to install (just a simple brew install rbenv) and work with. In my opinion, it is the best way to manage your rubies on a Mac.
However, if you have rvm installed on your machine already, consider removing it from your system by doing rvm implode.
Since setting up a fresh ruby on rails dev environment is a common barrier to most newbies (including myself when i started off with rails) I've put together detailed instructions on how to do exactly that in a blog post, which i will link to below. Hope you will find it useful.
http://blog.parsalabs.com/blog/2013/08/27/setting-up-a-ruby-on-rails-4-development-environment-on-a-clean-mac-os-x-installation/
i got the same error and uninstall rvm then i follow the instructions on this page https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
i think that help was
rvm requirements
on the terminal.
Our company uses a script to setup each new machine with a Rails dev environment:
We've open source it, give it a try: https://github.com/platform45/let-there-be-light
After a new
gem install rails
do
rbenv rehash
It worked for me.

Understanding Ruby environment (rvm, rails, gems, etc...)

I'm not a Ruby developer, but I need to run an application that use Ruby on rails with a lot of gems on a Mac.
Following few tutorials online I see that I need to install plenty of apps like xCode, Passenger, RVM, ecc...
Everything is ok but what about if one day I decide to uninstall everything keeping only the Ruby default installation that already exist in a Mac?
Where can I localize all the gems that I download using bundle install?
Using the Terminal and writing all these commands is a clean solution or it make my system "dirty" and slow?
Sorry for all these question, but I would like to know if there is a "best practice" to install this environment, how it work and how to uninstall it completely if I decide to do that one day.
RVM is what you need. All things could be done in command line and it will be clean and ready to be removed at any time.
Xcode is not necessary. But brew may be. If you have brew, install apple-gcc42 first. The llvm-gcc with Xcode 4.2 and later works not very well for compiling ruby.
Then install rvm. It is easy by following the steps on rvm official site. After installing it, try rvm requirements first. This command will tell you what you need to build ruby. Some libs may not are on the machine, like readline etc.
When all requirements are met, rvm install 1.9.3 will install ruby 1.9.3 on your machine and it takes several minutes. You can install any ruby version in rvm list known. And rvm list will show you local versions.
Use rvm default some_version to set default one. This will not be any conflict with system installation. And rvm use some_version will change ruby version to a specific one.
All things rvm installed will be kept in ~/.rvm/ by default, including gems.
There should be no need to uninstall rvm. But it is easy to do this by removing it directly.
RVM will provide you what you wanted. It will keep the system Ruby safe and install localized Ruby and rubygems. From rvm you can install/uninstall any version of ruby anytime and that won't affect the system ruby. When one day you wanted to remove all ruby except system one, first remove them using RVM, then then remove rvm itself.
Install RVM from here: https://rvm.io/rvm/install/
Installing RVM will install ruby a ruby. If you want, you can install other version. If you want to remove you simply run
rvm remove ruby-1.9.3-p194
you can get exact ruby version using rvm list
localized gemsets
you will need an .rvmrc file.
To create .rvmrc, enter the project directory and run the following command:
rvm --create --rvmrc ruby-1.9.3-p194#myproject
Then re-enter the directory and it will ask you to trust the .rvmrv file and you got to trust it. now if you run the bundle install it will install localized gemsets in your gemset directory (most possibly in your ~ path).
Note: please make sure ruby-1.9.3-p194 matches the name exactly that you found in rvm list

How can I uninstall Ruby on Rails on Mac OS X?

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.

Resources