I have been given task to move an app, the database, and all required
software from an old system (going away soon) to a new one. I think I
have all the software BUT can’t get the app to ‘work’. So, my question
is what is the step to migrate a ruby on rails app?
“old” server
saptip:/etc# ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [ia64-linux]
saptip:/etc# rails -v
Rails 2.3.5
saptip:/# apache2 -v
Server version: Apache/2.2.9 (Debian)
Server built: Nov 14 2009 21:10:54
saptip:/# mysql -h localhost -V
mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (ia64) using
readline 5.2
saptip:/etc# uname -a
Linux saptip 2.6.26-2-mckinley #1 SMP Thu Feb 11 11:08:30 UTC 2010 ia64
GNU/Linux
“new” server
[root@s928-apsaptip etc]# rails -v
Rails 4.2.5
[root@s928-apsaptip etc]# httpd -v
Server version: Apache/2.4.6 (Red Hat Enterprise Linux)
Server built: Sep 17 2015 09:06:30
[root@s928-apsaptip etc]# mysql -h localhost -V
mysql Ver 14.14 Distrib 5.6.29, for Linux (x86_64) using EditLine
wrapper
[root@s928-apsaptip etc]# uname -a
Linux s928-apsaptip.ssmhc.com 3.10.0-229.4.2.el7.x86_64 #1 SMP Fri Apr
24 15:26:38 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
I discovered this fact the same time you replied. Not sure where to go
from here. Thanks, though. Also, this is an internal site/app so no
internet access for this system.
Your app expects an old version of Rails (2.3.5) from 2009/10 (which
is likely now full of security holes). For the app to work you must
ensure that you have the right version of rails and all the other gems
on the new machine. Go back to the old one and check every gem that
is used and make sure you use exactly that version (and initially only
that version) on the new machine. Once it is working upgrade it to
Rails 4.
If at all possible it would be much better to upgrade to Rails 4 on
the old server, then at least you are starting with a working system.
With current rails versions the gem version problem is solved by the
use of Gemfile and Gemfile.lock. It is not safe to have an internet
facing rails app using 2.3.5
Unfortunately it will be probably be no slight task upgrading the app.
You will probably need someone experienced in Rails to do this.
I discovered this fact the same time you replied. Not sure where to go
from here. Thanks, though. Also, this is an internal site/app so no
internet access for this system.
I managed to get a “Hello World” app working… so what do need to do to
move the app from one server to another? This is apparently a SIMPLE
app and doesn’t use a bunch of libraries and such. I though I could
just copy to directory tree over but that didn’t seem to work.
The only clue I have is in the command “rake -T”. it works beautifully
in the ‘hello world’ app dir but fails in the one I moved over:
[root@s928-apsaptip tip]# rake -T
rake aborted!
LoadError: cannot load such file – initializer
/var/rails/tip/config/boot.rb:55:in load_initializer' /var/rails/tip/config/boot.rb:38:inrun’
/var/rails/tip/config/boot.rb:11:in boot!' /var/rails/tip/config/boot.rb:110:in<top (required)>’
/var/rails/tip/Rakefile:4:in `<top (required)>’
(See full trace by running task with --trace)
I managed to get a “Hello World” app working… so what do need to do to
move the app from one server to another? This is apparently a SIMPLE
app and doesn’t use a bunch of libraries and such. I though I could
just copy to directory tree over but that didn’t seem to work.
Have you checked the versions of all the gems (including rails) used
on the old server and installed those and only those on the new one?
If you have only that app to get going that is the easiest way of
making sure you pick up the right gems.
I think I got farther. Even though I have loaded acts_as_ferret I get
the following error. Since I know zero of config files I suspect it is
something there:
[root@s928-apsaptip tip]# rails s
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
Exiting
/var/rails/new_tip/tip/config/environment.rb:8:in require': cannot load such file -- acts_as_ferret (LoadError) from /var/rails/new_tip/tip/config/environment.rb:8:in <top
(required)>’
from /var/rails/new_tip/tip/config.ru:3:in require' from /var/rails/new_tip/tip/config.ru:3:in block in ’
from
/usr/local/share/gems/gems/rack-1.6.4/lib/rack/builder.rb:55:in instance_eval' from /usr/local/share/gems/gems/rack-1.6.4/lib/rack/builder.rb:55:in initialize’
from /var/rails/new_tip/tip/config.ru:in new' from /var/rails/new_tip/tip/config.ru:in ’
from
/usr/local/share/gems/gems/rack-1.6.4/lib/rack/builder.rb:49:in eval' from /usr/local/share/gems/gems/rack-1.6.4/lib/rack/builder.rb:49:in new_from_string’
from
/usr/local/share/gems/gems/rack-1.6.4/lib/rack/builder.rb:40:in parse_file' from /usr/local/share/gems/gems/rack-1.6.4/lib/rack/server.rb:299:in build_app_and_options_from_config’
from
/usr/local/share/gems/gems/rack-1.6.4/lib/rack/server.rb:208:in app' from /usr/local/share/gems/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in app’
from
/usr/local/share/gems/gems/rack-1.6.4/lib/rack/server.rb:336:in wrapped_app' from /usr/local/share/gems/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in log_to_stdout’
from
/usr/local/share/gems/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in start' from /usr/local/share/gems/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in block in server’
from
/usr/local/share/gems/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in tap' from /usr/local/share/gems/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in server’
from
/usr/local/share/gems/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in run_command!' from /usr/local/share/gems/gems/railties-4.2.5/lib/rails/commands.rb:17:in <top (required)>’
from /var/rails/new_tip/tip/bin/rails:9:in require' from /var/rails/new_tip/tip/bin/rails:9:in <top (required)>’
from
/usr/local/share/gems/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in load' from /usr/local/share/gems/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in call’
from
/usr/local/share/gems/gems/spring-1.7.1/lib/spring/client/command.rb:7:in call' from /usr/local/share/gems/gems/spring-1.7.1/lib/spring/client.rb:30:in run’
from /usr/local/share/gems/gems/spring-1.7.1/bin/spring:49:in <top (required)>' from /usr/local/share/gems/gems/spring-1.7.1/lib/spring/binstub.rb:11:in load’
from
/usr/local/share/gems/gems/spring-1.7.1/lib/spring/binstub.rb:11:in <top (required)>' from /usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:55:in require’
from
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:55:in require' from /var/rails/new_tip/tip/bin/spring:13:in <top (required)>’
from bin/rails:3:in load' from bin/rails:3:in ’
actionmailer (2.3.5) (4.2.5)
rails (2.3.5) (4.2.5)
warden (0.10.2) na
will_paginate (2.3.12) na
So… do I get rid of ALL the new gems and try to figure out how to just
install the old ones?
Probably, you have no hope as you have it, you are still trying to use
rails 4.2.5 which is hugely different to 2.3.5
Installing a specific gem version is easy.
For example
gem install -v n.n.n
Not sure whether for Rails you can just remove the gem versions above
and install the 2.3.5 ones or if you will also have problems with the
support tools that come with rails being of a later flavour
You might also have issues with the version of Ruby you have
installed. I don’t know which versions of Ruby 2.3 will run with.
The nicest way to do it would be to use rvm, which lets you run
multiple versions of gems from what are called gemsets, then you can
just make the right versions of gems available to your app. Rvm will
also allow multiple versions of ruby. But really you are on a massive
learning curve, you need someone who knows what they are doing or you
will be splashing about in the swamp for a long time.
I have not used red hat for years but with ubuntu 14.04 LTS (and some
other similar systems) I have configured the system to support rails
2.3.18 using this script http://opencampground.com/SWinstall.sh. Take
a look at it and you will see there is a lot needing to be changed from
a vanilla system. You will have no luck running rails 2.3.18 with a
ruby later than 1.9.1 which is about impossible to find. You really need
ruby 1.8.7. Make sure you grab the apache passenger virtual host
definition files from the old system before it vanishes.
rack (1.0.1) (1.6.4)
For example
just make the right versions of gems available to your app. Rvm will
also allow multiple versions of ruby. But really you are on a massive
learning curve, you need someone who knows what they are doing or you
will be splashing about in the swamp for a long time.
Actually thinking about it I could probably lead you through setting
the environment up using rvm fairly easily, assuming you are on a
sensible OS. What OS are you using?
There is a lot of difference between Rails 2.3 and 4.2 (I know because
I’ve recently helped a client do that “upgrade”†).
If your “old” application didn’t use bundler (aka, does it have a Gemfile and Gemfile.lock in the top directory?), that might be the
first tiny upgrade to make. Bundler did not exist when Rails 2.3 was
current so it’s not likely present unless someone introduced it.
At the very least, you could update rails to 2.3.18 (the last of its
lineage). In a Gemfile, that would be:
gem ‘rails’, ‘~> 2.3’
The will_paginate gem does not support Rails 4 (unless that has
changed somewhat recently). You might want to look at kaminari as a
replacement for pagination.
-Rob
† it was actually a “full body transplant” rather than an “upgrade in
place”. We started with a bare Rails 4.2.x application and generated
models as we went along, copying the relevant contents from the old
application into the new. Same with controllers.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.