Fixed JRuby and Rubinius builds.

- Can't use `__dir__` on JRuby (use to 1.9.x syntax).
- Can't clone stdout/stderr on Rubninus.