山本です。

>抜けてました。 on_
>
>すみません、なかださんのパッチでいいと思います。

あれこれ試してみたのですが、下のパッチが個人的に一番
わかりやすかったです。好みの問題なので、あとはお任せします。

Index: dir.c
===================================================================
--- dir.c	(revision 10)
+++ dir.c	(working copy)
@@ -891,11 +891,13 @@
 }
 
 /* System call with warning */
+extern int ruby_initialized(void);
+
 static int
 do_stat(const char *path, struct stat *pst)
 {
     int ret = stat(path, pst);
-    if (ret < 0 && errno != ENOENT)
+    if (ret < 0 && errno != ENOENT && ruby_initialized())
 	rb_protect((VALUE (*)(VALUE))rb_sys_warning, (VALUE)path, 0);
 
     return ret;
@@ -905,7 +907,7 @@
 do_lstat(const char *path, struct stat *pst)
 {
     int ret = lstat(path, pst);
-    if (ret < 0 && errno != ENOENT)
+    if (ret < 0 && errno != ENOENT && ruby_initialized())
 	rb_protect((VALUE (*)(VALUE))rb_sys_warning, (VALUE)path, 0);
 
     return ret;
@@ -915,7 +917,7 @@
 do_opendir(const char *path)
 {
     DIR *dirp = opendir(path);
-    if (dirp == NULL && errno != ENOENT && errno != ENOTDIR)
+    if (dirp == NULL && errno != ENOENT && errno != ENOTDIR && ruby_initialized())
 	rb_protect((VALUE (*)(VALUE))rb_sys_warning, (VALUE)path, 0);
 
     return dirp;
@@ -1121,15 +1123,21 @@
 static int
 glob_call_func(void (*func) (const char *, VALUE), const char *path, VALUE arg)
 {
-    int status;
-    struct glob_args args;
+    if (ruby_initialized()) {
+	int status;
+	struct glob_args args;
 
-    args.func = func;
-    args.c = path;
-    args.v = arg;
+	args.func = func;
+	args.c = path;
+	args.v = arg;
 
-    rb_protect(glob_func_caller, (VALUE)&args, &status);
-    return status;
+	rb_protect(glob_func_caller, (VALUE)&args, &status);
+	return status;
+    }
+    else {
+	func(path, arg);
+	return 0;
+    }
 }
 
 static int
@@ -1301,7 +1309,7 @@
     int n;
     int status;
 
-    if (flags & FNM_CASEFOLD) {
+    if (flags & FNM_CASEFOLD && ruby_initialized()) {
 	rb_warn("Dir.glob() ignores File::FNM_CASEFOLD");
     }
 
Index: eval.c
===================================================================
--- eval.c	(revision 10)
+++ eval.c	(working copy)
@@ -1330,6 +1330,12 @@
     ruby_running = 1;
 }
 
+int
+ruby_initialized(void)
+{
+    return ruby_running;
+}
+
 static VALUE
 eval_node(VALUE self, NODE *node)
 {