use_in_file_templates! not working

36 views
Skip to first unread message

seaofclouds

unread,
Nov 4, 2008, 4:47:36 PM11/4/08
to sinatrarb
i thought i'd put together a fun little sinatra app to capture the
rainy day "meh" feeling on twitter, but haven't been able to get it up
and running on my server (ubuntu hardy,thin,rack,nginx).

since i do have other sinatra apps that are running successfully on
the same server, i i shrunk this sinatra application (http://
gist.github.com/21958) down to the bare minimum, and determined that
the problem is with use_in_file_templates!

-------

$:.unshift File.dirname(__FILE__) + '/sinatra/lib'
require 'rubygems'
require 'sinatra'

get '/' do
haml :index
end

use_in_file_templates!

__END__

@@ layout
= yield

@@ index
%div.title Hello world!!!!!

---
i have tried running the application as ruby meh.rb, and receive the
following error:
---

Params:

{}

Errno::ENOENT - No such file or directory - /home/deploy/meh/sinatra/
views/index.haml

../sinatra/sinatra/lib/sinatra.rb:568:in `read_template_file'
../sinatra/sinatra/lib/sinatra.rb:555:in `resolve_template'
../sinatra/sinatra/lib/sinatra.rb:530:in `render'
../sinatra/sinatra/lib/sinatra.rb:610:in `haml'
../sinatra/meh.rb:6
../sinatra/sinatra/lib/sinatra.rb:1263:in `instance_eval'
../sinatra/sinatra/lib/sinatra.rb:1263:in `dispatch'
../sinatra/sinatra/lib/sinatra.rb:1257:in `catch'
../sinatra/sinatra/lib/sinatra.rb:1257:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rack-0.4.0/lib/rack/commonlogger.rb:20:in
`call'
/usr/lib/ruby/gems/1.8/gems/rack-0.4.0/lib/rack/commonlogger.rb:20:in
`_call'
/usr/lib/ruby/gems/1.8/gems/rack-0.4.0/lib/rack/commonlogger.rb:13:in
`call'
../sinatra/sinatra/lib/sinatra.rb:1236:in `call'
../sinatra/sinatra/lib/sinatra.rb:1181:in `run_safely'
../sinatra/sinatra/lib/sinatra.rb:1181:in `synchronize'
../sinatra/sinatra/lib/sinatra.rb:1181:in `run_safely'
../sinatra/sinatra/lib/sinatra.rb:1234:in `call'
../sinatra/sinatra/lib/sinatra/rack/handler/mongrel.rb:60:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
`process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
`process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
`initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
`initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
../sinatra/sinatra/lib/sinatra/rack/handler/mongrel.rb:33:in `run'
../sinatra/sinatra/lib/sinatra.rb:117:in `run'
../sinatra/sinatra/lib/sinatra.rb:1471
../sinatra/meh.rb:9


---
when running the sinatra app over thin and rack, i receive the
following error:
---

"Internal Server Error"

---
in my thin log, i see:
---

>> Writing PID to /home/deploy/meh/server/thin.7655.pid
/home/deploy/meh/sinatra/sinatra/lib/sinatra.rb:21: warning: already
initialized constant POST_TUNNEL_METHODS_ALLOWED
/home/deploy/meh/sinatra/sinatra/lib/sinatra.rb:63: warning: already
initialized constant VERSION
/home/deploy/meh/sinatra/sinatra/lib/sinatra.rb:133: warning: already
initialized constant SPLAT
/home/deploy/meh/sinatra/sinatra/lib/sinatra.rb:228: warning: already
initialized constant DEFAULT_SEND_FILE_OPTIONS
/home/deploy/meh/sinatra/sinatra/lib/sinatra.rb:902: warning: already
initialized constant FORWARD_METHODS
>> Thin web server (v1.0.0 codename That's What She Said)
>> Maximum connections set to 1024
>> Listening on 127.0.0.1:7655, CTRL+C to stop
127.0.0.1 - - [04/Nov/2008 21:39:52] "GET / HTTP/1.0" 500 30 0.0485

--------------
if i avoid "use_in_file_templates!" and instead put dummy text inside:
---

get '/' do
"this works"
end

--------------

any tips, solutions?

seaofclouds

unread,
Nov 4, 2008, 4:59:54 PM11/4/08
to sinatrarb
i should add that, oddly enough the other apps use
"use_in_file_templates!" and work just fine. what gives?

Simon Rozet

unread,
Nov 4, 2008, 5:00:07 PM11/4/08
to sina...@googlegroups.com
On Tue, Nov 4, 2008 at 10:47 PM, seaofclouds <twirlin...@gmail.com> wrote:
>
> i thought i'd put together a fun little sinatra app to capture the
> rainy day "meh" feeling on twitter, but haven't been able to get it up
> and running on my server (ubuntu hardy,thin,rack,nginx).
>
> since i do have other sinatra apps that are running successfully on
> the same server, i i shrunk this sinatra application (http://
> gist.github.com/21958) down to the bare minimum, and determined that
> the problem is with use_in_file_templates!

looks this is a line-ending character problem. I can't look at it right now
but switching to LF (UNIX) line-ending char should fix the problem for now.

I created a new bug:
http://sinatra.lighthouseapp.com/projects/9779-sinatra/tickets/45-use_in_file_template-fails-with-crlf

--
Simon Rozet -- <si...@rozet.name>

seaofclouds

unread,
Nov 4, 2008, 6:14:02 PM11/4/08
to sinatrarb
LF was it, exactly. thanks for your quick response, simon and blake.

it may be a result of gist, or pasting into gist.

via twitter, i've let @defunkt know, maybe he has some insight too...

--

On Nov 4, 2:00 pm, "Simon Rozet" <si...@rozet.name> wrote:
> On Tue, Nov 4, 2008 at 10:47 PM, seaofclouds <twirlingbubb...@gmail.com> wrote:
>
> > i thought i'd put together a fun little sinatra app to capture the
> > rainy day "meh" feeling on twitter, but haven't been able to get it up
> > and running on my server (ubuntu hardy,thin,rack,nginx).
>
> > since i do have other sinatra apps that are running successfully on
> > the same server, i i shrunk this sinatra application (http://
> > gist.github.com/21958) down to the bare minimum, and determined that
> > the problem is with use_in_file_templates!
>
> looks this is a line-ending character problem. I can't look at it right now
> but switching to LF (UNIX) line-ending char should fix the problem for now.
>
> I created a new bug:http://sinatra.lighthouseapp.com/projects/9779-sinatra/tickets/45-use...

Harry Vangberg

unread,
Nov 4, 2008, 6:15:03 PM11/4/08
to sina...@googlegroups.com
Bloody Gist. It's when copy/pasting from gist. Had issues alike that a
billion times.

2008/11/5 seaofclouds <twirlin...@gmail.com>:

Ryan Tomayko

unread,
Nov 6, 2008, 1:31:51 PM11/6/08
to sinatrarb
On Nov 4, 3:14 pm, seaofclouds <twirlingbubb...@gmail.com> wrote:
> LF was it, exactly. thanks for your quick response, simon and blake.
>
> it may be a result of gist, or pasting into gist.

IIRC, most browsers convert LF to CR+LF when submitting form data
(with the exception of <input type='file'>) so there might not be an
easy way to fix this.

I suppose we have IE to thank for that.

Ryan
Reply all
Reply to author
Forward
0 new messages