'sass' in a non thread-safe way

倖福魔咒の 提交于 2019-12-03 05:48:54

问题


I'm getting these warnings when trying to use sass in Rails 3.1 rc1.

WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
WARN: tilt autoloading 'sass/plugin' in a non thread-safe way; explicit require 'sass/plugin' suggested.

This is my Gemfile.

gem "rails", "~> 3.1.0.rc1"
gem "haml"
gem "sass"

I've tried to create a file called sass.rb inside the config/initializers containing this code.

require "sass"

Changing the Gemfile to this.

gem "rails", "~> 3.1.0.rc1"
gem "haml"
gem "sass", require: false

But the warnings remains. Anyone knows how to solve it?

I found the code that is printing the warnings, if that is to any help.


回答1:


have you tried doing this in Gemfile?

gem "sass", :require => 'sass'

this is an explicit call, without using initializers. by the way consider that you're using a rc1 release.




回答2:


I had the same problem, and was able to solve it by compiling assets locally before pushing to Heroku as mentioned in the article Rails 3.1+ Asset Pipeline on Heroku Cedar

RAILS_ENV=production bundle exec rake assets:precompile

I also tried Itecedors suggestion which also worked:

While precompiling assets, in Rails 3.1.1 and up, you can prevent initializing
your application and connecting to the database by ensuring that the following 
line is in your > config/application.rb:

config.assets.initialize_on_precompile = false



回答3:


On Heroku I was getting this same error and googling did not help me find the problem, so I thought I would add what I found to this questions since it comes up first when searching.

The problem was NOT this error, it was a smaller error while pushing the code up to Heroku. After the gems are listed these lines got me on the path to the answer:

Running: rake assets:precompile
rake aborted!
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting

I had just been configuring Redis on Heroku so I knew that the problem had to be something related to those changes. At that URL I found this:

While precompiling assets, in Rails 3.1.1 and up, you can prevent initializing your application and connecting to the database by ensuring that the following line is in your > config/application.rb:

config.assets.initialize_on_precompile = false

Adding the on_precompile = false line fixed all the errors, including the original one in this question.



来源:https://stackoverflow.com/questions/6091865/sass-in-a-non-thread-safe-way

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!