Forum: Ruby-core [Ruby 1.9 - Bug #4731][Open] ruby -S irb fails with mingw/msys vanilla builds

Posted by Roger Pack (rogerdpack)
on 2011-05-18 18:30
(Received via mailing list)
Issue #4731 has been reported by Roger Pack.

----------------------------------------
Bug #4731: ruby -S irb fails with mingw/msys vanilla builds
http://redmine.ruby-lang.org/issues/4731

Author: Roger Pack
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3dev (2011-05-18 trunk 31614) [i386-mingw32]


as reported originally with 
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
basically mingw builds fail with $ ruby -S irb and always have, at least 
for the 1.9 branches.

$ ruby -S irb
ruby: No such file or directory -- irb (LoadError)
Posted by Koichi Sasada (Guest)
on 2011-06-11 09:59
(Received via mailing list)
Issue #4731 has been updated by Koichi Sasada.

Status changed from Open to Assigned
Assignee set to Nobuyoshi Nakada


----------------------------------------
Bug #4731: ruby -S irb fails with mingw/msys vanilla builds
http://redmine.ruby-lang.org/issues/4731

Author: Roger Pack
Status: Assigned
Priority: Normal
Assignee: Nobuyoshi Nakada
Category:
Target version:
ruby -v: ruby 1.9.3dev (2011-05-18 trunk 31614) [i386-mingw32]


as reported originally with 
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
basically mingw builds fail with $ ruby -S irb and always have, at least 
for the 1.9 branches.

$ ruby -S irb
ruby: No such file or directory -- irb (LoadError)
Posted by Nobuyoshi Nakada (nobu)
on 2011-07-15 04:12
(Received via mailing list)
Issue #4731 has been updated by Nobuyoshi Nakada.

Status changed from Assigned to Feedback

I can't reproduce it.
Is irb only a batch file, or an exe file?
----------------------------------------
Bug #4731: ruby -S irb fails with mingw/msys vanilla builds
http://redmine.ruby-lang.org/issues/4731

Author: Roger Pack
Status: Feedback
Priority: Normal
Assignee: Nobuyoshi Nakada
Category:
Target version:
ruby -v: ruby 1.9.3dev (2011-05-18 trunk 31614) [i386-mingw32]


as reported originally with 
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
basically mingw builds fail with $ ruby -S irb and always have, at least 
for the 1.9 branches.

$ ruby -S irb
ruby: No such file or directory -- irb (LoadError)
Posted by Luis Lavena (luislavena)
on 2011-07-15 14:29
(Received via mailing list)
Issue #4731 has been updated by Luis Lavena.


Nobuyoshi Nakada wrote:
> I can't reproduce it.
> Is irb only a batch file, or an exe file?

After `make install` the end result in the indicated prefix is a series 
of batch files like: irb.bat which contains a mix of windows commands 
and the Ruby script in it, which is then fired using `ruby -x`

On RubyInstaller we replaced that with plain stubs and the original 
scripts from Ruby's source code, see here:

https://github.com/oneclick/rubyinstaller/blob/mas...
https://github.com/oneclick/rubyinstaller/blob/mas...
https://github.com/oneclick/rubyinstaller/blob/mas...

This workaround was implemented so `ruby -S irb` works.

----------------------------------------
Bug #4731: ruby -S irb fails with mingw/msys vanilla builds
http://redmine.ruby-lang.org/issues/4731

Author: Roger Pack
Status: Feedback
Priority: Normal
Assignee: Nobuyoshi Nakada
Category:
Target version:
ruby -v: ruby 1.9.3dev (2011-05-18 trunk 31614) [i386-mingw32]


as reported originally with 
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
basically mingw builds fail with $ ruby -S irb and always have, at least 
for the 1.9 branches.

$ ruby -S irb
ruby: No such file or directory -- irb (LoadError)
Posted by Nobuyoshi Nakada (nobu)
on 2011-07-16 12:47
(Received via mailing list)
Hi,

At Fri, 15 Jul 2011 21:28:50 +0900,
Luis Lavena wrote in [ruby-core:38075]:
> On RubyInstaller we replaced that with plain stubs and the
> original scripts from Ruby's source code, see here:

I see.  There is only irb.bat, not irb sans the suffix.  In
that sense, it's natural to fail, but maybe unexpected
behavior.  Now I'm thinking to make -S option search with .bat
(and .cmd too) suffix if it is not found.  How do you feel
about this?


diff --git a/ruby.c b/ruby.c
index 93b12d8..b8258ea 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1288,14 +1288,42 @@ process_options(int argc, char **argv, struct
cmdline_options *opt)
       }
       else if (opt->do_search) {
     char *path = getenv("RUBYPATH");
+#ifdef DOSISH
+    char *batch = NULL;
+    size_t batchlen = 0;
+#endif

     opt->script = 0;
     if (path) {
         opt->script = dln_find_file_r(argv[0], path, fbuf, 
sizeof(fbuf));
     }
+#ifdef DOSISH
     if (!opt->script) {
-        opt->script = dln_find_file_r(argv[0], getenv(PATH_ENV), fbuf,
sizeof(fbuf));
+        batchlen = strlen(argv[0]);
+        batch = ALLOC_N(char,  batchlen + 5);
+        memcpy(batch, argv[0], batchlen);
+        memcpy(batch + batchlen, ".bat", 5);
+        opt->script = dln_find_file_r(batch, path, fbuf, sizeof(fbuf));
+        if (!opt->script) {
+      memcpy(batch + batchlen, ".cmd", 5);
+      opt->script = dln_find_file_r(batch, path, fbuf, sizeof(fbuf));
+        }
+    }
+#endif
+    if (!opt->script && (path = getenv(PATH_ENV)) != NULL) {
+        opt->script = dln_find_file_r(argv[0], path, fbuf, 
sizeof(fbuf));
     }
+#ifdef DOSISH
+    if (!opt->script) {
+        memcpy(batch + batchlen, ".bat", 5);
+        opt->script = dln_find_file_r(batch, path, fbuf, sizeof(fbuf));
+        if (!opt->script) {
+      memcpy(batch + batchlen, ".cmd", 5);
+      opt->script = dln_find_file_r(batch, path, fbuf, sizeof(fbuf));
+        }
+    }
+    if (batch) xfree(batch);
+#endif
     if (!opt->script)
         opt->script = argv[0];
       }
