Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant SafeYAML::Parse::Date::DateTime (NameError) #80

Closed
sgerrand opened this issue Oct 18, 2015 · 5 comments · Fixed by #90
Closed

uninitialized constant SafeYAML::Parse::Date::DateTime (NameError) #80

sgerrand opened this issue Oct 18, 2015 · 5 comments · Fixed by #90

Comments

@sgerrand
Copy link

I've been getting this error when using SafeYAML without bundle exec. On a cursory look, it seems like the cause is a reference to DateTime without pulling it in from the Ruby standard library. 😰

Backtrace follows:

/Users/s/.gem/ruby/2.2.3/gems/safe_yaml-1.0.4/lib/safe_yaml/parse/date.rb:22:in `<class:Date>': uninitialized constant SafeYAML::Parse::Date::DateTime (NameError)
    from /Users/s/.gem/ruby/2.2.3/gems/safe_yaml-1.0.4/lib/safe_yaml/parse/date.rb:3:in `<class:Parse>'
    from /Users/s/.gem/ruby/2.2.3/gems/safe_yaml-1.0.4/lib/safe_yaml/parse/date.rb:2:in `<module:SafeYAML>'
    from /Users/s/.gem/ruby/2.2.3/gems/safe_yaml-1.0.4/lib/safe_yaml/parse/date.rb:1:in `<top (required)>'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /Users/s/.gem/ruby/2.2.3/gems/safe_yaml-1.0.4/lib/safe_yaml/load.rb:14:in `<top (required)>'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /Users/s/.gem/ruby/2.2.3/gems/test-kitchen-1.4.2/lib/kitchen/loader/yaml.rb:27:in `<top (required)>'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /Users/s/.gem/ruby/2.2.3/gems/test-kitchen-1.4.2/lib/kitchen.rb:42:in `<top (required)>'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /Users/s/.gem/ruby/2.2.3/gems/test-kitchen-1.4.2/lib/kitchen/cli.rb:21:in `<top (required)>'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /opt/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /Users/s/.gem/ruby/2.2.3/gems/test-kitchen-1.4.2/bin/kitchen:10:in `<top (required)>'
    from /Users/s/.gem/ruby/2.2.3/bin/kitchen:23:in `load'
    from /Users/s/.gem/ruby/2.2.3/bin/kitchen:23:in `<main>'
@victort
Copy link

victort commented Dec 13, 2017

i'm having this error occur on debian/buster

$ kitchen
/var/lib/gems/2.3.0/gems/safe_yaml-1.0.4/lib/safe_yaml/parse/date.rb:22:in `<class:Date>': uninitialized constant SafeYAML::Parse::Date::DateTime (NameError)
Did you mean?  SafeYAML::Parse::Date::DATE_MATCHER
	from /var/lib/gems/2.3.0/gems/safe_yaml-1.0.4/lib/safe_yaml/parse/date.rb:3:in `<class:Parse>'
	from /var/lib/gems/2.3.0/gems/safe_yaml-1.0.4/lib/safe_yaml/parse/date.rb:2:in `<module:SafeYAML>'
	from /var/lib/gems/2.3.0/gems/safe_yaml-1.0.4/lib/safe_yaml/parse/date.rb:1:in `<top (required)>'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /var/lib/gems/2.3.0/gems/safe_yaml-1.0.4/lib/safe_yaml/load.rb:14:in `<top (required)>'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
	from /var/lib/gems/2.3.0/gems/test-kitchen-1.19.2/lib/kitchen/loader/yaml.rb:21:in `<top (required)>'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /var/lib/gems/2.3.0/gems/test-kitchen-1.19.2/lib/kitchen.rb:42:in `<top (required)>'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /var/lib/gems/2.3.0/gems/test-kitchen-1.19.2/lib/kitchen/cli.rb:21:in `<top (required)>'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /var/lib/gems/2.3.0/gems/test-kitchen-1.19.2/bin/kitchen:10:in `<top (required)>'
	from /usr/local/bin/kitchen:22:in `load'
	from /usr/local/bin/kitchen:22:in `<main>'
$ ruby --version
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]
$ gem list --local | egrep "test-kitchen|safe_yaml"
safe_yaml (1.0.4)
test-kitchen (1.19.2)```

