title: Simplest possible rack app -> permission error
body: <p>Here's the program(1.rb):</p>
  
  <pre><code>require 'rack'
  
  my_rack = lambda { |env| [200, {}, ["Hello.  The time is: #{Time.now}"]] }
  handler = Rack::Handler::WEBrick
  
  handler.run(my_rack, :PORT =&gt; 12_500)
  </code></pre>
  
  <p>Here's the error:</p>
  
  <pre><code>~/ruby_programs$ ruby 1.rb 
  [2012-12-07 21:49:09] INFO  WEBrick 1.3.1
  [2012-12-07 21:49:09] INFO  ruby 1.9.3 (2012-04-20) [x86_64-darwin10.8.0]
  [2012-12-07 21:49:09] WARN  TCPServer Error: Permission denied - bind(2)
  [2012-12-07 21:49:09] WARN  TCPServer Error: Permission denied - bind(2)
  /Users/7stud/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/utils.rb:85:in `initialize': Permission denied - bind(2) (Errno::EACCES)
      from /Users/7stud/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/utils.rb:85:in `new'
      from /Users/7stud/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/utils.rb:85:in `block in create_listeners'
      from /Users/7stud/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/utils.rb:82:in `each'
      from /Users/7stud/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/utils.rb:82:in `create_listeners'
      from /Users/7stud/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:82:in `listen'
      from /Users/7stud/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:70:in `initialize'
      from /Users/7stud/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:45:in `initialize'
      from /Users/7stud/.rvm/gems/ruby-1.9.3-p194@programming/gems/rack-1.4.1/lib/rack/handler/webrick.rb:10:in `new'
      from /Users/7stud/.rvm/gems/ruby-1.9.3-p194@programming/gems/rack-1.4.1/lib/rack/handler/webrick.rb:10:in `run'
      from 1.rb:5:in `&lt;main&gt;'
  ~/ruby_programs$ 
  </code></pre>
  
  <p>Here's line 85 of ../webrick/utils.rb:</p>
  
  <pre><code>sock = TCPServer.new(ai[3], port)
  </code></pre>
  
  <p>If I replace the code in 1.rb with this:</p>
  
  <pre><code>require 'socket'
  
  server = TCPServer.new 12_000 # Server bind to port 2000
  
  loop do
    client = server.accept    # Wait for a client to connect
    client.puts "Hello !"
    client.puts "Time is #{Time.now}"
    client.close
  end
  </code></pre>
  
  <p>I don't get any errors, and if I enter the address:</p>
  
  <pre><code>http://localhost:12000/
  </code></pre>
  
  <p>in my browser, I get the expected output:</p>
  
  <pre><code>Hello !
  Time is 2012-12-07 18:58:15 -1000
  </code></pre>
  
  <p>The permissions for the .rvm directory:</p>
  
  <pre><code>~$ ls -al
  total 208
  ...
  drwxr-xr-x  30 7stud  staff   1020 Aug 31 11:09 .rvm
  ...
  </code></pre>