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
Related
I installed Ruby and Rails couple of months ago, and I do not remember if i used Homebrew or RVM or rbenv.
Presently I have all the three installed on my Mac. I did not touch the system installed Ruby.
Is there anything I need to worry about with these three things present on my system? Is there a chance that they may mess up my perfectly working Ruby and Rails environment?
Which one should I keep or can I keep all three?
If I need to remove any or all, can anyone also help me in removing everything, RVM, rbenv, Homebrew, Ruby and Rails and make a clean installation?
You will likely want to keep Homebrew and either RVM or rbenv.
Once you decide which Ruby version manager you would like to use (rbenv or RVM) then follow the instructions to uninstall one of them, either brew uninstall rbenv assuming you installed rbenv with Homebrew, or rvm implode.
From there you should be good if you didn't touch the system Ruby.
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.
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 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.
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!