Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

rails server fails when the tmp dir is missing

#3907

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.

Reported by Daniel Schierbeck · February 9th, 2010 @ 12:26 PM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: High

Activity

  1. Merrick
    Merrick

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

    February 27th, 2010 @ 06:28 AM

  2. Merrick
    Merrick

    => 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
    

    February 28th, 2010 @ 02:38 AM

  3. Petros Amiridis
    Petros Amiridis

    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'
    

    March 1st, 2010 @ 05:38 PM

  4. José Valim
    José Valim
    • Assigned user set to Yehuda Katz (wycats)
    • Milestone cleared.

    March 3rd, 2010 @ 08:47 AM

  5. Ravinder Rana
    Ravinder Rana

    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.

    March 30th, 2010 @ 07:10 PM

  6. José Valim
    José Valim
    • 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.

    March 30th, 2010 @ 11:18 PM

  7. Ravinder Rana
    Ravinder Rana

    Creating a new patch as per Jose suggestions.

    March 31st, 2010 @ 11:04 AM

  8. Repository
    Repository
    • State changed from open to resolved

    March 31st, 2010 @ 03:05 PM

  9. José Valim
    José Valim

    Thanks for the patch Ravinder!

    March 31st, 2010 @ 03:06 PM

  10. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to High

    October 15th, 2010 @ 11:01 PM