rake assets:precompile undefined method directory?

2019-02-21 14:38发布

While trying to do an assets:precompile for a production website I've encountered this error for the first time.

 rake assets:precompile undefined method directory? for nil:NilClass

I have successfully updated the website and done a assets:precompile many times before.

The full example:

# RAILS_ENV=production rake assets:precompile --trace                        
/usr/local/rvm/gems/ruby-1.9.2-p290@pm/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/usr/local/rvm/gems/ruby-1.9.2-p290@pm/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
rake aborted!
undefined method `directory?' for nil:NilClass

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

I'm looking forward to someone's insight in this one, I've been racking my brain and Googling answers for hours.

3条回答
淡お忘
2楼-- · 2019-02-21 14:45

In my case, I had this issue when deploying an application in Heroku. And one of my files was symlinked to somewhere outside the GIT repository, so the file was not present int 'master'.

I then had to remove the symbolic link (rm .../file) then copy the original file (cp file1 .../file) and finally add it to the repository (git -a -m "Added a forgotten file")

查看更多
时光不老,我们不散
3楼-- · 2019-02-21 15:01

I had created a symbolic link to a non-existent file by mistake in the assets/javascript directory. Removing the link fixed the problem. Note that I do have other links in the assets directory so links in general are not a problem.

查看更多
成全新的幸福
4楼-- · 2019-02-21 15:06

This is what happens when the file system can't find one of the assets it thinks its supposed to precompile. This happened to me when my VM could not find one of the files in my shared folder (Weird VMware issue where it appeared in the directory listing but the file did not actually exist)

查看更多
登录 后发表回答