Installing rails on Ubuntu

Hello, I'm trying to install the rails on ubuntu 11.10, but when I put the command

felipe@Felipe:~/Downloads/rubygems-1.8.15$ sudo gem install rails --no-r1 --no-rdoc ERROR: Loading command: install (LoadError)     no such file to load -- zlib ERROR: While executing gem ... (NameError)     uninitialized constant Gem::Commands::InstallCommand felipe@Felipe:~/Downloads/rubygems-1.8.15$

it return this error, how can I install correctly.

Thanks

Hello, I'm trying to install the rails on ubuntu 11.10, but when I put the command

felipe@Felipe:~/Downloads/rubygems-1.8.15$ sudo gem install rails

The best way to install rails is to use rvm. See http://beginrescueend.com/

Colin

Hello, I'm trying to install the rails on ubuntu 11.10, but when I put the command

felipe@Felipe:~/Downloads/rubygems-1.8.15$ sudo gem install rails --no-r1 --no-rdoc ERROR: Loading command: install (LoadError) no such file to load -- zlib ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommand felipe@Felipe:~/Downloads/rubygems-1.8.15$

it return this error, how can I install correctly.

Have you installed: apt-get install zlib1g zlib1g-dev

Also - in general, it is not a good idea to install gems using sudo.

  1. The default first answer to these questions is, “use rvm” (really !).

https://rvm.beginrescueend.com/

E.g. for Ubuntu 11.10, I wrote a detailed log of doing it from scratch

(and there are many others if you Google):

http://rails.vandenabeele.com/blog/2011/11/26/installing-ruby-and-rails-with-rvm-on-ubuntu-11-dot-10/

Note that you will NOT need to do “sudo” with rvm, It is a local install

that you could alway wipe out and start over etc. if you are experimenting …

(you could even make a separate “ror” user and do rvm there,

just to practice without risk.

  1. If you really want to install system with sudo , than the specific problem

you face is probably that you miss a number -dev libraries.

Probably

$ sudo apt-get install zlib1g zlib1g-dev

will get you out of this one and then you will probably hit the next error …

(I recently installed on a different Ubuntu 11.10 without rvm, it was a lot

harder and the write-up is here:

http://rails.vandenabeele.com/blog/2012/01/15/installing-ruby-rails-passenger-on-ubuntu-11-dot-10/

Not advised unless you are more experienced).

HTH,

Peter

CavalryJim wrote in post #1041969:

Also - in general, it is not a good idea to install gems using sudo.

CavalryJim, what is the best way to install ?

I'm following the tutorial, but when I try put the commando 'rvm install 1.8.7' shows

felipe@Felipe:~$ rvm install 1.8.7 bash: /usr/bin/rvm: File or folder not found felipe@Felipe:~$

As Colin stated, a best practice for installing ruby is rvm.

For installing rails, use 'gem install rails'

For all other gems, add the gem to your projects gemfile and run 'bundle install'.

Ok, but, when I try with 'gem install rails'

felipe@Felipe:~$ gem install rails ERROR: Loading command: install (LoadError)     no such file to load -- zlib ERROR: While executing gem ... (NameError)     uninitialized constant Gem::Commands::InstallCommand felipe@Felipe:~$

some lib are missing, but I put the command

sudo apt-get install zlib1g zlib1g-dev

and was all updated

From which source did you install your ruby and rubygems?

Where are they installed?

Could you run these commands and show the output please.

$ ruby -v

$ which ruby # if it is a symlink, follow it also

$ gem -v

$ which gem # if it is a symlink follow it also

$ echo $PATH

And again … even if you have started with manual install

of Ruby etc, you can still go to rvm (and inside rvm you

can use $ rvm system to go back to the system installed

ruby if you need to; I demonstrate that below).

As reference, on my system (rvm on Ubuntu 11.10):

peterv@ASUS:~$ ruby -v

ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]

peterv@ASUS:~$ which ruby

/home/peterv/.rvm/rubies/ruby-1.9.3-p0/bin/ruby

