Подтвердить что ты не робот

Аргумент require_tree должен быть каталогом в обновленном приложении Rails 5

Я только что обновил свое приложение с Rails 4.2.7 до Rails 5.0.0.1. Я использовал RailsDiff, чтобы убедиться, что все покрыто, и я полагаю, что сделал. Пока все работает до загрузки моего приложения.

Теперь я вижу эту ошибку:

Sprockets::ArgumentError at /
require_tree argument must be a directory

Это мое 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 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
 */

Это мое 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 vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It 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 .

Это выглядит так:

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/[email protected]/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'

Я не использую никаких плагинов. Это довольно простое/ванильное приложение. Единственный стиль - по умолчанию scaffold.scss.

Что может быть причиной этого?

4b9b3361

Ответ 1

Я наконец-то понял. Поэтому, поскольку я делаю обновление, RailsDiff не сказал мне, что я что-то упустил.

Поэтому сообщение об ошибке было неверным, однако я забыл сделать это, чтобы создать пустой каталог.

В моем app/assets/javascripts/cable.js меня было следующее:

//= require_tree ./channels

Однако я забыл создать эту папку.

Поэтому, чтобы исправить это, все, что мне нужно было сделать, это создать пустую папку в app/assets/javascripts называемую channels. Кроме того, поскольку git игнорирует пустые каталоги, внутри этой вновь созданной папки мне также пришлось создать пустой файл с именем .keep.

Поэтому, как только я сделал следующее, все работало как шарм:

  • Создать папку: app/assets/javascripts/channels
  • Создайте пустой файл в этой папке: app/assets/javascripts/channels/.keep

Теперь все работает отлично.