-
Notifications
You must be signed in to change notification settings - Fork 187
Heroku Issue: ActionView::Template::Error (The asset "tailwind.css" is not present in the asset pipeline.") #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I fixed this problem running: Commit and push to heroku. |
I am seeing the same issue when running tests on github. My configuration is using importmap
|
@peteoliveira: If you have this issue while running tests in your continuous integration, you need to precompile assets with: bundle exec rake assets:precompile I had the same issue and this fixed it. |
@dmarcoux That worked, thanks! |
@dmarcoux Shouldn’t CI be handled by the Rake tasks? Rake::Task["assets:precompile"].enhance(["tailwindcss:build"])
if Rake::Task.task_defined?("test:prepare")
Rake::Task["test:prepare"].enhance(["tailwindcss:build"])
elsif Rake::Task.task_defined?("db:test:prepare")
Rake::Task["db:test:prepare"].enhance(["tailwindcss:build"])
end Having said that, I’m having the same issue in CircleCI. I call |
I didn't know about those Edit: After giving the rake task |
Yeah, this is exactly what I’m seeing also as mentioned:
Maybe @flavorjones or @dhh can shine some light? |
Similar things are happening to me after updating the
The tests run by GitHub CI were then failing with:
After re-reading https://github.com/rails/tailwindcss-rails#building-for-testing, I was able to fix that by adapting the run script:
Not running |
I also suddenly had this problem after upgrading The problem is present both locally (after removing old assets with I solved it by adding the following to my system test configuration: # spec/support/system_test_configuration.rb
# Could alternatively be added to `rails_helper.rb` or `spec_helper.rb`
RSpec.configure do |config|
...
config.before(:suite) do
if config.files_to_run.any? { |path| path.start_with?(Rails.root.join("spec/system").to_s) }
Rails.application.load_tasks
Rake::Task["tailwindcss:build"].invoke
end
end
end Works like a charm. Still seems like a breaking change in a patch version, though 😉
|
@dmarcoux Great! it works like a charm... I'm using the Ruby On Rails CI provided by GitHub Actions, I added the assets precompile before running the tests.
|
none of the suggested solutions work for me which is really frustrating since my productive env is broken right now... staging works fine though. Edit: Turns out in my gitignore i had |
What ended up working: # config/application.rb
config.assets.css_compressor = nil |
@gabrielboeker Wouldn't that mean that you have to commit your assets all the time? |
For me, it was helpful to see which tasks tailwindcss-rails hooks into. You can see that here: https://github.com/rails/tailwindcss-rails/blob/main/lib/tasks/build.rake#L15-L21 If you're using RSpec, you need to figure out a way to build tailwind's CSS or you'll receive this error. @Timmitry 's solution worked for me in this case. I also put the whole block in a |
If someone on this thread would be willing to submit a documentation PR to update the README, I would be very grateful! |
|
For the goofballs like me who don't notice a compilation error and only notice the failure to precompile Since this happened in my Nope, turned out I derped and Tailwind errored when trying to compile my typo, but then it failed to compile — as you'd expect. Output from
|
I can confirm that two of the previously suggested solutions work for me. Run all tests at once with Explicitly precompile assets before running your tests I'm sticking to the second solution, this way I can keep unit tests separated from system tests. You can also check the builds on the two last commits of this pull request: cherrypush/cherrypush.com#80 Hope that helps ❤️ |
Running Enhancing prepare commands with if Rake::Task.task_defined?("test:prepare")
Rake::Task["test:prepare"].enhance(["tailwindcss:build"])
elsif Rake::Task.task_defined?("spec:prepare")
Rake::Task["spec:prepare"].enhance(["tailwindcss:build"])
elsif Rake::Task.task_defined?("db:test:prepare")
Rake::Task["db:test:prepare"].enhance(["tailwindcss:build"])
end So, you can just add |
What does |
@pas256 yeah, as I wrote above, this should have been fixed in the latest versions of the gem. Happy that everything is ok now 🙂 |
I only makethis working after run:
|
My fix for this error was to make sure that the app/assets/builds directory is in git:
|
I'm experiencing this issue in production, even though I've already run or have these:
Always getting
Here's a bare bones repo to reproduce: https://github.com/sebastialonso/tailwindcss-rails-dokku Anybody managed to solve this? |
The only thing that worked for me is adding Thanks for the help @seanbjornsson! |
Oh, I thought I got some kind of glitch or smth, cause I've just baked a sourdough bread by your recipe @hendricius and now I see you here answering about the Ruby. What a great coincidence! |
For those who have mentioned removing /app/assets/builds/*
!/app/assets/builds/.keep This will ignore ignore anything in the |
Love it! Problem solved! |
Hi
Thanks for your work.
I'm running a very simple Rails 7.0.2.2 which I've just set up.
Everything is working swimmingly locally, but when I deploy to heroku I'm getting the following error when I try to view a page:
ActionView::Template::Error (The asset "tailwind.css" is not present in the asset pipeline.)
I have checked to ensure that sassc-rails is disabled in the Gemfile.
I have also tried adding
config.assets.css_compressor = nil
to production.rb, but the error remains.
Any ideas where I am going wrong?
Thanks
The text was updated successfully, but these errors were encountered: