From 103b8d1bfc8e6ca492efa0f554773b09fd936afe Mon Sep 17 00:00:00 2001 From: Brian Palmer Date: Thu, 13 Dec 2012 16:04:54 -0700 Subject: [PATCH] don't set default Encodings in ruby 1.9 closes #CNVS-2165 This is recommended in some guides for upgrading a Rails 2.3 app to Ruby 1.9, but it was causing a lot of problems with file reading and writing, especially in gems. Our override for ActiveSupport::SafeBuffer to always be encoded as utf-8 fixes the issue that originally prompted us to add these default encodings in the first place. Change-Id: Ifb4649dd6aa86bfb15ff16daa706a5c6df33292a Reviewed-on: https://gerrit.instructure.com/16079 Tested-by: Jenkins Reviewed-by: Ethan Vizitei QA-Review: Brian Palmer --- config/initializers/ruby_version_compat.rb | 2 +- config/preinitializer.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/config/initializers/ruby_version_compat.rb b/config/initializers/ruby_version_compat.rb index 825a4612248..495233e14c4 100644 --- a/config/initializers/ruby_version_compat.rb +++ b/config/initializers/ruby_version_compat.rb @@ -132,7 +132,7 @@ else # (which in canvas is utf-8) class ActiveSupport::SafeBuffer def initialize(*a) - super.force_encoding(Encoding.default_internal) + super.force_encoding('utf-8') end end end diff --git a/config/preinitializer.rb b/config/preinitializer.rb index f808257cc36..ee33d0e654d 100644 --- a/config/preinitializer.rb +++ b/config/preinitializer.rb @@ -14,7 +14,6 @@ begin # Set up load paths for all bundled gems ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__) Bundler.setup - Encoding.default_internal = Encoding.default_external = 'UTF-8' if defined?(Encoding) rescue Bundler::GemNotFound raise RuntimeError, "Bundler couldn't find some gems." + "Did you run `bundle install`?"