Posted by Luis Lavena (luislavena)
on 2011-07-16 22:23
(Received via mailing list)
On Sat, Jul 16, 2011 at 7:46 AM, Nobuyoshi Nakada <nobu@ruby-lang.org> 
wrote:
>
> I see. There is only irb.bat, not irb sans the suffix. In
> that sense, it's natural to fail, but maybe unexpected
> behavior. Now I'm thinking to make -S option search with .bat
> (and .cmd too) suffix if it is not found. How do you feel
> about this?
>

Thank you Nakada-san, I see a few drawbacks with this approach:

* For a missing script (e.g. foo), system will attempt to find two
extra "foo.bat" and "foo.cmd" in all portions of PATH, which will be
expensive.

* It will introduce a platform-specific discrepancy that other
implementations will either need to implement or indicate that are not
compatible.

I would like to understand why original script is merged with the
batchfile stub in tools/rbinstall.rb

Perhaps we can remove that?

The only reason I see with this is PowerShell, which finds the
extensionless script prior the .bat one and attempts to execute it
(dunno why, but that is what it tries).

For users with PowerShell I've always recommend them use "ruby -S
script" instead.

Thank you for your time.
Posted by Nobuyoshi Nakada (nobu)
on 2011-07-21 16:08
(Received via mailing list)
Hi,

At Sun, 17 Jul 2011 05:22:32 +0900,
Luis Lavena wrote in [ruby-core:38108]:
> I would like to understand why original script is merged with the
> batchfile stub in tools/rbinstall.rb
>
> Perhaps we can remove that?

Removing the stub, or splitting to a batch file and a script
file?

> The only reason I see with this is PowerShell, which finds the
> extensionless script prior the .bat one and attempts to execute it
> (dunno why, but that is what it tries).

The reason is just that one file is handier than two files.
I know nothing about PowerShell.
Posted by Luis Lavena (luislavena)
on 2011-07-21 16:12
(Received via mailing list)
On Thu, Jul 21, 2011 at 11:07 AM, Nobuyoshi Nakada <nobu@ruby-lang.org> 
wrote:
> file?
>

Splitting to back and script file.

>> The only reason I see with this is PowerShell, which finds the
>> extensionless script prior the .bat one and attempts to execute it
>> (dunno why, but that is what it tries).
>
> The reason is just that one file is handier than two files.

What particular thing are you doing with the files? If I move I move
the entire directory.

Thank you.
Posted by drbrain (Eric Hodel) (Guest)
on 2013-01-25 22:49
(Received via mailing list)
Issue #4731 has been updated by drbrain (Eric Hodel).


Luis, Nobu, what is the status of this?
----------------------------------------
Bug #4731: ruby -S irb fails with mingw/msys vanilla builds
https://bugs.ruby-lang.org/issues/4731#change-35651

Author: rogerdpack (Roger Pack)
Status: Feedback
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version:
ruby -v: -


as reported originally with 
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
basically mingw builds fail with $ ruby -S irb and always have, at least 
for the 1.9 branches.

$ ruby -S irb
ruby: No such file or directory -- irb (LoadError)
Posted by Luis Lavena (luislavena)
on 2013-01-25 23:10
(Received via mailing list)
Issue #4731 has been updated by luislavena (Luis Lavena).

Status changed from Feedback to Assigned
Assignee changed from nobu (Nobuyoshi Nakada) to luislavena (Luis 
Lavena)

drbrain (Eric Hodel) wrote:
> Luis, Nobu, what is the status of this?

I proposed an alternate rbinstall.rb method in #6769 that will correct 
this issue.

However, workload has been high and code in rbinstall.rb is not very 
clear.


----------------------------------------
Bug #4731: ruby -S irb fails with mingw/msys vanilla builds
https://bugs.ruby-lang.org/issues/4731#change-35664

Author: rogerdpack (Roger Pack)
Status: Assigned
Priority: Normal
Assignee: luislavena (Luis Lavena)
Category:
Target version:
ruby -v: -


as reported originally with 
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
basically mingw builds fail with $ ruby -S irb and always have, at least 
for the 1.9 branches.

$ ruby -S irb
ruby: No such file or directory -- irb (LoadError)
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.