以非线程安全的方式’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"
我试图在包含此代码的config/initializers
中创建一个名为sass.rb
的文件。
require "sass"
将Gemfile更改为此。
gem "rails", "~> 3.1.0.rc1" gem "haml" gem "sass", require: false
但警告仍然存在。 谁知道如何解决它?
我找到了打印警告的代码 ,如果有任何帮助的话。
你有没有试过在Gemfile中这样做?
gem "sass", :require => 'sass'
这是一个显式调用,不使用初始值设定项。 顺便说一下,考虑一下你正在使用rc1版本。
我有同样的问题,并且能够通过在推送到Heroku之前在本地编译资源来解决它,如文章Rails 3.1+ Heroku Cedar上的资产管道中所提到的那样
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
在Heroku上我得到同样的错误,谷歌搜索没有帮助我找到问题,所以我想我会添加我发现的这个问题,因为它在搜索时首先出现。
问题不是这个错误,将代码推送到Heroku时这是一个较小的错误。 列出gem后,这些线条让我走上了答案的道路:
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,所以我知道问题必须与这些变化有关。 在那个URL我发现了这个:
在预编译资产时,在Rails 3.1.1及更高版本中,您可以通过确保以下行位于> config / application.rb中来阻止初始化应用程序并连接到数据库:
config.assets.initialize_on_precompile = false
添加on_precompile = false行修复了所有错误,包括此问题中的原始错误。