This project is archived and is in readonly mode.

#3907 ✓resolved
Daniel Schierbeck

rails server fails when the tmp dir is missing

Reported by Daniel Schierbeck | February 9th, 2010 @ 12:26 PM | in 3.0.2

I'm getting the following error when running rails server in a Rails 3 beta app with a missing tmp directory:

=> Booting WEBrick
=> Rails 3.0.0.beta application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:208:in `initialize': No such file or directory - tmp/pids/server.pid (Errno::ENOENT)
    from /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:208:in `open'
    from /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:208:in `write_pid'
    from /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:154:in `start'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/commands/server.rb:49:in `start'
    from /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:83:in `start'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/commands.rb:39
    from /home/daniel/Projects/dorms/script/rails:10:in `require'
    from /home/daniel/Projects/dorms/script/rails:10

It seems that the tmp dir is not created automatically if it's missing.

Comments and changes to this ticket

  • Merrick

    Merrick February 27th, 2010 @ 06:28 AM

    I'm having this same issue. Anyone find any resolve on it?

  • Merrick

    Merrick February 28th, 2010 @ 02:38 AM

    => Booting WEBrick => Rails 3.0.0.beta application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting
    /opt/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:208:in initialize': No such file or directory - tmp/pids/server.pid (Errno::ENOENT)

    from /opt/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:208:in `open'
    from /opt/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:208:in `write_pid'
    from /opt/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:154:in `start'
    from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/commands/server.rb:49:in `start'
    from /opt/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb:83:in `start'
    from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/commands.rb:39
    from /Users/Merrick/Work/Arkitekt/Projects/Campaign Arkitekt/campaignarkitekt.com/script/rails:10:in `require'
    from /Users/Merrick/Work/Arkitekt/Projects/Campaign Arkitekt/campaignarkitekt.com/script/rails:10
    
  • Petros Amiridis

    Petros Amiridis March 1st, 2010 @ 05:38 PM

    I am not sure it's the best way, but until the bug is resolved I do the following as a workaround:

    I go to script/rails file and add the following lines right after the first two lines:

    
    +require "fileutils"
    +FileUtils.mkdir_p 'tmp'
    +FileUtils.mkdir_p 'tmp/cache'
    +FileUtils.mkdir_p 'tmp/pids'
    +FileUtils.mkdir_p 'tmp/sessions'
    +FileUtils.mkdir_p 'tmp/sockets'
    
  • José Valim

    José Valim March 3rd, 2010 @ 08:47 AM

    • Assigned user set to “Yehuda Katz (wycats)”
    • Milestone cleared.
  • Ravinder Rana

    Ravinder Rana March 30th, 2010 @ 07:10 PM

    Attached is a patch to fix the issue. Basically, what we need to do is create the "tmp" directories before
    starting the server, the way it was done in rails 2.3.*

    There's no tests for this yet as i was not able to figure out where the existing test class for "railties/lib/rails/commands/server.rb" is :( let me know if it exist, i'll add the necessary tests.

  • José Valim

    José Valim March 30th, 2010 @ 11:18 PM

    • State changed from “new” to “open”
    • Assigned user changed from “Yehuda Katz (wycats)” to “José Valim”

    Ravinder, thanks for the patch! Before applying it, I need to ask you to do two changes:

    1) Can you please create the patch using git format-patch? This will keep you as patch author. More information in the contributors guide: https://rails.lighthouseapp.com/projects/8994/sending-patches

    2) RAILS_ROOT is deprecated. So instead of:

    File.join(RAILS_ROOT, 'tmp', dir_to_make)
    

    You could do:

    Rails.root.join('tmp', dir_to_make)
    

    That's it. Unfortunately there are no tests for rails/commands/server.

  • Ravinder Rana

    Ravinder Rana March 31st, 2010 @ 11:04 AM

    Creating a new patch as per Jose suggestions.

  • Repository

    Repository March 31st, 2010 @ 03:05 PM

    • State changed from “open” to “resolved”

    (from [db28d407f76a790a31e27bf51560e23425dd6944]) Create tmp directories if required before starting server [#3907 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/db28d407f76a790a31e27bf51560e2...

  • José Valim

    José Valim March 31st, 2010 @ 03:06 PM

    Thanks for the patch Ravinder!

  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:01 PM

    • Milestone set to 3.0.2
    • Importance changed from “” to “High”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Tags

Referenced by

Pages