以非线程安全的方式“ sass”

尝试在Rails 3.1 rc1中使用sass时出现这些警告

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.

这是我的Gemfile。

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

我试图创建一个包含此代码的sass.rb内部文件config/initializers

require "sass"

将Gemfile更改为此。

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

但是警告仍然存在。有人知道如何解决吗?

我发现打印警告的代码,如果有帮助的话。

小卤蛋2020/03/24 11:03:14

我遇到了同样的问题,并且能够像在Heroku Cedar上的Rails 3.1+ Asset Pipeline中提到的那样,在推送到Heroku之前通过本地编译资产来解决此问题。

RAILS_ENV=production bundle exec rake assets:precompile

我还尝试了Itecedors建议,该建议也有效:

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
Tom凯2020/03/24 11:03:14

在Heroku上,我遇到了同样的错误,而谷歌搜索并没有帮助我找到问题,所以我想我将添加到该问题中的内容添加到搜索中,因为它首先出现在搜索中。

问题不在于此错误,而是在将代码推送到Heroku时的较小错误。列出宝石之后,这些行将我带到了答案的道路上:

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

我刚刚在Heroku上配置Redis,所以我知道问题一定与这些更改有关。在该网址,我发现了这一点:

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.