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

NameError: uninitialized constant Hashie::Extensions::Array #367

Closed
kjschnei001 opened this issue Sep 16, 2016 · 16 comments
Closed

NameError: uninitialized constant Hashie::Extensions::Array #367

kjschnei001 opened this issue Sep 16, 2016 · 16 comments
Labels

Comments

@kjschnei001
Copy link

https://github.com/intridea/hashie/blob/93b941d653cf8cad14933b498ffc6808457b86b6/lib/hashie/array.rb#L3 references a class that has not yet been loaded.

Similar error on https://github.com/intridea/hashie/blob/93b941d653cf8cad14933b498ffc6808457b86b6/lib/hashie/array.rb#L4

@jrafanie
Copy link
Contributor

This was introduced in 3.4.5. I don't see it in 3.4.4

@dblock
Copy link
Member

dblock commented Sep 16, 2016

Uh oh. Maybe needs a require/autoload. A spec/example that actually reproduces this would be nice. Please PR.

@dblock dblock added the bug? label Sep 16, 2016
@jrafanie
Copy link
Contributor

I'll see if I can fix it.

@jrafanie
Copy link
Contributor

In my case, omniauth is requiring hashie/mash without requiring hashie.

That causes us to never autoload here. We can't recreate this in test @dblock because we require hashie in the spec_helper.

@jrafanie
Copy link
Contributor

See here for the omniauth code I forgot to include above.

@dblock
Copy link
Member

dblock commented Sep 16, 2016

What do you propose the fix to be @jrafanie?

@jrafanie
Copy link
Contributor

