17

I'm getting an error I can't seem to figure out the cause of:

EOF Error end of file reached 

called from /app/views/layouts/application.html.erb, line 6:

<%= javascript_include_tag "application", "data-turbolinks-track" => true %>

In ruby, an EOF error is a subclass of IOError, and is raised by an IO operation reaching the end of a file.

Here's some of what I've found out so far:

Using:

<%= javascript_include_tag :defaults, "data-turbolinks-track" => true %>

...or...

<%= javascript_include_tag :all, "data-turbolinks-track" => true %>

or even listing out the individual js files via javascript_include_tag work to remove the EOF error.

I thought this might be caused by some sprockets directives, so I deleted all the directives in application.js. This did not change anything.

Running rake assets:precompile also gives me:

rake aborted!
end of file reached 

Running git diff on the app/assets/javascripts directory shows 1 thing that may be of note in a .js file I had been editing recently:

+$(document).on('ready page:load', function() {
+
+     // some code I had written
+
+});
\ No newline at end of file

That "no newline at end of file" bit... I have never seen that before. However, I just inserted a newline at the end of the same file and committed the change, and that comment is now gone from the diff.

EDIT: Pointing my browser to localhost:3000/assets/application.js gives me this:

throw Error("EOFError: end of file reached")

I am thoroughly stumped and have been trying to debug this for the entire day. Why is this error occurring? Here is the stacktrace from when I run rake assets:precompile:

rake aborted!
end of file reached
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0.rc2/lib/active_support/core_ext/marshal.rb:6:in `load'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0.rc2/lib/active_support/core_ext/marshal.rb:6:in `load_with_autoloading'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/cache/file_store.rb:19:in `block in []'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/cache/file_store.rb:19:in `open'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/cache/file_store.rb:19:in `open'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/cache/file_store.rb:19:in `[]'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/caching.rb:14:in `cache_get'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/caching.rb:84:in `cache_get_hash'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/caching.rb:54:in `cache_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:93:in `build_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:287:in `find_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:61:in `find_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/bundled_asset.rb:37:in `init_with'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/asset.rb:24:in `from_hash'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/caching.rb:54:in `cache_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:93:in `build_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:287:in `find_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:61:in `find_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:211:in `block in find_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:257:in `benchmark'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:210:in `find_asset'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:119:in `block in compile'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:118:in `each'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:118:in `compile'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:60:in `block (3 levels) in define'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/rake/sprocketstask.rb:146:in `with_logger'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:59:in `block (2 levels) in define'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/Users/kevinyoung/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
1
  • I started experiencing this same issue in the last few days. I did no rails development over the weekend but did use nvm to install latest versions of node and npm coffee-script packages. It doesn't make sense to me that this would have an impact on my rails application but maybe it does? Commented Aug 26, 2013 at 15:26

4 Answers 4

58
+50

If you still have your old repo lying around, then you can run bundle exec rake tmp:clear. I reckon that'll fix it.

Sign up to request clarification or add additional context in comments.

4 Comments

Unfortunately I deleted my old repository so I can't test this out. Hopefully this will be useful to other people with the same error though.
To elaborate on this answer: The cause seems to be that the assets cache in the tmp folder is corrupted. I believe this occurs if the Rails process dies at the wrong moment. When you try to reboot the server, run test, etc, the asset pipeline tries to read the corrupted cache, and it chokes. Which is why clearing the cache solves the problem.
Jesus Christ, thank god it was something this simple. I spent 2 hours combing through commits trying to find the sneaky bug. Geez!
Sometimes doing this stuff is just so frustrating. Thanks for this solution!
4

Try deleting your local project directory and checking out a fresh copy.

I experienced an aborted rails server startup today that perhaps left my system in an inconsistent state and resulted in the same exact error you were experiencing. A ruby 2.0.0-p0 segfault stopped my rails server startup, after which I could not load any pages due to the aforementioned error.

I do not know for sure what caused this original failure, unfortunately. Fortunately, I don't have to deal with it anymore on my end!

2 Comments

Yep, I tried that yesterday and it worked. I first tried reverting back to an earlier commit, but I was getting the same error, so I ran git clone https://github.com/mygithubusername/myrepo.git mynewrepo to clone into a new local directory and for some reason it started working.
Can anyone explain WHY this happened? I got the same problem this afternoon in work and thought the world had ended! Dont suppose either of you are using Twitter gem? Or perhaps Rack Timeout? They're the newest additions to my codebase that might have introduced this...
2

Cleaning up the temp files using the following command fixes this issue:

rake tmp:clear

Comments

0

If you're having this problem on Windows, try going into your Gemfile.lock file and manually changing the value of coffee-script-source to 1.8.0 (mine started as 1.9.1.1). Something about newer versions doesn't play nice for whatever reason.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.