@javierbertoli
Copy link

As a quick fix, changing here

    class Date
        # This one's easy enough :)

to

    class Date
        require 'time'
        # This one's easy enough :)

seems to fix it

@victort
Copy link

victort commented Dec 14, 2017

confirmed, @javierbertoli
that Works For Me™

thanks!

@electriquo
Copy link

i was having the same problem when upgrading from ruby version 2.4.2 to 2.5.0

$ ruby --version
ruby 2.5.0p0 (2017-12-25 revision 61468)
$ cat Gemfile.lock | grep -i 'test-kitchen ([0-9]'
    test-kitchen (1.19.2)

applying @javierbertoli quick fix resolved my pain.
wonder why i just got this error when the initial issue date it set back to Oct 18, 2015 and @javierbertoli resolution was not pushed to the upstream or any other suitable fix...

any idea?

@silverhammermba
Copy link

silverhammermba commented Jan 11, 2018

@y0y0z My only guess is that somebody somewhere was doing a require 'date' or require 'time' which pulls in the DateTime class and this was happening before safe yaml got invoked.

Top level constant names are a nasty little bit of global state in Ruby...

darwin added a commit to binaryage/totalfinder-i18n that referenced this issue Mar 22, 2018
@dtao dtao closed this as completed in #90 Aug 14, 2018
mbakke pushed a commit to guix-mirror/guix that referenced this issue Feb 14, 2019
Patch ruby-safe-yaml to fix an issue that would lead to an error like this:
uninitialized constant SafeYAML::Parse::Date::DateTime

It's been reported upstream [1], and this patch was taken from the upstream Git
repository.

1: dtao/safe_yaml#80

* gnu/packages/ruby.scm (ruby-safe-yaml)[source]: Switch to the Git repository
so that applying patches works and add a patch.
[arguments]: Enable tests and add a phase to set the TZ environment variable,
as one of the tests depends on a certian timezone.
* gnu/packages/patches/ruby-safe-yaml-add-require-time.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add new patch file.
sean-smith added a commit to sean-smith/cfncluster-cookbook that referenced this issue Feb 22, 2019
Fixes issue with travis caused by [aws#80](dtao/safe_yaml#80) and fixed in [aws#90](dtao/safe_yaml#90)

To test:

	bundle install
	bundle exec rake

Signed-off-by: Sean Smith <[email protected]>
sean-smith added a commit to aws/aws-parallelcluster-cookbook that referenced this issue Feb 22, 2019
Fixes issue with travis caused by [#80](dtao/safe_yaml#80) and fixed in [#90](dtao/safe_yaml#90)

To test:

	bundle install
	bundle exec rake

Signed-off-by: Sean Smith <[email protected]>
jwright added a commit to brilliantfantastic/laziness that referenced this issue Mar 15, 2019
wmfgerrit pushed a commit to wikimedia/operations-puppet that referenced this issue Jul 18, 2019
mitigates dtao/safe_yaml#80

Change-Id: Icf63f6620d7112926d2c2d324bdd6b73a7eebae6
wmfgerrit pushed a commit to wikimedia/operations-puppet that referenced this issue Oct 15, 2019
'time' is required by ruby-safe-yaml, however the version installed does
not declare the requirement/.  this patch adds the requirement to
check_puppetrun before safe_yaml is loaded

dtao/safe_yaml#80

Change-Id: I8f019c2e17a5656c659baf9b642e4382c0386e05
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Mar 24, 2020
Update ruby-safe_yaml to 1.0.5.
pkgsrc change: add "USE_LANGUAGES=	# none".


1.0.5
-----

- fixed [#80](dtao/safe_yaml#80): uninitialized constant DateTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants