Moving a ruby/rails app from one server to another

80 views
Skip to first unread message

Vince Laurent

unread,
Apr 13, 2016, 11:39:42 AM4/13/16
to rubyonra...@googlegroups.com
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

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Apr 13, 2016, 11:54:22 AM4/13/16
to Ruby on Rails: Talk
On 13 April 2016 at 16:39, Vince Laurent <li...@ruby-forum.com> wrote:
> 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

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.

Colin

Vince Laurent

unread,
Apr 13, 2016, 12:01:23 PM4/13/16
to rubyonra...@googlegroups.com
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.

Time to find a ruby developer...

Colin Law

unread,
Apr 13, 2016, 12:22:13 PM4/13/16
to Ruby on Rails: Talk
On 13 April 2016 at 17:01, Vince Laurent <li...@ruby-forum.com> wrote:
> 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.
>
> Time to find a ruby developer...

Not only ruby, but Rails.

Colin

Vince Laurent

unread,
Apr 14, 2016, 12:07:52 PM4/14/16
to rubyonra...@googlegroups.com
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:in `run'
/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)

[root@s928-apsaptip tip]# rake -T --trace
rake aborted!
LoadError: cannot load such file -- initializer
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:119:in
`require'
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:119:in
`require'
/var/rails/tip/config/boot.rb:55:in `load_initializer'
/var/rails/tip/config/boot.rb:38:in `run'
/var/rails/tip/config/boot.rb:11:in `boot!'
/var/rails/tip/config/boot.rb:110:in `<top (required)>'
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:54:in
`require'
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:54:in
`require'
/var/rails/tip/Rakefile:4:in `<top (required)>'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in
`load'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in
`load_rakefile'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/application.rb:689:in
`raw_load_rakefile'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/application.rb:94:in
`block in load_rakefile'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/application.rb:176:in
`standard_exception_handling'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/application.rb:93:in
`load_rakefile'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/application.rb:77:in
`block in run'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/application.rb:176:in
`standard_exception_handling'
/usr/local/share/gems/gems/rake-11.1.2/lib/rake/application.rb:75:in
`run'
/usr/local/share/gems/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'

library issues?

Colin Law

unread,
Apr 14, 2016, 12:34:13 PM4/14/16
to Ruby on Rails: Talk
On 14 April 2016 at 17:07, Vince Laurent <li...@ruby-forum.com> wrote:
> 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.

Colin
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3d89ed51648a72038260583ed06b13b4%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

Vince Laurent

unread,
Apr 14, 2016, 2:51:38 PM4/14/16
to rubyonra...@googlegroups.com
"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?"

using gem list --local

the old system has 16, the new one 64
Here is the list of the differences:

gem old new
------------------------------------
actionmailer (2.3.5) (4.2.5)
actionpack (2.3.5) (4.2.5)
activerecord (2.3.5) (4.2.5)
activesupport (2.3.5) (4.2.5)
acts_as_ferret (0.4.8.2) (0.5.4)
devise (1.0.5) na
fastthread (1.0.7) na
ferret (0.11.6) (0.11.8.6)
jk-ferret (0.11.8.3) na
passenger (2.2.11) (5.0.27, 5.0.26)
rack (1.0.1) (1.6.4)
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?

Vince Laurent

unread,
Apr 14, 2016, 3:00:33 PM4/14/16
to rubyonra...@googlegroups.com
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 <main>'
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 `<main>'
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 `<main>'

Rob Biedenharn

unread,
Apr 14, 2016, 4:02:28 PM4/14/16
to rubyonra...@googlegroups.com
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.

Colin Law

unread,
Apr 14, 2016, 4:15:12 PM4/14/16
to Ruby on Rails: Talk
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 <name> -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.

Colin

Norm Scherer

unread,
Apr 14, 2016, 4:53:53 PM4/14/16
to rubyonra...@googlegroups.com
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.  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.

Norm

Colin Law

unread,
Apr 15, 2016, 5:53:14 AM4/15/16
to Ruby on Rails: Talk
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?

Colin

>
> Colin
Reply all
Reply to author
Forward
0 new messages