mar*_*ion 24 ruby-on-rails sprockets asset-pipeline ruby-on-rails-5
我刚刚将我的应用程序升级Rails 4.2.7
为Rails 5.0.0.1
.我使用RailsDiff来确保我已经覆盖了所有内容,我相信我做到了.到目前为止,一切都运行良好,直到加载我的应用程序.
现在我看到这个错误:
Sprockets::ArgumentError at /
require_tree argument must be a directory
Run Code Online (Sandbox Code Playgroud)
这是我的application.css
:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope. *
*= require_tree .
*= require_self
*/
Run Code Online (Sandbox Code Playgroud)
这是我的 application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
这就是服务器日志的样子:
Started GET "/" for ::1 at 2016-09-02 09:08:19 -0500
ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
User Load (1.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 2], ["LIMIT", 1]]
Processing by ProfilesController#index as HTML
Rendering profiles/index.html.erb within layouts/application
Profile Load (1.6ms) SELECT "profiles".* FROM "profiles"
Rendered profiles/index.html.erb within layouts/application (45.8ms)
Completed 500 Internal Server Error in 367ms (ActiveRecord: 6.3ms)
DEPRECATION WARNING: #original_exception is deprecated. Use #cause instead. (called from initialize at /.rvm/gems/ruby-2.3.1@myapp/gems/better_errors-2.1.1/lib/better_errors/raised_exception.rb:7)
DEPRECATION WARNING: #original_exception is deprecated. Use #cause instead. (called from initialize at /.rvm/gems/ruby-2.3.1myapp/gems/better_errors-2.1.1/lib/better_errors/raised_exception.rb:8)
Sprockets::ArgumentError - require_tree argument must be a directory:
sprockets (3.7.0) lib/sprockets/directive_processor.rb:182:in `rescue in block in process_directives'
sprockets (3.7.0) lib/sprockets/directive_processor.rb:179:in `block in process_directives'
sprockets (3.7.0) lib/sprockets/directive_processor.rb:178:in `process_directives'
Run Code Online (Sandbox Code Playgroud)
我没有使用任何类型的插件.这是一个相当简单/香草的应用程序.唯一的样式是默认的scaffold.scss
.
可能是什么导致了这个?
mar*_*ion 53
我终于弄明白了.因为我正在进行升级,RailsDiff没有告诉我,我错过了一些东西.
因此错误消息不正确,但是,我忘记做的是创建一个空目录.
在我app/assets/javascripts/cable.js
,我有以下内容:
//= require_tree ./channels
Run Code Online (Sandbox Code Playgroud)
但是,我忘了实际创建该文件夹.
所以要解决这个问题,我所要做的就是在app/assets/javascripts
被调用的内部创建一个空文件夹channels
.另外,因为git忽略空目录,在新创建的文件夹中,我还必须创建一个名为的空文件.keep
.
所以,一旦我做了以下,一切都像一个魅力:
app/assets/javascripts/channels
app/assets/javascripts/channels/.keep
现在一切都很完美.
面临类似的问题,但不是同一个问题。Rails 从 5.2.3 升级到 5.2.4.1 期间
$ rails s
回到:
Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
But did not, please create this file and use it to link any assets that need to be rendered by your app:
Example:
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
and restart your server
Run Code Online (Sandbox Code Playgroud)
好的,按照说明,manifest.js
用上面的内容创建,然后
$ rails s
回到:
Sprockets::ArgumentError at / link_tree argument must be a directory
Run Code Online (Sandbox Code Playgroud)
使固定:
.keep
在新文件夹中创建空文件images
(该文件可能在过去的某个时刻被删除,没有任何直接后果):
app/assets/images/.keep
使用rails new appname --skip-keeps
标志时会出现问题- 它仍然试图要求不存在的文件,并且通常是 Rails 团队方面的错误。
这只是解决所描述问题的不同方法,主要解决方案完美无缺;
app/assets/javascripts/cable.js
//= require_tree ./channels
从第 6 行删除自动生成保持您的代码库尽可能小,有人.keep
出于某种原因跳过了s。
归档时间: |
|
查看次数: |
7656 次 |
最近记录: |