2

I'm trying to push my app to Heroku.

All works good, until the last command git push heroku master

The end of the work is:

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

It ends with the message Precompiling assets failed

I guess it is looking for a directory that is missing in my assets (css or javascript). But I don't know which directory.

Any help would be much appreciated.

EDIT

My file cable.js looks like this :

//= require action_cable
//= require_self
//= require_tree ./channels
(function() {
  this.App || (this.App = {});
  App.cable = ActionCable.createConsumer();
}).call(this);

Whether I added //= require_tree or whether I commented everything out, didn't change anything.

thiebo
  • 1,339
  • 1
  • 17
  • 37
  • 2
    Possible duplicate of [require\_tree argument must be a directory in a Rails 5 upgraded app](https://stackoverflow.com/questions/39294859/require-tree-argument-must-be-a-directory-in-a-rails-5-upgraded-app) – viktorianer Mar 20 '18 at 09:55

2 Answers2

2

What does line 6 of your cable.js file look like?

Are you using Action Cable?

In your app/assests/javascripts/cable.js file, the //= require_tree statement must be followed by a directory, like so:

//= require_tree ./channels

And then you'd have your channel files in the directory at app/assets/javascripts/channels

If you're not using Action Cable, then just comment everything out and your push should succeed.

EDIT:

You should delete your cable.js file. And comment out all the code in app/channels/application_cable/channel.rb and app/channels/application_cable/connection.rb

That has allowed me to push a Rails 5 project to Heroku without an assets error.

James Milani
  • 1,921
  • 2
  • 16
  • 26
  • I didn't know what Action Cable was. I have updated the question to answer. It still doesn't work. – thiebo Jan 21 '17 at 21:00
  • I removed cable.js and commented the 2 files out completely and I still get the same error (i.e. ligne 6 of cable.js, which doesn't exist any more). I guess I will completely redo the deploy of my app. – thiebo Jan 21 '17 at 21:11
  • And you still get the same error even though the file doesn't exist? That doesn't make sense. Please post the new error. Also, make sure to re-commit the code to Github before pushing. – James Milani Jan 21 '17 at 21:16
0

I don't think you should remove or comment out something. But Heroku needs an empty ./channels directory, with you don't have right now. Just add an empty file, e.g. .keep to your ./channels directory, commit it and push to Heroku.

See: require_tree argument must be a directory in a Rails 5 upgraded app

Athul Nath
  • 2,536
  • 1
  • 15
  • 27
viktorianer
  • 92
  • 2
  • 5