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

getHomeDirectoryPath fails when ENV is stubbed (RSpec) #2167

Open
e2 opened this Issue Nov 10, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@e2

e2 commented Nov 10, 2014

How to reproduce:

class Foo; def self.[](name); ENV[name]; end; end

Object.__send__(:remove_const, 'ENV')
Object.const_set('ENV', Foo)

File.expand_path('~/anything') # works as expected on MRI

Error is:

RubyDir.java:769:in `getHomeDirectoryPath': java.lang.ClassCastException: org.jruby.RubyClass cannot be cast to org.jruby.RubyHash
    from RubyFile.java:1760:in `expandUserPath'

Line:
https://github.com/jruby/jruby/blob/1.7.16.1/core/src/main/java/org/jruby/RubyDir.java#L769

Same on master (obviously - code hasn't changed).

I'm not an expert on Java or JRuby, so it would probably take ages for me to create a proper PR.

@MSNexploder

This comment has been minimized.

Contributor

MSNexploder commented Jul 12, 2017

This works as expected on 9.1.12.0 (same as MRI)

class Foo; def self.[](name); ENV[name]; end; end
Object.__send__(:remove_const, 'ENV')

File.expand_path('~/anything')
# => "/Users/stefan/anything"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment