0

I am currently troubleshooting an issue with precompiling of asset pipeline and pushing it on the server. I am on rails 4.2.3 and ruby 2.2.0!

I precompile my assets with

RAILS_ENV=production bundle exec rake assets:precompile

and several files are created successfully, including the .sprockets-manifest-... file.

If i now try to push the app, it looks like the manifest file is not detected - my usual "assets cannot be compiled" issue (the reason why i am precompiling) occurs:

   Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   rake aborted!
   Mysql2::Error: Can't connect to MySQL server on '127.0.0.1' (111)

I am pretty sure this worked before but somehow - maybe by upgrading to rails 4.2.3, it fails now...

I appreciate any kind of help!

bgeek
  • 41
  • 4

2 Answers2

1

The usage of the sprockets gem with a version < 3.x fixes this issue for me.

With the new version (> 3.x), the name of the manifest file has changed to .sprockets-manifest-xxxx.json! Due to this the precompiled assets aren't recognized correctly. With the old version the old name .manifest-xxxx.json is used and the precompiled assets are recognized.

bgeek
  • 41
  • 4
0

The Add-on credentials, like databases are not available during build. On cloudControl you can detect if you're inside the build process by reading the BUILDPACK_RUNNING environment variable. See the Rails notes for an example.

The recommended way is to have the buildpack compile the assets during push. But you need to make sure Rails is not trying to connect to the database. Here's a related SO question regarding this.

If you want to precompile locally and this is not being detected I'd suggest to check if the manifest and the precompiled assets have been committed to the repository. A common pitfall is the .gitignore file.

Community
  • 1
  • 1
pst
  • 1,414
  • 11
  • 22
  • thanks for the quick reply. I already include `config.assets.initialize_on_precompile = false if ENV['BUILDPACK_RUNNING']`in my application.rb - but this is not working for rails 4 anymore! I also checked .gitignore and it doenst exclude e.g. the public folder. I know check the related question you posted and try to check this one... – bgeek Aug 13 '15 at 09:09
  • checked the answers and they don't apply unfortunately. is cloudcontrol also offering such a flag to make the env vars available during the build? what i am also wondering: it worked with rails 4.1 but stopped working with rails 4.2.3... :( – bgeek Aug 13 '15 at 09:19
  • No, we're not providing such a flag. So if it worked before and stopped with the Rails upgrade, something must have changed on the Rails side. Let me know if you find out. Curious to know. – pst Aug 13 '15 at 15:08
  • I reworked all my commits and identified the issue. With the new version of sprockets (3.x), the manifest file is now named .sprockets-manifest....json - i have the feeling that this is currently not supported by the buildpack. i now use sprockets 2.13.2 and the push works perfectly - my precompiled assets are identified - the manifest file has the "old" name manifest-....json. – bgeek Aug 13 '15 at 16:56
  • I see. Thanks for the info. You might want to answer your own question and then mark your own answer as the correct one. – pst Aug 14 '15 at 12:32
  • Will do. Thanks for the advice! – bgeek Aug 14 '15 at 16:39