Comments (19)
The problem will have been that your Rakefile will have not been able to load.
So when checking if the rake task is defined, it would have bombed out.
I would suggest instead that an environment variable saying that assets should be compiled be added, that way the compilation is always attempted and will not silently fail.
from heroku-buildpack-ruby.
We'll look into adding a way to show rake failing here because of loading issues.
from heroku-buildpack-ruby.
Hi, I'm working on trying to make this better. I've come up with this: https://github.com/heroku/heroku-buildpack-ruby/tree/asset_pipeline_rake
@bcardarella @zapnap can you give me a repro case or test out that branch?
You can try it by adding the BUILDPACK_URL
to your app.
heroku config:add BUILDPACK_URL=git://github.com/heroku/heroku-buildpack-ruby.git#asset_pipeline_rake
from heroku-buildpack-ruby.
why not have rake with with --trace the first go-around? It seems running it twice is unnecessary.
from heroku-buildpack-ruby.
also, this commit doesn't look like it prevents deploy if rake fails. Perhaps this is unpreventable with Heroku, once the deploy is kicked off no way to stop, but personally I wouldn't want a production deploy to complete if asset compilation fails
from heroku-buildpack-ruby.
@bcardarella This doesn't try to fail the build if assets:precompile fails. This just tries to run a trace if we can't detect the rake task properly. The rake task won't run more than once. We don't --trace
because we don't want it on every case.
I'm not sure where it's failing.
from heroku-buildpack-ruby.
Maybe I'm misunderstanding, but why wouldn't you fail the build if assets:precompile fails? I can't think of many scenarios there where I would want it to proceed if an associated Rake task (as in my scenario yesterday) aborted. In that scenario, even doing the equivalent of a Rake -T would raise because I had a very basic problem :). Agree that --trace shouldn't be default though, far too noisy for the average deploy.
from heroku-buildpack-ruby.
You should run rake -t
and pipe the result into a file. You can simply puts "Compiling assets"
and detect the exit code of rake. If it exited with error you dump the result of the file and abort the deploy. IMO that's what should happen.
from heroku-buildpack-ruby.
Something like:
puts 'Compiling assets...'
unless system('rake assets:precompile --trace > /tmp/assets')
puts '** Asset compilation failed! **'
puts File.open('/tmp/assets').read
exit
end
from heroku-buildpack-ruby.
@zapnap @bcardarella it doesn't fail the build, b/c that's just not the point of this change. I'm trying to first come up with helpful output to debug why the assets:precompile task fails ambiguously. I believe @zapnap's issue the other day and the one opened up here was there's basically no output when the rake task is not detected. This branch tries to help solve that.
As for failing the build, I need to think about it more. I'm just not sure if there are people who depend on that behaviour atm. Even if we did fail the build, it wouldn't help you debug why. I think these are two different but related concerns.
from heroku-buildpack-ruby.
I guess I don't understand why the build should still proceed if the assets fail to compile. The production application will 500 when the assets are not compiled.
from heroku-buildpack-ruby.
I think I'm with Brian on this one. Of course, the user could be choosing to explicitly push precompiled assets or enabled asset compilation on the fly. But that could be detectable as well and/or the Rake task no-op'd.
from heroku-buildpack-ruby.
Yeah, if the assets are pre-compiled the rake task should not run at all. Would it be OK to do:
unless Dir.exist?(File.join(Rails.root, 'public/assets'))
# kick off rake
end
from heroku-buildpack-ruby.
Also, if the rake task fails it should output a URL to a Heroku article on why Rake is most likely failing
from heroku-buildpack-ruby.
@zapnap @bcardarella I understand your issue with failing the build when the assets:precompile
rake task does not pass, but like I said above that's a different issue that we should discuss on and needs more thought on my part.
The buildpack already skips assets:precompile
if we detect public/assets/manifest.yml
: https://github.com/heroku/heroku-buildpack-ruby/blob/master/lib/language_pack/rails3.rb#L43
This change is just to fix the "no detection of rake" failure, which is obscure why that happens at all.
from heroku-buildpack-ruby.
I understand. Would you like me to open another 'Asset Pipeline Deploy Strategy' issue to discuss?
from heroku-buildpack-ruby.
maybe we can just use #15 here. Do you guys have sample repro code for this issue though?
from heroku-buildpack-ruby.
We were bit by this recently and I think comparing the approach in #34 would be useful.
from heroku-buildpack-ruby.
This should be solved by #34 .
from heroku-buildpack-ruby.
Related Issues (20)
- Heroku doesn't support differentiated Gemfiles HOT 4
- Missing tag for v250 HOT 1
- ruby: integer overflow: 3689348814741910509 * 8 > 18446744073709551615 (RuntimeError) HOT 3
- Only add default web dyno if `config.ru` exists HOT 1
- Having `rack` gem is not a guarantee for having `rackup` executable (since Rack 3) HOT 2
- Heroku-22 fails installing gems HOT 3
- running ruby 3.2 with yjit HOT 1
- JRuby warns to use a more recent version, but it's blank
- Difficulties getting `rake assets:precompile` to work HOT 1
- JRuby 9.4.2.0 support? HOT 4
- Upgrade to Node 18 LTS HOT 1
- Using ruby 3.3.0 for preview release (as suggested in the notes) raises error with bundler HOT 2
- JRuby 9.4.4.0 support? HOT 1
- Support Bundler 2.4.20+ to enable `ruby file: '.ruby-version'` in Gemfile HOT 9
- Support Ruby 3.2.3 HOT 1
- Bundler 2.5.6 Causes Builds to Fail HOT 10
- Possible Bundler 2.5.6 Issues HOT 5
- ruby required for compiling webpack assets in rails build, missing from nodejs buildpack and stack 22 HOT 1
- Failed to install gems via Bundler (2.5.6) on Ruby 2.7.8 HOT 1
- Rails builds fail if `BUNDLE_WITHOUT="'development:test'"` (note the extra quotes)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from heroku-buildpack-ruby.