@dblock either enforce people require hashie (can't here since we broke people in a patch release)... or require what's needed at the top of the array extension. I'll throw something up for review.

@dblock
Copy link
Member

dblock commented Sep 16, 2016

I think the fact that require 'hashie/mash' worked before is a bit of an accident, no? Also any project can work-around by requiring whatever is necessary explicitly (including just require 'hashie').

@dblock
Copy link
Member

dblock commented Sep 16, 2016

It's unfortunate that this was a minor version increment I agree. We need at the very least an UPGRADING line.

@jrafanie
Copy link
Contributor

I think the fact that require 'hashie/mash' worked before is a bit of an accident, no?

I'm very new to hashie but from looking at the code, it looks like you're not expected to require 'hashie/mash' without 'hashie'. With that said, that should be enforced in 3.5 not 3.4.5.

@dblock
Copy link
Member

dblock commented Sep 16, 2016

I am with you @jrafanie. I could yank 3.4.5 but I suspect a minority of people is requiring hashie/mash and the majority is requiring hashie. Would love to hear other people's opinions.

If you can PR an UPGRADING note that'd be great!

@jrafanie
Copy link
Contributor

@dblock see #368 for a fix to allow the old "questionable" behavior. What would you like in the UPGRADING guide?

jrafanie added a commit to jrafanie/hashie that referenced this issue Sep 16, 2016
Fixes hashie#367

While it's probably not something hashie wants to allow, previously
this was possible so we shouldn't break this when going 3.4.4 to 3.4.5.

As an example, omniauth requires hashie/mash alone:
https://github.com/omniauth/omniauth/blob/d941c4bcb1eb52f3674dd46225808751dd6a1c2f/lib/omniauth/auth_hash.rb#L1

This appears to have been broken in hashie#358.

Note, we can't write a test for this because we require 'hashie' in the spec_helper
which properly defines the Hashie::Extensions::Array constant and autoloads
the pretty_inspect here:
https://github.com/intridea/hashie/blob/229ee36d7c6a07eff6d8a0434726e12b8c3a0223/lib/hashie.rb#L48

**Before**

```
10:44:30 ~/Code/hashie (master) (2.3.1) + be irb
irb(main):001:0> require 'hashie/mash'
NameError: uninitialized constant Hashie::Extensions::Array
Did you mean?  Hashie::Array
               Array
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:3:in `<class:Array>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:2:in `<module:Hashie>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:1:in `<top (required)>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/mash.rb:2:in `require'
  from /Users/joerafaniello/Code/hashie/lib/hashie/mash.rb:2:in `<top (required)>'
  ...
```

**After**

```
10:44:40 ~/Code/hashie (master) (2.3.1) + be irb
irb(main):001:0> require 'hashie/mash'
=> true
irb(main):002:0> exit
```
@litch
Copy link

litch commented Sep 16, 2016

This has broken me as well.

jrafanie added a commit to jrafanie/hashie that referenced this issue Sep 16, 2016
Fixes hashie#367

While it's probably not something hashie wants to allow, previously
this was possible so we shouldn't break this when going 3.4.4 to 3.4.5.

As an example, omniauth requires hashie/mash alone:
https://github.com/omniauth/omniauth/blob/d941c4bcb1eb52f3674dd46225808751dd6a1c2f/lib/omniauth/auth_hash.rb#L1

This appears to have been broken in hashie#358.

Note, we can't write a test for this because we require 'hashie' in the spec_helper
which properly defines the Hashie::Extensions::Array constant and autoloads
the pretty_inspect here:
https://github.com/intridea/hashie/blob/229ee36d7c6a07eff6d8a0434726e12b8c3a0223/lib/hashie.rb#L48

**Before**

```
10:44:30 ~/Code/hashie (master) (2.3.1) + be irb
irb(main):001:0> require 'hashie/mash'
NameError: uninitialized constant Hashie::Extensions::Array
Did you mean?  Hashie::Array
               Array
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:3:in `<class:Array>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:2:in `<module:Hashie>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:1:in `<top (required)>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/mash.rb:2:in `require'
  from /Users/joerafaniello/Code/hashie/lib/hashie/mash.rb:2:in `<top (required)>'
  ...
```

**After**

```
10:44:40 ~/Code/hashie (master) (2.3.1) + be irb
irb(main):001:0> require 'hashie/mash'
=> true
irb(main):002:0> exit
```
jrafanie added a commit to jrafanie/hashie that referenced this issue Sep 16, 2016
Fixes hashie#367

While it's probably not something hashie wants to allow, previously
this was possible so we shouldn't break this when going 3.4.4 to 3.4.5.

As an example, omniauth requires hashie/mash alone:
https://github.com/omniauth/omniauth/blob/d941c4bcb1eb52f3674dd46225808751dd6a1c2f/lib/omniauth/auth_hash.rb#L1

This appears to have been broken in hashie#358.

Note, we can't write a test for this because we require 'hashie' in the spec_helper
which properly defines the Hashie::Extensions::Array constant and autoloads
the pretty_inspect here:
https://github.com/intridea/hashie/blob/229ee36d7c6a07eff6d8a0434726e12b8c3a0223/lib/hashie.rb#L48

**Before**

```
10:44:30 ~/Code/hashie (master) (2.3.1) + be irb
irb(main):001:0> require 'hashie/mash'
NameError: uninitialized constant Hashie::Extensions::Array
Did you mean?  Hashie::Array
               Array
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:3:in `<class:Array>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:2:in `<module:Hashie>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/array.rb:1:in `<top (required)>'
  from /Users/joerafaniello/Code/hashie/lib/hashie/mash.rb:2:in `require'
  from /Users/joerafaniello/Code/hashie/lib/hashie/mash.rb:2:in `<top (required)>'
  ...
```

**After**

```
10:44:40 ~/Code/hashie (master) (2.3.1) + be irb
irb(main):001:0> require 'hashie/mash'
=> true
irb(main):002:0> exit
```
@medright
Copy link

Broken records are we..

@dblock
Copy link
Member

dblock commented Sep 16, 2016

I released hashie 3.4.6 with this fix, thanks everyone.

@caleuanhopkins
Copy link

phew, quick work guys! Ran bundler just before the patch was pushed and broke my rails app but all working now! 👍

alecxvs added a commit to cerner/cerner_splunk_ingredient that referenced this issue Sep 21, 2016
* Refactor "ensured restart" to a resource

* Update Gemfile

hashie/hashie#367

* Don't rely on name to determine package for splunk_restart

* Test formatting

* Hashie issue fixed

* Fix integration tests for Windows

* Try testing for both Chef <= 12.13 and Chef >= 12.14

* Exclude fix?

* Rubocop

* Use Ruby 2.3.1 instead of 2.2.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants