我正在尝试将我的应用推送到Heroku。
一切正常,直到最后一个命令git push heroku master
工作的结束是:
remote: Bundle complete! 23 Gemfile dependencies, 64 gems now installed.
remote: Gems in the groups development and test were not installed.
remote: Bundled gems are installed into ./vendor/bundle.
remote: Post-install message from httparty:
remote: When you HTTParty, you must party hard!
remote: Bundle completed (43.35s)
remote: Cleaning up the bundler cache.
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: I, [2017-01-21T18:38:23.836925 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/knacss-2fd9029d30582c6fdf840f44c8b929a84918ca5d13a17d95ff31500a7391ff3d.css
remote: I, [2017-01-21T18:38:23.837699 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/knacss-2fd9029d30582c6fdf840f44c8b929a84918ca5d13a17d95ff31500a7391ff3d.css.gz
remote: I, [2017-01-21T18:38:29.692584 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/froala_editor.min-bf21cc5709ba6b62dbaf6f8b39b9d555ca633fd92e99d0fdddbdfc893bbd5ec0.js
remote: I, [2017-01-21T18:38:29.693514 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/froala_editor.min-bf21cc5709ba6b62dbaf6f8b39b9d555ca633fd92e99d0fdddbdfc893bbd5ec0.js.gz
remote: I, [2017-01-21T18:38:30.081111 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/froala_editor.min-4f428c6899d37f6415063f547a9818c7665532ecdffa7a2ccae309183e516efe.css
remote: I, [2017-01-21T18:38:30.081876 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/froala_editor.min-4f428c6899d37f6415063f547a9818c7665532ecdffa7a2ccae309183e516efe.css.gz
remote: I, [2017-01-21T18:38:30.163071 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/froala_style.min-f464bc7ed28df7543569f0518d2522676230104c53afd6303a5519a60c001b36.css
remote: I, [2017-01-21T18:38:30.163506 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/froala_style.min-f464bc7ed28df7543569f0518d2522676230104c53afd6303a5519a60c001b36.css.gz
remote: I, [2017-01-21T18:38:30.167687 #1189] INFO -- : Writing /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/public/assets/plus-a4fd4a7a5f7c6877b6f60c21b804384d0613d5a7d14a66eb1a828672d211e600.png
remote: rake aborted!
remote: Sprockets::ArgumentError: require_tree argument must be a directory
remote: /tmp/build_da9cf4ff20889ce0ceb823aa131b35be/app/assets/javascripts/cable.js:6
以消息Precompiling assets failed
我猜它正在寻找我的资产(css或javascript)中缺少的目录。但我不知道哪个目录。
非常感谢任何帮助。
修改
我的文件cable.js看起来像这样:
//= require action_cable
//= require_self
//= require_tree ./channels
(function() {
this.App || (this.App = {});
App.cable = ActionCable.createConsumer();
}).call(this);
我是否添加了//= require_tree
或者我是否对所有内容进行了评论,并没有改变任何内容。
答案 0 :(得分:1)
你的cable.js文件的第6行是什么样的?
您使用的是Action Cable
吗?
在app/assests/javascripts/cable.js
文件中,//= require_tree
语句后面必须跟一个目录,如下所示:
//= require_tree ./channels
然后,您的频道文件位于app/assets/javascripts/channels
如果您没有使用Action Cable
,那么只需对所有内容进行评论,您的推送就应该成功。
编辑:
您应该删除cable.js
文件。并注释掉app/channels/application_cable/channel.rb
和app/channels/application_cable/connection.rb
这使我可以将Rails 5项目推送到Heroku而不会出现资产错误。
答案 1 :(得分:0)
我认为你不应该删除或评论某些内容。但是Heroku需要一个空的./channels
目录,你现在还没有。只需添加一个空文件,例如.keep到你的./channels
目录,提交它并推送到Heroku。
请参阅: require_tree argument must be a directory in a Rails 5 upgraded app