开发者

How to alias ruby as jruby in Windows

开发者 https://www.devze.com 2023-03-22 05:06 出处:网络
I have installed jruby 1.6.3 on Windows 7 and to use jruby from comma开发者_JS百科nd line I use command jruby, example:

I have installed jruby 1.6.3 on Windows 7 and to use jruby from comma开发者_JS百科nd line I use command jruby, example:

jruby -v

but some script want to use command ruby. How to alias ruby as jruby. I tried to use doskey in bat but it doesn't work. I tried to create bat file:

@"jruby.bat" %1 %2 %3 %4 %5 %6 %7 %8 %9

but it doesnt work too.


It seems JRuby loader, which is based on Netbeans one (announced here) is sending argv[0] when starting the loader, as shown in the following code:

https://github.com/vvs/jruby-launcher/blob/master/jrubyexe.cpp#L78 https://github.com/vvs/jruby-launcher/blob/master/nbexecloader.h#L20

Because of that, ruby is send to JRuby DLL entry point and is failing to load the platform:

> ruby -v
jruby: No such file or directory -- ruby (LoadError)

argv[0] is required because JRuby on Windows support both jruby and jrubyw launchers.

I suggest you ask this specific feature request at JRuby bug tracker

EDIT: answer below was based on the assumption that jruby.exe hardcoded the entry point to load jruby.dll, seems it not.

JRuby on Windows uses jruby.exe as executable instead of the batch file (the batch file is kept for compatibility)

You can simply copy jruby.exe ruby.exe inside JRuby's bin directory.

Please note that if by chance you have another Ruby in the PATH this will definitely bork it.

If you need to switch between multiple Ruby interpreters you can use Pik, is a Ruby Version Manager for Windows.

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消