peterv@ASUS:~$ gem -v

1.8.10

peterv@ASUS:~$ which gem

/home/peterv/.rvm/rubies/ruby-1.9.3-p0/bin/gem

peterv@ASUS:~$ echo $PATH

/home/peterv/.rvm/gems/ruby-1.9.3-p0/bin:/home/peterv/.rvm/gems/ruby-1.9.3-p0@global/bin:/home/peterv/.rvm/rubies/ruby-1.9.3-p0/bin:/home/peterv/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Falling back (what I normally never do anymore) to system ruby:

peterv@ASUS:~$ rvm use system

Now using system ruby.

peterv@ASUS:~$ ruby -v

ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]

peterv@ASUS:~$ which ruby

/usr/bin/ruby

peterv@ASUS:~$ gem -v

1.3.7

peterv@ASUS:~$ which gem

/usr/bin/gem

peterv@ASUS:~$ echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/peterv/.rvm/bin

HTH,

Peter

Ok, but, when I try with ‘gem install rails’

felipe@Felipe:~$ gem install rails ERROR: Loading command: install (LoadError)

no such file to load -- zlib

ERROR: While executing gem … (NameError)

uninitialized constant Gem::Commands::InstallCommand

felipe@Felipe:~$

some lib are missing, but I put the command

sudo apt-get install zlib1g zlib1g-dev

and was all updated

I have used Rails Ready in the past, and it made the setup rather easy.

https://github.com/joshfng/railsready

Jason

felipe@Felipe:~/Downloads/rubygems-1.8.15$ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] felipe@Felipe:~/Downloads/rubygems-1.8.15$ which ruby /usr/local/bin/ruby felipe@Felipe:~/Downloads/rubygems-1.8.15$ gem -v 1.8.15 felipe@Felipe:~/Downloads/rubygems-1.8.15$ which gem /usr/local/bin/gem felipe@Felipe:~/Downloads/rubygems-1.8.15$ echo $PATH /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Ah, you actually do have rvm installed …

Did you already install some rubies ?

Anyway, this sequence should work then

peterv@ASUS:~$ rvm get stable

Original installed RVM version:

rvm 1.10.2 by Wayne E. Seguin wayneeseguin@gmail.com, Michal Papis mpapis@gmail.com [https://rvm.beginrescueend.com/]

Downloading RVM from wayneeseguin branch stable

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 799k 100 799k 0 0 337k 0 0:00:02 0:00:02 --:–:-- 677k

Upgrading the RVM installation in /home/peterv/.rvm/

RVM sourcing line found in: /home/peterv/.bashrc.

Upgrade Notes:

  • No new notes to display.

RVM: Shell scripts enabling management of multiple ruby environments.

RTFM: https://rvm.beginrescueend.com/

HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

Screencast: http://screencasts.org/episodes/how-to-use-rvm

In case of any issues read output of ‘rvm requirements’ and/or ‘rvm notes’

Upgrade of RVM in /home/peterv/.rvm/ is complete.

Peter Vandenabeele,

Ok, I try, but, look what happen when I put rvm get stable

felipe@Felipe:~$ rvm get stable felipe@Felipe:~$

nothing...

I'm brazilian, so, the language is portuguese, but I guess is easy to know the error messages.

felipe@Felipe:~$ rvm get stable felipe@Felipe:~$ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] felipe@Felipe:~$ which ruby /usr/local/bin/ruby felipe@Felipe:~$ gem -v 1.8.15 felipe@Felipe:~$ which gem /usr/local/bin/gem felipe@Felipe:~$ echo $PATH /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games felipe@Felipe:~$ rvm use 1.9.3 --default WARN: ruby ruby-1.9.3 is not installed. To install do: 'rvm install ruby-1.9.3' felipe@Felipe:~$ rvm list

rvm rubies

