This project is archived and is in readonly mode.
ActiveModel has undeclared dependency on tzinfo
Reported by Chris Griego | June 26th, 2010 @ 05:32 AM | in 3.0.2
Steps to recreate:
$ echo "gem 'activemodel', :require => 'active_model', :git => 'git://github.com/rails/rails.git'" > Gemfile
$ bundle install && bundle console
>> ActiveModel::Observing
You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install
LoadError: no such file to load -- tzinfo
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/values/time_zone.rb:4:in `require'
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/values/time_zone.rb:4
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time_with_zone.rb:1:in `require'
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time_with_zone.rb:1
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/zones.rb:1:in `require'
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/zones.rb:1
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/date/calculations.rb:3:in `require'
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/date/calculations.rb:3
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/calculations.rb:3:in `require'
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/calculations.rb:3
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/string/conversions.rb:3:in `require'
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/string/conversions.rb:3
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/observing.rb:5:in `require'
from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/observing.rb:5
from (irb):2
ActiveResource::Base fails in a similar way because of its dependency on ActiveModel::Observing. The backtrace shows how tzinfo comes to be required. I really dislike the pattern of having so-called optional dependencies because things like this creep in. The only way to test for this would be to maintain unique Gemfiles for each of the Rails core gems used when running the test suite, otherwise they're not tested separately from the full Rails stack. Each gem which uses ActiveSupport without being Rails dependent has to declare an explicit tzinfo dependency in cases where they're not using any timezone functionality just because they use something innocuous and unrelated in ActiveSupport like core_ext/string/conversions because of complex dependency trees within ActiveSupport.
I think the best solution would be to reinstate the ActiveSupport dependency on tzinfo, but since that seems unlikely to happen (I looked at the commits removing them but they had no reference back to a LH ticket or mailing list discussion), I've attached a patch that at least adds the dependency to ActiveModel.
Comments and changes to this ticket
-
Repository June 26th, 2010 @ 07:50 PM
- State changed from new to committed
(from [51be8dbdedd1279d74cd7a7e277c5042f278b8a2]) Move constantize from conversions to inflections.
This removes ActiveModel dependency on TZInfo.
[#4979 state:committed]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/51be8dbdedd1279d74cd7a7e277c50... -
Chris Griego June 27th, 2010 @ 06:39 AM
Same bug, different spot. ActiveModel::Serializers::JSON, which you can argue is an optional part of ActiveModel but in that case it is a dependency of ActiveResource.
Steps to reproduce:
$ echo "gem 'activemodel', :require => 'active_model', :git => 'git://github.com/rails/rails.git'" > Gemfile $ bundle install && bundle console Updating git://github.com/rails/rails.git Updating git://github.com/rails/rails.git Using activesupport (3.0.0.beta4) from git://github.com/rails/rails.git (at master) Using builder (2.1.2) from system gems Using i18n (0.4.1) from bundler gems Using activemodel (3.0.0.beta4) from git://github.com/rails/rails.git (at master) Your bundle is complete! Use
bundle show [gemname] to see where a bundled gem is installed. >> ActiveModel::Serializers::JSON You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install LoadError: no such file to load -- tzinfofrom /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/values/time_zone.rb:4:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/values/time_zone.rb:4 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time_with_zone.rb:1:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time_with_zone.rb:1 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/zones.rb:1:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/zones.rb:1 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/date/calculations.rb:3:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/date/calculations.rb:3 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/calculations.rb:3:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/calculations.rb:3 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time.rb:19:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time.rb:19 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/json/encoding.rb:11:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/json/encoding.rb:11 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/json.rb:2:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/json.rb:2 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/serializers/json.rb:1:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/serializers/json.rb:1 from (irb):1</code>
-
Santiago Pastorino July 1st, 2010 @ 11:09 PM
- Milestone cleared.
- State changed from committed to open
- Importance changed from to Low
I'm pushing a change again, hope that this fix your problem ;)
-
Repository July 2nd, 2010 @ 01:01 AM
- State changed from open to committed
(from [cb321546b7aef33fcf5466b61f79bd9198cd12b5]) Time has it own implementation of xmlschema, now AMo doesn't depend on TZInfo
[#4979 state:committed]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/cb321546b7aef33fcf5466b61f79bd... -
Chris Griego July 2nd, 2010 @ 03:43 AM
I appreciate the effort!
ActiveModel::Serializers::Xml has a similar issue. The good news is that I beefed up how I was iterating over the constants and I also used the required gem and I think this is the last one. The other way I was driving these out is by bundling activeresource and loading ActiveResource::Base.
>> ActiveModel::Serializers::Xml You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install LoadError: no such file to load -- tzinfo from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/values/time_zone.rb:4:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/values/time_zone.rb:4 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time_with_zone.rb:1:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time_with_zone.rb:1 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/zones.rb:1:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/zones.rb:1 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/date/calculations.rb:3:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/date/calculations.rb:3 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/calculations.rb:3:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/time/calculations.rb:3 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time.rb:19:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/time.rb:19 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/hash/conversions.rb:2:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/hash/conversions.rb:2 from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/serializers/xml.rb:4:in `require' from /Users/cgriego/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activemodel/lib/active_model/serializers/xml.rb:4
-
Geoff Buesing July 2nd, 2010 @ 07:03 PM
- State changed from committed to open
Reopening this because I noticed this patch changes the Time#as_json implementation from:
%(#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)})
to:
strftime("%Y/%m/%d %H:%M:%S %z")
...i.e., the call to formatted_offset has been replaced with the strftime %z directive. %z is non-standard and unreliable, notably on Mac OS X:
ruby-1.8.7-p174 > Time.local(2010) => Fri Jan 01 00:00:00 -0600 2010 ruby-1.8.7-p174 > Time.local(2010).strftime("%z") => "-0500" # NOTE: should be "-0600"!! ruby-1.8.7-p174 > Time.utc(2010).strftime("%z") => "-0500" ruby-1.8.7-p174 > Time.utc(2010) => Fri Jan 01 00:00:00 UTC 2010 ruby-1.8.7-p174 > Time.utc(2010).strftime("%z") => "-0500" # NOTE: should be "+0000"!!
Because of this issue, I'm now getting two failing tests on my machine (OS X 10.6.4 w/Ruby 1.8.7-p174):
1) Failure: test_hash_with_time_to_json(TestJSONEncoding) [./test/json/encoding_test.rb:140:in `test_hash_with_time_to_json' /Users/gbuesing/.rvm/gems/ruby-1.8.7-p174/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `__send__' /Users/gbuesing/.rvm/gems/ruby-1.8.7-p174/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `run']: <"{\"time\":\"2009/01/01 00:00:00 +0000\"}"> expected but was <"{\"time\":\"2009/01/01 00:00:00 -0500\"}">. 2) Failure: test_time(TestJSONEncoding) [./test/json/encoding_test.rb:72:in `test_time' ./test/json/encoding_test.rb:71:in `each' ./test/json/encoding_test.rb:71:in `test_time' /Users/gbuesing/.rvm/gems/ruby-1.8.7-p174/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `__send__' /Users/gbuesing/.rvm/gems/ruby-1.8.7-p174/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `run']: <"\"2005/02/01 15:15:10 +0000\""> expected but was <"\"2005/02/01 15:15:10 -0500\"">.
This change looks like it just slipped in to this patch; it doesn't seem relevant to what's being fixed. I've attached a patch that reverts the use of %z; tests are back to passing with this.
-
Repository July 2nd, 2010 @ 07:50 PM
(from [227e1caea51279fe4687f17e5704d637a21ea15f]) Time#as_json: use Time#formatted_offset instead of strftime %z directive, which is non-standard and inaccurate on some platforms (e.g., Mac OS X).
[#4979]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/227e1caea51279fe4687f17e5704d6... -
Repository July 3rd, 2010 @ 04:22 AM
(from [8cc746331c32a6951e5c73c8a21fd32f00680471]) Time#formatted_offset is defined in core_ext/time/conversions
[#4979] http://github.com/rails/rails/commit/8cc746331c32a6951e5c73c8a21fd3...
-
Santiago Pastorino July 7th, 2010 @ 05:04 PM
- State changed from open to resolved
This was finally fixed here http://github.com/rails/rails/commit/f6d7a4d251cae3e425cb62898c50d3...
Great work Chris please check all the constants again to make sure we're not depending on TZInfo.
Anyways if you want to convert to JSON or Xml a time with a zone you will be ending with this error in case you don't have tzinfobegin require 'tzinfo' rescue LoadError => e $stderr.puts "You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install" raise e end
So for this cases you will need to install it.
-
Repository July 8th, 2010 @ 07:36 PM
- State changed from resolved to committed
(from [f6d7a4d251cae3e425cb62898c50d3f070c69d4b]) Removes the dependency that AMo has on tzinfo
[#4979 state:committed] http://github.com/rails/rails/commit/f6d7a4d251cae3e425cb62898c50d3...
-
Chris Griego July 8th, 2010 @ 07:59 PM
Both ActiveModel and ActiveResource seem to work great now. Thanks Santiago!
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 4979 ActiveModel has undeclared dependency on tzinfo [#4979 state:committed]
- 4979 ActiveModel has undeclared dependency on tzinfo [#4979 state:committed]
- 4979 ActiveModel has undeclared dependency on tzinfo [#4979]
- 4979 ActiveModel has undeclared dependency on tzinfo [#4979] http://github.com/rails/rails/commit/8cc746331c3...
- 4979 ActiveModel has undeclared dependency on tzinfo [#4979 state:committed] http://github.com/rails/rails/co...