balder icon indicating copy to clipboard operation
balder copied to clipboard

Carrierwave 500s with "TypeError (no implicit conversion of nil into String)" when not on Heroku

Open rick opened this issue 11 years ago • 9 comments

I have a patch for this over in https://github.com/rick/balder/pull/1, specifically https://github.com/rick/balder/commit/81af9e7eedef9cf5a1d676213f888d6cfee40fa7 but I'm not clear on what the various concerns are (and whether this will break something for other folks).

I was seeing these sort of errors consistently:

TypeError (no implicit conversion of nil into String):
  app/controllers/photos_controller.rb:80:in `create'
  app/middleware/flash_session_cookie_middleware.rb:16:in `call'

The cache_dir method, which carrierwave seems to rely on, is only defined on Heroku + S3 configurations. It might actually need to be widened to be defined on all configurations, but I'm at least relying on S3 myself, so not sure.

rick avatar Nov 15 '13 03:11 rick

What server are you using? I would assume that the tmp directory would be writable otherwise (Heroku is sortof read-only).

espen avatar Nov 15 '13 14:11 espen

I'm on a digitalocean VPS for this installation, nginx + unicorn. The problem doesn't appear to be one of whether the temp directory is writeable, but rather one of the call to cache_dir from inside carrierwave blows up because there's no implementation of cache_dir in scope when using S3 but not using Heroku.

Would it be more appropriate to delegate to some other default in the non-Heroku case? I looked back at the history of the file and couldn't infer what the intent was when I tracked down the problem.

rick avatar Nov 15 '13 15:11 rick

I am seeing this problem problem when uploading on a private server as well as localhost.

Completed 500 Internal Server Error in 952ms

TypeError (can't convert nil into String):
  app/controllers/photos_controller.rb:82:in `create'
  app/middleware/flash_session_cookie_middleware.rb:16:in `call'

coneybeare avatar Nov 26 '13 15:11 coneybeare

And it works when setting the tmp dir? I'm a bit confused with the error message if the problem is not being able to store to disk.

espen avatar Nov 26 '13 15:11 espen

I am not sure that that is the problem, the error message is pretty vague. I am using s3 and not heroku, so maybe the cache_dir thing is the problem, maybe not. Is there anything you want me to experiment with to help debug?

coneybeare avatar Nov 26 '13 15:11 coneybeare

A full stack trace would help. Try changing this and see if that helps. https://github.com/rick/balder/commit/81af9e7eedef9cf5a1d676213f888d6cfee40fa7

espen avatar Nov 26 '13 15:11 espen

Not necessary. I just commented out the cache_dir method and it worked. So the problem is that you are returning false from the cache_dir method in file_uploader.rb when not using heroku instead of calling super or the default it expects (I think).

coneybeare avatar Nov 26 '13 15:11 coneybeare

Hm, spoke too soon. Worked locally, but not on the remote server.

coneybeare avatar Nov 26 '13 15:11 coneybeare

Sorry for the smap, twas a caching issue. This fix works for me both locally and on my remote non-heroku server with s3

coneybeare avatar Nov 26 '13 16:11 coneybeare