"require_tree argument must be a directory" rails 3.1.1 precompile assets

18,298

Solution 1

I ran into this exact same issue you described. My production server was Heroku (cedar stack). In my case the issue was that one of my:

require_tree ./mobile

Was pointing to a legitimate directory, but this directory had no files. On dev it didn't matter but something about the production setup was resulting in the error, “require_tree argument must be a directory”.

Hopefully that helps.

Solution 2

require_tree must be given an existing folder, but git doesn't store empty folders, therefore when you deploy on heroku, those empty folders doesn't exist.

one trick is to add an empty .keep file to the folders you want to keep.

Share:
18,298
evets
Author by

evets

Updated on July 14, 2022

Comments

  • evets
    evets almost 2 years

    I've been round and round here with trying to get the assets to pre-compile on my production server (straightforward ubuntu install with ruby 1.9.2 and Rails 3.1.1, and tried 3.1.2RC with the new sprockets 2.10 as well).

    "require_tree argument must be a directory". I've seen other issues related to this on stack but the situation isn't exactly the same and none of the proposed solutions have helped – like create a stub file in the sub folder, then reference only relatively at that point. No luck.

    And to top it off, of course this works perfectly on all development machines (mac's but with identical configs, even matching gem for gem), in production env.

    Here is my /app/assets/javascript/application.js:

    //= require ../../views/app/manifest
    //= require_self
    

    Not much to it. Basically just pointing to the real manifest file for the app area (yeah, not exactly boxed vanilla Rails but...)

    Here is my stub manifest in my views/admin (/views/app/manifest.coffee.js):

    # = require ./app
    # = require_tree ./models
    # = require_directory ./views <- or using require_directory, either would work fine.
    

    Like I said, in dev env, no issues at all. The asset pipeline compiles on the fly and everything is great. Running, rake assets:precompile on the dev machine, no issues either.

    I send it up to the production machine and run the exact same code and I get:

    require_tree argument must be a directory

    There has to be some tiny tiny difference here that I'm just not seeing. Any help would be much appreciated!