Moving to Rails 3¶
We have a Redmine 2.2 pristine branch (redmine-2.2) and an integration branch (redmine-2.2-integration) in which to fix errors arising from merging our own changes back in to Redmine 2.2.
For Rails 2, we have been using Ruby Enterprise Edition v1.8.7 with Phusion Passenger v3.0.1.
For Rails 3 we want to use a more mainstream Ruby v1.9.3, with Phusion Passenger v3.0.18.
Ubuntu 10.04 LTS only has Ruby 1.9.1, so we use the Brightbox packages.
$ sudo apt-add-repository ppa:brightbox/ruby-ng $ sudo apt-get update $ sudo apt-get install ruby1.9.3 $ sudo gem1.9.3 install rails $ sudo gem1.9.3 install passenger $ sudo apt-get install libcurl4-openssl-dev $ sudo passenger-install-apache2-module
The Passenger installer prints out:
Please edit your Apache configuration file, and add these lines: LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-3.0.18/ext/apache2/mod_passenger.so PassengerRoot /var/lib/gems/1.9.1/gems/passenger-3.0.18 PassengerRuby /usr/bin/ruby1.9.1
(Note that the Brightbox PPA "Ruby 1.9.1" is in fact 1.9.3, unlike the Ubuntu repo package which is 1.9.1 -- confusing)
Although the different versions of Ruby and Rails can coexist, the Passenger Apache module can be loaded once per Apache instance only, so introducing the new version will supersede entirely the old one. The Rails version is specified in each application config, but they will all get the same Ruby version.
So, we make the above change (in
mods-available/passenger.load) and the existing sites break with "Ruby on Rails version '2.3.14' not found" -- fair enough, it isn't installed for the new version of Ruby. Rather than fix this, let's keep the situation simpler to understand by blundering into the world of Rails 3 only.
I'm also going to remove /usr/local/bin (i.e. REE) from the PATH:
$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games $ PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
/usr/games ??) Unfortunately we seem to have
bundle for Ruby 1.9 installed in /usr/local/bin, so
$ sudo /usr/local/bin/bundle install
Now, to the web instance and
hg pull -u; hg update redmine-2.2-integration. Then
$ RAILS_ENV=development rake1.9.3 db:migrate
And now we're into application incompatibility territory:
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /var/www/test-cannam/Rakefile:7) Plugins in vendor/plugins (/var/www/test-cannam/vendor/plugins) are no longer allowed. Please, put your Redmine plugins in the `plugins` directory at the root of your Redmine directory (/var/www/test-cannam/plugins)
Before we try to fix all the application incompatibilities, let's try the pristine Redmine 2.2.
Pristine Redmine 2.2¶
$ hg update redmine-2.2 $ rm -rf vendor/plugins # nothing here but leftover crap anyway $ RAILS_ENV=development rake1.9.3 db:migrate rake aborted! Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)
This is a misleading error message -- see here. We need to change the db adapter in config/database.yml from
mysql2. Next up,
Please remove config/initializers/session_store.rb and run `rake generate_secret_token`. Setting the session secret with ActionController.session= is no longer supported in Rails 3.
OK, I'm going to rename that file rather than remove it (in case we need to go back) and then run the rake task.
$ mv config/initializers/session_store.rb config/initializers/session_store.rb_rails2 $ RAILS_ENV=development rake1.9.3 generate_secret_token $ RAILS_ENV=development rake1.9.3 db:migrate
migrate now succeeds (there does not appear to be a separate
db:migrate:plugins any more?) and we can restart the server, for an apparently working Redmine 2.2 instance.
Back to our application¶
OK, so the pristine code works. Now
$ hg update redmine-2.2-integration
and take it from here Luis!
Working wit the the integration branch¶
Needed to move all the plugins from vendor/plugins to plugins/.
To do this I used hg rename:
for i in `ls vendor/plugins`; do echo hg rename vendor/plugins/$i plugins/$i; done | sh
I also needed to completely remove the vendor/plugins folder and any remaining files (temporary files from the editors, for instance).
After moving the plugins, I had to rerun
bundle install to make sure I had all the gems properly installed.