简体   繁体   English

以非线程安全的方式'sass'

[英]'sass' in a non thread-safe way

I'm getting these warnings when trying to use sass in Rails 3.1 rc1. 我试图在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.

This is my Gemfile. 这是我的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. 我试图在包含此代码的config/initializers中创建一个名为sass.rb的文件。

require "sass"

Changing the Gemfile to this. 将Gemfile更改为此。

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. 我找到打印警告的代码 ,如果有任何帮助的话。

have you tried doing this in Gemfile? 你有没有试过在Gemfile中这样做?

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

this is an explicit call, without using initializers. 这是一个显式调用,不使用初始值设定项。 by the way consider that you're using a rc1 release. 顺便说一下,考虑一下你正在使用rc1版本。

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 我遇到了同样的问题,并且能够通过在推送到Heroku之前在本地编译资产来解决它,正如文章Rails 3.1 + Heroku Cedar上的资产管道中提到的那样

RAILS_ENV=production bundle exec rake assets:precompile

I also tried Itecedors suggestion which also worked: 我也尝试了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

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. 在Heroku上我得到了同样的错误,谷歌搜索没有帮助我找到问题,所以我想我会添加我发现的这个问题,因为它在搜索时首先出现。

The problem was NOT this error, it was a smaller error while pushing the code up to Heroku. 问题不是这个错误,将代码推送到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. 我刚刚在Heroku上配置了Redis,所以我知道问题必须与这些变化有关。 At that URL I found this: 在那个URL我发现了这个:

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: 在预编译资产时,在Rails 3.1.1及更高版本中,您可以通过确保以下行位于> config / application.rb中来阻止初始化应用程序并连接到数据库:

config.assets.initialize_on_precompile = false config.assets.initialize_on_precompile = false

Adding the on_precompile = false line fixed all the errors, including the original one in this question. 添加on_precompile = false行修复了所有错误,包括此问题中的原始错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM