Mash#load uses except, a rails specific method?
najamelan opened this issue · 10 comments
I just updated the hashie gem and some of my code fails to run. The error I get is:
WARNING: unable to load thorfile "/data/doc/code/Susu/Thorfile": undefined method `except' for {}:Hash
/usr/lib/ruby/gems/2.7.0/gems/hashie-4.0.0/lib/hashie/mash.rb:77:in `load'
Checking out that method, it uses except
on what seems like a standard Hash
, but that has no method except
. The only reference I found to an except method is from Rails. So this fails if monkey-patching rails is not loaded.
Is Mashie meant to be used only with Rails? Doesn't seem to be documented.
Is Mashie meant to be used only with Rails? Doesn't seem to be documented.
no, Hashie::Mash
should work with whatever, not sure what's going on here, but appreciate some digging/specs/repro
no,
Hashie::Mash
should work with whatever, not sure what's going on here, but appreciate some digging/specs/repro
I could make a small reproducible example, but frankly, the code just calls a non-existing method. So if I can save the time... Just look at the ruby api docs: https://docs.ruby-lang.org/en/2.7.0/
I would propose you use the delete
method instead.
This is Ruby 2.7? We haven't gotten to it. Appreciate a PR with the fix + adding 2.7 to CI.
There is no except
method in earlier versions of ruby either.
I see us adding it in Railtie,
Line 13 in ca36045
Either way, if something is not working, the best way to fix it is to write a failing spec and a fix.
Just to avoid the expectations. I have a lot of chores to do on my own code, so I'm not volunteering to fix this.
What's probably happening is that either no integration tests exists for Mash::load
or the integration tests turn on the monkey patching from rails for code that shouldn't depend on it.
I feel you are much better placed to look into that than I am, and it would probably cost you much less time since you are familiar with the code base already.
Just to avoid the expectations. I have a lot of chores to do on my own code, so I'm not volunteering to fix this.
Same.
Thanks for reporting this @najamelan, this was a bug introduced in 4.0.0 from a PR earlier in 2019, so we never caught it.
I've submitted a PR to resolve it, and will release a patch version once merged.
@BobbyMcWho Thanks for looking into it!