"No such file or directory" error thrown in cache.rb #109

Closed
briangonzalez opened this Issue May 8, 2012 · 9 comments

Projects

None yet

2 participants

@briangonzalez

I deployed a Nesta site to my CentOS server running Passenger/nginx and received the following error:

No such file or directory
/usr/local/rvm/gems/ruby-1.9.2-p318/gems/nesta-0.9.13/lib/nesta/cache.rb:34:in `cache'

I was also able to reproduce the error locally on OSX Lion on my Macbook Pro, which makes me think the issue is not limited
to subtlety on my server.

I can only reproduce the error using the bleeding edge version of Nesta (from Github) and setting cache: true in Nesta's config.yml.

Using Ruby 1.9.2 and Sinatra 1.3.

@gma
Owner
gma commented May 8, 2012

That clarifies it wonderfully, thanks.

@gma
Owner
gma commented May 9, 2012

I've tested caching on my localhost with shotgun, and it works fine. I used commit 858af82, but it's essentially identical from a caching perspective to the one you tried.

My suspicion is that your problem is to do with how Passenger is configured. When you reproduced the error locally was that with Passenger, or can you get it to break with shotgun or rackup too?

@gma
Owner
gma commented May 9, 2012

I was just reading the code in cache.rb. I think it might be passing an empty string to FileUtils.mkdir_p, which would suggest that in the environment you're running that code the path variable that's defined on line 33 doesn't have a directory prefix on it. From reading the code I can't see how this would occur, but it's not something that I'd expect to be passenger's "fault" as the path is determined from Rack's request.path_info method.

I'm tempted to just rip this cache.rb file out and replace it with sinatra-cache. It's long overdue anyway…

@gma
Owner
gma commented May 9, 2012

I've got a branch of Nesta that does away with this old caching code.

@briangonzalez - Would you be up for installing Nesta from that branch and taking the docs for a spin? I think it might solve your problem, especially given that you can easily override the path to the folder where cached files should be stored (with the cache_output_dir setting).

The commit with the docs in is here: gma/nestacms.com@9b559eb

The new version of Nesta is on the sinatra-cache branch of gma/nesta. You can install it with bundler by following these instructions: http://nestacms.com/docs/recipes/running-the-latest-code

Cheers!

:-)

@briangonzalez

Graham,

I've just been tinkering around a little with the sinatra-cache branch, and even on my production server running CentOS/Passenger, all seems to be working fine. Great work.

I found through some inspection over the past hour or so that my cache problems were in my config.ru file.

Since I was using others' examples as a starting point, I must have grabbed an old config.ru that was missing these lines:

use Rack::ConditionalGet
use Rack::ETag

require 'nesta/env'
Nesta::Env.root = ::File.expand_path('.', ::File.dirname(__FILE__))

Adding them solved my cache.rb issues.

I'll bang around more on the sinatra-cache branch tonight when I get home from work. Thanks Graham!

@briangonzalez

Perhaps we should close this issue?

@gma
Owner
gma commented May 9, 2012

Glad to hear it's working okay. In config.ru you won't need the two use lines unless you want to serve the HTTP headers they produce (they're a good idea, but unrelated to the caching problem). It's the missing root setting that explains why caching was breaking for you. Sinatra's settings.public_folder path is derived from the root folder, and that in turn was used inside cache.rb.

I'll close this issue once I've merged the sinatra-cache branch onto master; for the moment it's serving as a reminder in the 0.10.0 milestone of what I still want to get done before 0.10.0.

I'll merge the sinatra-cache branch and mark this as closed just before 0.10.0 so that the public docs are correct for anybody who wants to install Nesta from master in the meantime…

@gma
Owner

Note to self; before merging the sinatra-cache branch onto master make sure that it runs fine on sites that have defined their own routing actions that call the cache helper.

@gma
Owner

I've just removed lib/nesta/cache.rb, which solves this.

@gma gma closed this Oct 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment