Broken config/lighttpd.conf? (in EdgeRails)


#1

I’m using Mac OS X, I installed Ruby/Rails/lighttpd/etc via the
instructions from hivelogic. I think I’ve found a bug with
EdgeRails, but I’m not sure how to submit it (and maybe I’m doing
something wrong and someone can just point me in the right
direction). Anyway I thought I’d report it just in case it is a bug.

I’ve downloaded the EdgeRails tree (revision 4007 using /usr/local/ bin/svn co http://dev.rubyonrails.org/svn/rails/trunk rails) and
built a new rails app (using /usr/local/bin/ruby rails/railties/bin/ rails ~/Sites/test2)

I then cd to the test2 directory, and rake freeze_edge (I also have
GemRails installed which I can’t change yet). When I try to start
the lighty server (using start/server) it tries to copy lighttpd.conf
from my vendor directory (as it should). Unfortunately, rake freeze_edge doesn’t put “rails/railties/configs/lighttpd.conf” into
my vendor directory. So script/server barfs:

—%<—

=> Booting lighttpd (use ‘script/server webrick’ to force WEBrick)
=> config/lighttpd.conf not found, copying from /Users/ptb/Sites/
Rails/test2/vendor/rails/railties/configs/lighttpd.conf
/usr/local/lib/ruby/1.8/fileutils.rb:1182:in stat': No such file or directory - /Users/ptb/Sites/Rails/test2/vendor/rails/railties/ configs/lighttpd.conf (Errno::ENOENT) from /usr/local/lib/ruby/1.8/fileutils.rb:1182:inlstat’
from /usr/local/lib/ruby/1.8/fileutils.rb:1160:in stat' from /usr/local/lib/ruby/1.8/fileutils.rb:1242:incopy_file’
from /usr/local/lib/ruby/1.8/fileutils.rb:459:in copy_file' from /usr/local/lib/ruby/1.8/fileutils.rb:383:incp’
from /usr/local/lib/ruby/1.8/fileutils.rb:1377:in
fu_each_src_dest' from /usr/local/lib/ruby/1.8/fileutils.rb:1393:infu_each_src_dest0’
from /usr/local/lib/ruby/1.8/fileutils.rb:1375:in
fu_each_src_dest' from /usr/local/lib/ruby/1.8/fileutils.rb:382:incp’
from ./script/…/config/…/vendor/rails/railties/lib/
commands/servers/lighttpd.rb:40
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:21:in require' from ./script/../config/../vendor/rails/activesupport/lib/ active_support/dependencies.rb:149:inrequire’
from ./script/…/config/…/vendor/rails/railties/lib/
commands/server.rb:34
from script/server:3

—%<—

Unfazed, I tried copying the entire rails tree directly into my
vendor directory (/usr/local/bin/svn co http://dev.rubyonrails.org/ svn/rails/trunk vendor/rails). That should fix the problem of the
missing lighttpd.conf file. Well it does, but it doesn’t replace
“CWD” in lighttpd.conf with the current directory, so even though
lighttpd.conf has been copied, it doesn’t point to the correct
directory.

—%<—

=> Booting lighttpd (use ‘script/server webrick’ to force WEBrick)
=> config/lighttpd.conf not found, copying from /Users/ptb/Sites/
Rails/test/vendor/rails/railties/configs/lighttpd.conf
=> Rails application started on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)
Undefined config variable: var.CWD
2006-03-21 11:25:28: (configfile.c.800) source: config/lighttpd.conf
line: 8 pos: 43 parser failed somehow near here: +
Exiting

—%<—

What I’ve been doing is opening the file with vi then doing search
and replace with CWD with the correct path, but that’s tedious and
not the way it should be. I think it’s script/server that should do
the substitutions after it copies the file, but it’s currently not
doing that. What do you think, bug?

  • Peter

#2

Hi Peter,

I had the same problem. Here’s my simple test, a description of the
problem, and what I did to fix it. There may be a reason why the
configs dir is not checked out but I don’t know why that is.

I have rails 1.0 installed. After updating rake I tried the following:

rails editor
cd editor
rake freeze_edge
script/server

which produced an error when it couldn’t find the file:

vendor/rails/railties/configs/lighttpd.conf

to copy into config/lighttpd.conf

Problem:

The freeze_edge task in framework.rake only checks out the lib
directories in each framework but
vendor/rails/railties/lib/commands/servers/lighttpd.rb is looking for
vendor/rails/railties/configs/lighttpd.conf.

I patched my Rails 1.0 rake freeze_edge task
(rails-1.0.0/lib/tasks/framework.rake):

for framework in %w( railties actionpack activerecord actionmailer
activesupport actionwebservice )
mkdir_p “vendor/rails/#{framework}”
system “svn export
http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib
vendor/rails/#{framework}/lib #{revision_switch}”
end
end

By inserting the following line after line 46:

for framework in %w( railties actionpack activerecord actionmailer
activesupport actionwebservice )
mkdir_p “vendor/rails/#{framework}”
system “svn export
http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib
vendor/rails/#{framework}/lib #{revision_switch}”
end
system “svn export
http://dev.rubyonrails.org/svn/rails/trunk/railties/configs
vendor/rails/railties/configs #{revision_switch}”
end

After rm -rf vendor/rails/ and rake freeze_edge my script/server
command worked.


#3

So, rake freeze_edge runs from rails-1.0.0 and not vendor/rails?

Is that what everyone should expect is the correct behavior for
rake? I would have thought that rake would use vendor/rails if it
existed, and gemrails only if vendor/rails wasn’t available (in which
case http://dev.rubyonrails.org/ticket/4047 would have fixed this
problem).

  • Peter

#4

Undefined config variable: var.CWD
means your (and my) lighttpd doesn’t support mod_cml and I guess edge
rails assumes you have it.
I’m on Mac OS X and I haven’t found an easy way to compile lighty with
mod_cml yet. The lighttpd +cml darwinport is broken, I think, because
the lua port doesn’t generate a pkgconfig file. I’d file a bug if I
had any idea who’s responsibility it is :slight_smile:
I’d love to hear a non-darwinports way of installing lighty with
mod_cml (on OSX x86).

thanks,
-Sam


#5

*** Rails 1.1 will require lighttpd 1.4.11 (if you’re using lighttpd)



I submitted a ticket on this issue: http://dev.rubyonrails.org/ticket/
4344 and DHH said that “Yes, Rails 1.1 will assume that you have
1.4.11 or above. You’re still free to use 1.4.8, but it’ll require
that you alter your lighttpd.conf accordingly.” (See the ticket for
a workaround.)

I’ve built lighttpd 1.4.11 on Mac OS X 10.4.5 using the instructions
from hivelogic (1) (changing the version number obviously) and “CWD”
is built into 1.4.11. Everyone will need to upgrade to 1.4.11 if
they want to run Rails 1.1 apps.

So, rake freeze_edge runs from rails-1.0.0 and not vendor/rails?

This is my statement, so I’ll give myself a big “DUH”. rake freeze_edge copies the EdgeRails trunk into vendor/rails so
obviously rake is going to use “rails-1.0.0/lib/tasks/framework.rake”
for it’s configuration (vendor/rails doesn’t exist until it’s run!).
Unfortunately, rails-1.0 didn’t copy vendor/rails/railties/configs/
lighttpd.conf from the trunk into vendor/rails. (This was fixed with
http://dev.rubyonrails.org/ticket/4047)

Therefore, in order to get a complete checkout of EdgeRails into
vendor/rails is to actually run rake freeze_edge twice. The
first time it uses the config from rails-1.0.0 (your gem install),
the second time it runs the config from vendor/rails which correctly
copies lighttpd.conf into your app.

  • Peter

(1) - http://hivelogic.com/articles/2005/12/01/
ruby_rails_lighttpd_mysql_tiger