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

change dir does not propagate to java runtime #971

Closed
mkristian opened this issue Aug 24, 2013 · 5 comments
Closed

change dir does not propagate to java runtime #971

mkristian opened this issue Aug 24, 2013 · 5 comments
Assignees
Milestone

Comments

@mkristian
Copy link
Member

@mkristian mkristian commented Aug 24, 2013

jruby -e 'Dir.chdir("..");p File.expand_path(".");p java.io.File.new("").absolute_path;p java.lang.System.get_property("user.dir")'

produces
"/home/christian/projects/active/maven/tesla-polyglot/tesla-polyglot-gems"
"/home/christian/projects/active/maven/tesla-polyglot/tesla-polyglot-gems/ruby-maven"
"/home/christian/projects/active/maven/tesla-polyglot/tesla-polyglot-gems/ruby-maven"

not sure how the java runtime 'knows' the pwd. one way is to set the user.dir system property:
``jruby -e 'Dir.chdir("..");java.lang.System.set_property("user.dir", File.expand_path("."));p java.io.File.new("").absolute_path;p java.lang.System.get_property("user.dir")'`

which does the trick at least for java.io.File

usually I am using jruby and ruby almost exchangable, i.e. ruby calls java and java calls ruby . . .

when looking at the jruby sources I am not sure whether the place to 'add' the system property fix is RubyDir.java or Ruby.java

@BanzaiMan
Copy link
Member

@BanzaiMan BanzaiMan commented Aug 27, 2013

Broke some test for Embedded.

@BanzaiMan BanzaiMan reopened this Aug 27, 2013
@BanzaiMan
Copy link
Member

@BanzaiMan BanzaiMan commented Aug 27, 2013

Reverted the commit for now.

@BanzaiMan
Copy link
Member

@BanzaiMan BanzaiMan commented Sep 1, 2013

It's been pointed out that JVM may not like this. https://github.com/rubyspec/rubyspec/issues/248#issuecomment-23514353

@mkristian mkristian added this to the Won't Fix milestone Dec 3, 2014
@headius
Copy link
Member

@headius headius commented Dec 3, 2014

It sucks, but we should make our best effort to emulate chdir and deal with it at external integration points (anywhere that needs to see the chdir) rather than forcibly chdir the whole JVM (which will never work in typical server settings).

@mkristian
Copy link
Member Author

@mkristian mkristian commented Dec 3, 2014

yeah - something like: #2215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants