17

我收到一个错误,我似乎无法找出原因:

EOF Error end of file reached 

从 /app/views/layouts/application.html.erb 调用,第 6 行:

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

在 ruby​​ 中,EOF 错误是 IOError 的子类,由到达文件末尾的 IO 操作引发。

以下是我迄今为止发现的一些内容:

使用:

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

...或者...

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

甚至通过 javascript_include_tag 列出单个 js 文件以消除 EOF 错误。

我认为这可能是由一些 sprockets 指令引起的,所以我删除了 application.js 中的所有指令。这并没有改变什么。

运行 rake assets:precompile 也给了我:

rake aborted!
end of file reached 

在 app/assets/javascripts 目录上运行git diff会显示我最近编辑的 .js 文件中可能需要注意的 1 件事:

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

那个“文件末尾没有换行符”位......我以前从未见过。但是,我只是在同一个文件的末尾插入了一个换行符并提交了更改,并且该注释现在从差异中消失了。

编辑:将我的浏览器指向 localhost:3000/assets/application.js 给了我这个:

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

我完全被难住了,一整天都在尝试调试这个。为什么会出现这个错误?这是我运行 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>'
4

4 回答 4

58

如果您仍然有旧的仓库,那么您可以运行bundle exec rake tmp:clear. 我认为那会解决它。

于 2013-08-29T18:41:10.863 回答
4

尝试删除您的本地项目目录并签出新副本。

我今天经历了一次中止的 Rails 服务器启动,这可能使我的系统处于不一致的状态,并导致了与您遇到的完全相同的错误。ruby 2.0.0-p0 段错误停止了我的 rails 服务器启动,之后由于上述错误我无法加载任何页面。

不幸的是,我不确定是什么导致了最初的失败。幸运的是,我不必再处理它了!

于 2013-08-26T18:34:17.837 回答
2

使用以下命令清理临时文件可修复此问题:

rake tmp:clear
于 2015-02-12T13:14:06.330 回答
0

如果您在 Windows 上遇到此问题,请尝试进入您的Gemfile.lock文件并手动将值更改coffee-script-source1.8.0(我的开始为1.9.1.1)。无论出于何种原因,关于较新版本的某些东西都不能很好地发挥作用。

于 2015-11-18T03:25:57.407 回答