jrubyc has issues with mangled (target) path on Windows

Created on 21 Sep 2020  ·  3Comments  ·  Source: jruby/jruby

not 100% sure but seems like jrubyc is broken with --target path specified,
the path seems to end up being invalid on Windows, here's 2 (pended) reproducers: https://github.com/jruby/jruby/commit/851629a431b4c5b9fe63d78723cd32980f030c85

beginner help wanted windows

All 3 comments

@kares ,can I contribute?

@debapriyo1999 sorry if you have already spent some time on this but I think I found the problem.

@kares it seems that this issue exists not only on windows but also on linux.
On windows there was a error but on linux it was silently mangling path.

Example:

> cd ~
> mkdir bar
> jrubyc /home/mariusz/temp/foo.rb --target bar
> tree bar
bar
└── home
    └── mariusz
        └── temp
            └── foo.class

To my understanding it should create file class foo in java package temp (because "base dir" is home dir) under bar/temp/ directory (i.e. /home/mariusz/bar/temp/foo.class).
Compiled package/class is fine, but target directory seems wrong.

On windows it results in error because compiler.rb blindly concatenates two paths. In the test it creates file under C:\Users\...\Temp.
Concatenation results in broken directory name because it appends "C:", e.g. D:\src\jrubyc\C:\Users\.... On Linux it's does not fail, but still seems incorrect.

With my fix:

> jrubyc /home/mariusz/temp/foo.rb --target bar
> tree bar
bar
└── temp
    └── foo.class

@MariuszCwikla Thank you for the fix!

Was this page helpful?
0 / 5 - 0 ratings