Installing the RoR stack in ubuntu 10 - ruby-on-rails

Why is setting up ruby on rails in ubuntu (for a ubuntu beginner) like getting a root canal at the dentist's office?
First of all downloading ruby, rubygems and rails itself takes forever with so many commands... Then, apparently there's already Ruby 1.8.7 in ubuntu - and when I try to install ruby 1.9.2 (for rails 3) it goes somewhere else... and rails doesn't see the new ruby...
Ugg...

Ryan Bigg has an excellent post about this using RVM. For setting up rails, you generally want to avoid installation via aptitude.
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you

I had to (not sure if this is standard), Download rails/ruby offline and link it to my bin folder before everything was good, I also had to go remove all the old stuff ubuntu flung at me. Quite painful I wish ubuntu would just update the repositories to point to the 1.9.2.

I agree about the root canal feeling. I wrote a script that does the setup for me. You can find it here: https://github.com/sleepycat/wrong-side-of-the-tracks
Suggestions, bug fixes and improvements welcome.

$ sudo apt-get install ruby1.9.1-full rubygems1.9.1 # this is really 1.9.2 despite the confusing name
$ export PATH=/var/lib/gems/1.9.1/bin:$PATH # add this to your ~/.bashrc too
$ sudo gem1.9.1 install rails
$ rails new foo_project
enjoy.

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 on Rails Install Fails

I am trying to get set up using rbenv and ruby on rails. Everything has been working fine (been working through Lynda.com Ruby on Rails Essential Training) until it came time to actually install the rails gem. It fails in the sam way every time. Can someone tell me what I need to do to continue with Rails?
I've used rbenv and have been set up with Ruby 2.1.1.
Provided Terminal Screenshot
Edit: I am calling sudo because when I try to install without sudo it provides the following (folder permissions provided for context)
Assuming you have a working rbenv installation with 2.1.1 installed, you should just be able to remove sudo from the command:
gem install rails --no-rdoc --no-ri
Using sudo runs as root, which knows nothing of the local rbenv installation for your mattcoker user, so it uses the system's Ruby instead. Generally, when using rbenv locally on your machine, you should never need to use sudo.
I never actually set the local ruby version with rbenv local 2.1.1. Everything worked like a charm after that.

Do I have to install Rails on every new project?

This is a beginner-level question.
I'm using Ubuntu 12.04
I copied a project (created on Rails 4 using the rails new command) from Dropbox to my local environment, where I have previously install Rails 4 and up-to-date Ruby and RVM, went to project's directory, typed rails server and got
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I ran gem install rails instead.
Will I have to run gem install rails on every project's directory? I thought the Rails install was a general and accessible on my whole environment.
The project was created using the same Ruby version, but on a MacOS X system.
The project is a static web brochure and has no database configuration.
Thank you in advance.
Make sure you're using the correct version of Ruby - the same version that you'd installed Rails into - with rvm list.
You likely have two of them (since you have such an issue) - the system Ruby and the RVM-installed Ruby. And likely RVM didn't engage and hook up the correct path to the rails executable, thus the error.
This should fix the issue:
rvm use whatever-ruby-you-had-installed-rails-into
Where whatever-ruby-you-had-installed-rails-into is a string like ruby-2.1.0-p0 taken from the rvm list output.
To make RVM retain Ruby version for the project.
echo whatever-ruby-you-had-installed-into >.ruby-version
in your project's path.
So after a few hours of testing, reproducing the problem, and reading (the other answers inclusive) I got the solution as follows:
Short answer: No. Rails needs to be installed only once.
Long answer: This problem occurred because of a default setting on Terminal that prevents the system from using RVM installations of ruby and rails. The solution is to integrate RVM with gnome-terminal as described in the RVM website.
With terminal window active, go to the menu at the top bar
Edit > Profile Preferences > Title and Command tab
Check the Run command as a login shell box
Restart Terminal and make sure your gemset and ruby version are set
rails server should now work as expected (you might be prompted to run bundle install before Rails can actually run fine, follow the promtp).
I am still learning to work with Ruby on Rails, so any inputs, clarifications, or additional information on the issue is more than welcome.
You don't have to install Rails on every project, but the gems that you need for that project.
With bundle install you install all the gems that you specify in Gemfile.
If you want to avoid reinstall the gems every time you change project, I suggest you to have a better look to RVM: it has got an opt called gemset (https://rvm.io/gemsets), if you use it you just need to switch your gemset:
rvm gemset use yourgemset
I hope it can help you.

How to manage ruby gems in linux?

As I have started using Linux (Ubuntu) to broaden my knowledge, but the flow for ruby (rails) development does not feel so smooth as on Mac OSX.
Do you use rvm to manage ruby gems in Linux?
One particular issue I face is that I could install rails with only sudo command. But this forces me to use sudo for all the time under my rails project.
P.S.
Might be I am missing some point with the way you do things in Linux so it is not related to ruby (or rails) at all.
It is preferred to use rvm. we can install ruby and rails without rvm as well, but we can have only one version at a time. You can find the instructions to install rvm from following link - rvm installation.
If you are the only person working on ruby rails, install in single user mode(doesn't need to go with sudo)
Installing ruby and rails only using superuser privileges means you're installing it from distribution packages. That's not recommended, and you get unneeded overload writting sudo before any rails command.
Install rvm or rbenv in your home directory and things should be smooth.

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.

Resources