gpt4 book ai didi

javascript - EOF 错误 javascript_include_tag Rails 4

转载 作者:IT王子 更新时间:2023-10-29 01:26:26 26 4
gpt4 key购买 nike

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

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 文件中可能值得注意的一件事:

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

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

编辑:将我的浏览器指向 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>'

最佳答案

如果您仍然有旧的存储库,那么您可以运行 bundle exec rake tmp:clear。我想这会解决问题。

关于javascript - EOF 错误 javascript_include_tag Rails 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18392846/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com