felipe@Felipe:~$ rvm gemset create first_app mkdir: é impossível criar o diretório "/usr/local/lib/ruby/gems/1.9.1@first_app": Permissão negada 'first_app' gemset created (/usr/local/lib/ruby/gems/1.9.1@first_app). felipe@Felipe:~$ gem install rails ERROR: Loading command: install (LoadError)     no such file to load -- zlib ERROR: While executing gem ... (NameError)     uninitialized constant Gem::Commands::InstallCommand felipe@Felipe:~$ rails help O programa 'rails' não está instalado no momento. Você pode instalá-lo digitando: sudo apt-get install rails felipe@Felipe:~$ rails new first_app -skip-bundle O programa 'rails' não está instalado no momento. Você pode instalá-lo digitando: sudo apt-get install rails felipe@Felipe:~$ cd first_app bash: cd: first_app: Arquivo ou diretório não encontrado felipe@Felipe:~$ echo "gem 'therubyracer'" >> Gemfile felipe@Felipe:~$ bundle install O programa 'bundle' não está instalado no momento. Você pode instalá-lo digitando: sudo apt-get install ruby-bundler felipe@Felipe:~$ rake environment rake aborted! No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) /usr/local/lib/ruby/1.9.1/rake.rb:2367:in `raw_load_rakefile' /usr/local/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile' /usr/local/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling' /usr/local/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile' /usr/local/lib/ruby/1.9.1/rake.rb:1991:in `run' /usr/local/bin/rake:31:in `<main>' felipe@Felipe:~$

Thank's

Ok, I try, but, look what happen when I put rvm get stable

felipe@Felipe:~$ rvm get stable

felipe@Felipe:~$

nothing…

I’m brazilian, so, the language is portuguese, but I guess is easy to

know the error messages.

felipe@Felipe:~$ rvm get stable

felipe@Felipe:~$ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

felipe@Felipe:~$ which ruby

/usr/local/bin/ruby

felipe@Felipe:~$ gem -v

1.8.15

felipe@Felipe:~$ which gem

/usr/local/bin/gem

felipe@Felipe:~$ echo $PATH /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

felipe@Felipe:~$ rvm use 1.9.3 --default

WARN: ruby ruby-1.9.3 is not installed.

To install do: ‘rvm install ruby-1.9.3’

felipe@Felipe:~$ rvm list

rvm rubies

OK, since you do not have any rubies installed yet

(unlike my system), you should do here:

$ ruby list known # this will show all available rubies

pick one of them, best is ruby 1.9.3 to start

$ ruby install 1.9.3

sorry, I probably forgot to document that step, since the

rubies are already installed on my computer.

now all commands here after should work.

That’s gibberish … sorry

$ rvm install ruby-1.9.3

Peter

$ ruby list known # this will show all available rubies # pick one of them, best is ruby 1.9.3 to start

felipe@Felipe:~$ ruby list know ruby: No such file or directory -- list (LoadError) felipe@Felipe:~$

That's gibberish ... sorry

$ rvm install ruby-1.9.3

felipe@Felipe:~$ rvm install ruby-1.9.3 Installing Ruby from source to: /usr/share/ruby-rvm/rubies/ruby-1.9.3, this may take a while depending on your cpu(s)...

ruby-1.9.3 - #fetching ruby-1.9.3 - #extracting ruby-1.9.3- to /usr/share/ruby-rvm/src/ruby-1.9.3 ERROR: Error running 'bunzip2 < '/usr/share/ruby-rvm/archives/ruby-1.9.3-.tar.bz2' | tar xf - -C /usr/share/ruby-rvm/tmp/rvm_src_2991', please read /usr/share/ruby-rvm/log/ruby-1.9.3/extract.log ERROR: There has been an error while trying to extract the source. Halting the installation. ERROR: There has been an error fetching the ruby interpreter. Halting the installation. felipe@Felipe:~$

I'm using Ubuntu 11.10, I was following, before your steps, this tutorial: http://blog.sudobits.com/2011/10/27/how-to-install-ruby-on-rails-in-ubuntu-11-10/

Thank for all the people that help me, I see another tutorial, and I was having a huge mistake, I wasn't restart the terminal, that was the problem...

Thank's again...