Port Ruby on Rails Application

Discussion in 'Ruby' started by Snoop1990 Snoop1990, Dec 27, 2007.

  1. Hello,
    I have to leave my old server, so I did a backup and saved my ruby on
    rails Applications and my mysql databases to an external USB stick and
    brought them to the new server.

    The backup for mysql works just fine, no errors on this side.

    The next thing, I want to start the internal webrick server ... and got
    an Error message. Not able to boot up ? ... And I noticed that the error
    was caused because my previous server was FreeBSD and the new is Linux
    (Kubuntu). So I replaced some files and get the server running and I
    could access the applications first page, but then again I get an Error.
    Therefore my question is, which files differ between the different
    operation systems.

    I have :
    -app
    -components
    -config
    -db
    -doc
    -lib
    -log
    -public
    -Rakefile // file
    -README // file
    -script
    -test
    -tmp
    -vendor

    I'm not sure but maybe the version of rails between the servers differ
    as well.
     
    Snoop1990 Snoop1990, Dec 27, 2007
    #1
    1. Advertisements

  2. Hard to say without something more descriptive than 'an Error'.
    Most of the time it shouldn't matter whether you're on ubuntu or bsd
    (none of our apps care if they are on windows, linux or mac os x) but
    if as you say below the version of rails is different then that could
    certainly rip things up. But again without any more information it's
    hard to say.

    Fred
     
    Frederick Cheung, Dec 27, 2007
    #2
    1. Advertisements

  3. [Note: parts of this message were removed to make it a legal post.]

    Yes Rails applications can be sensitive to the version of Ruby, Rails or
    Gems installed

    Telling us what error you got would help.
     
    michael greenly, Dec 27, 2007
    #3



  4. Ok, I use my first one, this application run on Freebsd without any
    errors! I copied the hole directory and now try to start the internal
    web server webrick and get this :

    $ ./script/server
    /script/../config/boot.rb:18:in `require': no such file to load --
    rubygems (LoadError)
    from ./script/../config/boot.rb:18
    from ./script/server:2:in `require'
    from ./script/server:2

    I thought maybe Rails does not work, so I started a new projekt with the
    "rails <projectname>" command and launched the internal webserver inside
    this new project. It works but it looks a bit different during the boot
    process:

    $ ./script/server
    => Booting WEBrick...
    => Rails application started on http://127.0.0.1:3000
    => Ctrl-C to shutdown server; call with --help for options
    [2007-12-27 16:42:12] INFO WEBrick 1.3.1
    [2007-12-27 16:42:12] INFO ruby 1.8.6 (2007-06-07) [i486-linux]
    [2007-12-27 16:42:12] WARN TCPServer Error: Address already in use -
    bind(2)
    /usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Address already
    in use - bind(2) (Errno::EADDRINUSE)
    from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `new'
    from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
    from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `each'
    from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
    from /usr/lib/ruby/1.8/webrick/server.rb:75:in `listen'
    from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
    from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
    from
    /home/Share/www/snoop/blog/vendor/rails/railties/lib/webrick_server.rb:58:in
    `new'
    from
    /home/Share/www/snoop/blog/vendor/rails/railties/lib/webrick_server.rb:58:in
    `dispatch'
    from
    /home/Share/www/snoop/blog/vendor/rails/railties/lib/commands/servers/webrick.rb:59
    from
    /home/Share/www/snoop/blog/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
    `require'
    from
    /home/Share/www/snoop/blog/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
    `require'
    from
    /home/Share/www/snoop/blog/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in
    `new_constants_in'
    from
    /home/Share/www/snoop/blog/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
    `require'
    from
    /home/Share/www/snoop/blog/vendor/rails/railties/lib/commands/server.rb:39
    from ./script/server:3:in `require'
    from ./script/server:3

    Booting on freebsd, the first application:
    %./script/server
    => Booting WEBrick...
    => Rails application started on http://0.0.0.0:3000
    => Ctrl-C to shutdown server; call with --help for options
     
    Snoop1990 Snoop1990, Dec 27, 2007
    #4
  5. Ups I missed :

    [2007-12-27 17:47:08] INFO WEBrick 1.3.1
    [2007-12-27 17:47:08] INFO ruby 1.8.6 (2007-03-13) [i386-freebsd6]
    [2007-12-27 17:47:08] INFO WEBrick::HTTPServer#start: pid=817 port=3000

    So the total FreeBSD webrick boot looks like:

    %./script/server
    => Booting WEBrick...
    => Rails application started on http://0.0.0.0:3000
    => Ctrl-C to shutdown server; call with --help for options
    [2007-12-27 17:47:08] INFO WEBrick 1.3.1
    [2007-12-27 17:47:08] INFO ruby 1.8.6 (2007-03-13) [i386-freebsd6]
    [2007-12-27 17:47:08] INFO WEBrick::HTTPServer#start: pid=817 port=3000
     
    Snoop1990 Snoop1990, Dec 27, 2007
    #5
  6. Snoop1990 Snoop1990

    Luis Lavena Guest

    script/server is yelling at you that rubygems is not installed, but
    then you said that using 'rails command' manage to create a empty
    application.

    How did you managed to install Rails _without_ rubygems?
    Maybe you used the zip or tgz package available in rubyforge, which
    you should have pointed in your first mail:

    - I installed ruby using freebsd ports
    - I installed rails grabbing the zip package and running setup.
    - THEN i get this error message.

    Will be cool when users start writting that kind of reports of their
    problems, but still we live in a imperfect world ;-)
    Reading the error message:

    WARN TCPServer Error: Address already in use - bind(2)

    That means the port used by webrick is already used by another
    process, and is impossible to continue beyond that point.

    So:

    1) install rubygems
    2) look what other process/application is using port 3000 (rails
    default).
    3) fix your dependencies issues (and correct version of them) for
    Rails and the gems you're using in your application.

    HTH,
    Luis Lavena
     
    Luis Lavena, Dec 27, 2007
    #6
  7. Sorry I do not get this!

    I just setup a new rails application and started it at port 40000 and it
    works ... why ? ... neither I nor my friend changed anything !

    $ ./script/server -p 40000
    => Booting WEBrick...
    => Rails application started on http://127.0.0.1:40000
    => Ctrl-C to shutdown server; call with --help for options
    [2007-12-27 18:00:07] INFO WEBrick 1.3.1
    [2007-12-27 18:00:07] INFO ruby 1.8.6 (2007-06-07) [i486-linux]
    [2007-12-27 18:00:07] INFO WEBrick::HTTPServer#start: pid=22874
    port=40000


    But still the same error when I try the FreeBSD application on the Linux
    Server !

    $ ./script/server -p 40000
    /script/../config/boot.rb:18:in `require': no such file to load --
    rubygems (LoadError)
    from ./script/../config/boot.rb:18
    from ./script/server:2:in `require'
    from ./script/server:2
     
    Snoop1990 Snoop1990, Dec 27, 2007
    #7
  8. Found the first Error:

    I get :

    $ ./script/server
    => Booting WEBrick...
    Rails Error: Unable to access log file. Please ensure that
    /home/Share/www/snoop/backup/blog copy/log/development.log exists and is
    chmod 0666. The log level has been raised to WARN and the output
    directed to STDERR until the problem is fixed.
    => Rails application started on http://127.0.0.1:3000
    => Ctrl-C to shutdown server; call with --help for options
    [2007-12-27 18:14:41] INFO WEBrick 1.3.1
    [2007-12-27 18:14:41] INFO ruby 1.8.6 (2007-06-07) [i486-linux]
    [2007-12-27 18:14:41] WARN TCPServer Error: Address already in use -
    bind(2)
    /usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Address already
    in use - bind(2) (Errno::EADDRINUSE)
    from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `new'
    from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
    from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `each'
    from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
    from /usr/lib/ruby/1.8/webrick/server.rb:75:in `listen'
    from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
    from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
    from /home/Share/www/snoop/backup/blog
    copy/vendor/rails/railties/lib/webrick_server.rb:58:in `new'
    from /home/Share/www/snoop/backup/blog
    copy/vendor/rails/railties/lib/webrick_server.rb:58:in `dispatch'
    from /home/Share/www/snoop/backup/blog
    copy/vendor/rails/railties/lib/commands/servers/webrick.rb:59
    from /home/Share/www/snoop/backup/blog
    copy/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
    `require'
    from /home/Share/www/snoop/backup/blog
    copy/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
    `require'
    from /home/Share/www/snoop/backup/blog
    copy/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in
    `new_constants_in'
    from /home/Share/www/snoop/backup/blog
    copy/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in
    `require'
    from /home/Share/www/snoop/backup/blog
    copy/vendor/rails/railties/lib/commands/server.rb:39
    from ./script/server:3:in `require'
    from ./script/server:3


    Instead of :

    $ ./script/server
    => Booting WEBrick...
    => Rails application started on http://127.0.0.1:3000
    => Ctrl-C to shutdown server; call with --help for options
    [2007-12-27 18:13:09] INFO WEBrick 1.3.1
    [2007-12-27 18:13:09] INFO ruby 1.8.6 (2007-06-07) [i486-linux]
    [2007-12-27 18:13:09] INFO WEBrick::HTTPServer#start: pid=23598
    port=3000

    when I try to run two webrick servers at the same port on the same
    system. I just mixed up to shutdown one and started another, which
    causes an error. As described above. But what about the FreeBSD
    application ?

    When I try to start it I still get the following error :

    $ ./script/server -p 40001
    /script/../config/boot.rb:18:in `require': no such file to load --
    rubygems (LoadError)
    from ./script/../config/boot.rb:18
    from ./script/server:2:in `require'
    from ./script/server:2
     
    Snoop1990 Snoop1990, Dec 27, 2007
    #8
  9. This app has gems frozen in vendor
    This one probably doesn't. Do you have rubygems installed ?

    Fred
     
    Frederick Cheung, Dec 27, 2007
    #9
  10. [Note: parts of this message were removed to make it a legal post.]

    It sounds like gems are not available?

    Can you give us the results of each of these commands?

    #> which ruby
    #> ruby --version
    #> which rails
    #> rails --version
    #> which gem
    #> gem environment

    How did you install each of these components? Ruby? Gems? Rails?

    I'd recomend this path on debian/ubuntu for people who don't know why they
    may want to do it differently....

    Install Ruby and Gems via apt and Rails via Gems. In your case you will
    also want to make sure the version of Rails your application expects is
    available. To find out what version you need look in
    /config/environment.rb and then install Rails with a command something
    like: "gem install rails --version 1.2.6"

    The one thing to remember with this setup is DON'T run 'gem update --system'


    A more robust alternative is to install Ruby via apt and Gems via source
    packages.
     
    michael greenly, Dec 27, 2007
    #10
  11. As you see in the posts above the Application created on Linux works on
    Linux only the one created on FreeBSD and then transfered to a Linux
    server does not work !
     
    Snoop1990 Snoop1990, Dec 27, 2007
    #11

  12. As you see above on both server's we have WEBrick 1.3.1 and ruby 1.8.6
    ! On freebsd my Ruby on Rails server runs like a shame so there is no
    problem !

    Here are my reuslts for the Linux server :

    $ ruby --version
    ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux]
    $ rails --version
    getopt: unrecognized option `--version'
    Terminating...
    $ gem enviroment
    -sh: gem: not found
    $

    Seems like gem is missing !
     
    Snoop1990 Snoop1990, Dec 27, 2007
    #12
  13. Snoop1990 Snoop1990

    Luis Lavena Guest

    This work? (inside a irb session):

    require 'rubygems'
    => true

    If that is the answer, then something is wrong in other place, but if
    it raise a LoadError exception, that means you don't have rubygems
    installed and that is part of config/boot.rb

    HTH,

    Luis
     
    Luis Lavena, Dec 27, 2007
    #13
  14. [Note: parts of this message were removed to make it a legal post.]

    It looks like your problem is that rubygems is not installed and the
    application doesn't have them frozen.

    You'll either have to freeze the gems from the running machine before
    copying the application off or install rubygems on the new machine.

    Once you install rubygems you will still need to install what ever gems the
    application needs.



     
    michael greenly, Dec 27, 2007
    #14
  15. Ok I am going to do that ! thank you all for your support !
     
    Snoop1990 Snoop1990, Dec 27, 2007
    #15
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.