Getting Rails and mod_passenger to work under Debian with packages - ruby-on-rails

I am running a Debian squeeze server with these (backported) packages installed:
rails 2.3.5-1~bpo50+1
rails-ruby1.8 2.3.5-1~bpo50+1
rake 0.8.7-1~bpo50+1
libapache2-mod-passenger 2.2.11debian-1~bpo50+1
I have a Rails application I am trying to run in this environment, but when I load the page I get this error message:
Actual load error: Could not find
RubyGem rails (= 2.3.5) Missing the
Rails 2.3.5 gem. Please gem install
-v=2.3.5 rails, update your RAILS_GEM_VERSION setting in
config/environment.rb for the Rails
version you do have installed, or
comment out RAILS_GEM_VERSION to use
the latest version installed.
There is a constraint that I must use these "official" Rails and mod_passenger Debian packages, so installing Rails and mod_passenger the traditional way via gems is not a possibility.

There is no real reason that you should have to use offical gems from debian. You get faster security updates by using rubygems or going for fullblown rvm.
However I would suggest commenting out the RAILS_GEM_VERSION in config/environment.rb and then it should use the version you have installed.

This seems to work:
ln -s /usr/share/rails-ruby1.8/ /usr/share/myrailsproject/vendor/rails

Related

How do I upgrade the Ruby version of my project?

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.

How do I install Rails?

I am completely new to Ruby and need to use Ruby on Rails 2.3.5 on Windows. I have downloaded the zip from GitHub here: https://github.com/rails/rails/tree/v2.3.5
There was no gem file so I tried rake in the extracted directory. It took ages and seemed to have a lot of errors, but it did eventually complete.
There was no gem file created (is this even what rake is supposed to do?). And rails is not installed (typing rails at the command prompt doesnt work).
Any ideas what I am doing wrong?
EDIT: I cannot use gem install rails -v "2.3.5" as I am behind a firewall. I think I need to install it from local files.
You first need to download and install Ruby 1.8.7.
You can then install Rails via gem install rails -v=2.3.5
I would recommended you download the gems of Rails 2.3.5 from: http://rubygems.org/gems/rails/versions/2.3.5
You also need other dependencies, such as:
actionmailer = 2.3.5
actionpack = 2.3.5
activerecord = 2.3.5
activeresource = 2.3.5
activesupport = 2.3.5
rake >= 0.8.3
Since you do not have an direct internet connection, you need to download them by hand.
After you download them, use "gem install xxx.gem" to install
install ruby, include gems support.
at the command line
gem install rails
Do not install instant rails, as it is outdated and unmaintained. Use RailsInstaller http://railsinstaller.org/
You normally install Rails by only using gem, you only install "by hand" if it is not hosted anywhere.
Do the following steps (I suppose that ruby is installed and the gem command is working):
gem install rails -v 2.3.5
This should include all needed gems as well, and will install the rails command in your shell. However, to use it in Windows is a little bit difficult, because the installation of sqlite3 is not so easy.
If you could access outside world through a corporate proxy, you could use it's address in gem command, like this: gem install rails -v 2.3.5 -p http://corporate_proxy
Install InstantRails: http://broadcast.oreilly.com/2008/12/installing-instant-rails-on-wi.html

problem with rails instalation need 2.3.8 after installation still getting "rails -v" = "Rails 2.3.5"

I'm trying to setup clockingit but...
even after
gem install -v=2.3.8 rails
1 gem installed
i'm getting
rails -v
Rails 2.3.5
I need 2.3.8 to rake the gems for clockingit
help greatly apreciated
Try gem install -v 2.3.8 rails (no equal sign). You should also check if the version of Ruby on Rails installed through RubyGems is used at all. Maybe a version of Ruby on Rails installed through the package management of your operating system overlaps the version installed through RubyGems.
Try to use rvm. It is dead simple to deal with, and makes managing gems very easy. If you already on rvm, try to create another gemset
rvm gemset create new_gemset
and the try to install rails

Error putting Instant Rails on Windows 7

I am trying to get my Instant Rails working on my Windows 7 laptop.
The error I keep getting when trying to access my site files are:
c:/rails/ruby/lib/site_ruby/1.8/rubygems.rb:779:in 'report_activate_error'
RubyGem version error: rack<1.1.0 not~> 1.0.1> <Gem::LoadError>
from c:/rails/ruby/lib/ruby.site_ruby/1.8/rubygems.rb:214:in 'activate'
from c:/rails/ruby/lib/ruby.site_ruby/1.8/rubygems.rb:1082:in 'gem'
from c:/depot/vendor/rails/actionpack/lib/action_controller.rb:34
from c://rails/ruby/lib/ruby.site_ruby/1.8/rubygems/custom_require.rb:31 in 'gem_original_require'
etc...
I have intalled Rubygems 1.3.7 and they work fine and when I run the test it works and the gem env shows that the 1.3.7 has been installed correctly.
What can I do to get this working?
Any prompt help would be VERY appreciated.
Thanks
Your rack gem is outdated. Try to run gem update rack. Or, if you use Rails with Bundler, just run bundle install in the root of your project and it will do everything for you.
I decided to write a little manual about the Ruby 1.8.7 and Rails stable installation.
Download RubyInstaller 1.8.7 from here. During the installation, check the 'Add Ruby executables to your PATH' box. After the installation, don't forget to restard cmd. Then try running ruby -v and gem -v to check for installed Ruby 1.8.7 and RubyGems 1.3.7;
Install the latest stable Rails 2.3.8 using gem install rails --no-ri --no-rdoc; Check it using rails -v;
Create a new application using rails myapp;
Test it: script/server. That's it!
gem install rack -v 1.0.1

Rails 2.3.8 problem

I am running Ruby 1.9.1 & rails 2.3.8. Everything is installed fine as far as I can tell but when I run rake db:migrate I get this error:
Missing the Rails 2.3.8 gem. Please gem install -v=2.3.8 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
So I wanted to make sure I had rails installed and ran from the command line rails -v & it says Rails 2.3.8. So I am not sure what gives here. Can anyone point me in the right direction? thank you very much.
Well, if you really have those versions installed and you get the error, something may be wrong.
But, you can do as the message recommends and comment out the setting in your config/environment.rb so it tries to use whatever version you have installed.
Did you install rails with a different package manager? If I install rails with "sudo apt-get install rails" then "rails -v" uses the rails binary in /bin (even if it's 2.3.5 or 2.0.2) because that is first in my path. If after that I install rails with "sudo gem install rails -v=2.3.8" typing "rails -v" still gives me the version of the /bin rails. I haven't verified, but I would guess this is the same issue if you're using macports. If you uninstall the package you installed with the non rubygems package manger and then reinstall rails with rubygems that may fix your issue.
Hope this helps.

Resources