views:

141

answers:

2

I have a rails app which I develop on Windows with Rails 2.3.5, using sqlite3 as my database engine, and the internal Mongrel server as my webserver.

I deploy this app to a hosted Linux machine running Rails 2.1.0, using Postgres as my database, and Apache (calling dispatch.cgi) as my webserver. I do not have permissions to update the native Ruby or Rails installations, or to install gems natively.

In order to make my deployment easier (I thought...), I have taken a branch of my code-base for the deployed system. On this branch, I have updated database.yml to refer to postgres and run rake rails:freeze:gems and rake gems:unpack:dependencies. I have then exported this branch to my production server.

When I try to view my app on the production server, I get the error:

Application error
Rails application failed to start properly"

Checking the Apache error logs, I see the following:

./../config/../vendor/rails/railties/lib/initializer.rb:271:in `require_frameworks': Could not find RubyGem rack (~> 1.0.1) (RuntimeError)
    from ./../config/../vendor/rails/railties/lib/initializer.rb:134:in `process'
    from ./../config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
    from ./../config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
    from ./../config/environment.rb:9
    from dispatch.cgi:5:in `require'
    from dispatch.cgi:5

I'm confused. If Rack is required, why wasn't it included by gems:unpack? How can I get this working?

(If it's relevant, vendor$ find . -name rack* gives the following:

./rails/railties/lib/rails/rack
./rails/railties/lib/rails/rack.rb
./rails/railties/lib/rails/.svn/text-base/rack.rb.svn-base
./rails/actionpack/test/controller/rack_test.rb
./rails/actionpack/test/controller/.svn/text-base/rack_test.rb.svn-base
./rails/actionpack/lib/action_controller/rack_lint_patch.rb
./rails/actionpack/lib/action_controller/.svn/text-base/rack_lint_patch.rb.svn-base

)

+4  A: 

Rack isn't included because it is a framework gem. To vendor this gem you can manually unpack it into vendor/gems like this:

cd vendor/gems; gem unpack rack -v="1.0.1"

You could also start using bundler to manage your dependencies, as Rails now does by default in version three to avoid problems like the one you're currently experiencing.

Sam C
Ah that's definitely helped, but we're not quite there. First, I also had to rake gems:refresh_specs, which got Rack loading. I'm now getting the following error:/var/www/chowlett/dominion_frozen/vendor/rails/activesupport/lib/active_support/whiny_nil.rb:52:in `method_missing': undefined method `env_table' for nil:NilClass (NoMethodError) from /var/www/chowlett/dominion_frozen/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `__send__'If it's unrelated, let me know and I'll open a new question.
Chris
Never mind, this last seems to be a problem with Apache under Debian, and with not using Passenger. I'll try to work through it and raise a new question if needed.
Chris
A: 

Your first problem is that Rails 2.1.0 does not use Rack as a middle layer.

You also need to change the rails version in the config/environment.rb file.

Also, depending on the other gems you have used, you may need to go back to a stable version that works with 2.1.0.

Personally, I would install 2.1.0 on my local machine create a new app with that rails version, copy the app folder over from the 2.3.5 project (and of course your unit tests and public folder, etc, and see if you can get it to run under 2.1.0 on your local machine, substituting gems as you go that are failing in the backtrace on the server log or in the browser. This will be much easier than running in production mode and looking at apache logs. Presuming that you have good unit tests that render all your views and flex your model code, then you should flush out any methods you have used that were added since 2.1.0 that are not supported in the older versions of Rails pretty quickly.

Jed Schneider
Thanks, I might do that in future. At the moment, freezing Rack in seems to have got to the next known bug, for which I need to smile sweetly at my sysadmin to install and configure Passenger.
Chris