From: Luis Lavena Date: 2011-06-22T00:44:25+09:00 Subject: [ruby-core:37262] Re: 1.8.7 release next month On Sun, Jun 19, 2011 at 10:55 PM, Hidetoshi NAGAI wrote: > > I can't generate the problem. > "ruby -r tk -e 'p Tk.tk_call("info", "library")'" prints the value of > TCL_LIBRARY environment variable. > Is the env var really exported? > When not do "export TCL_LIBRARY" on the terminal, the value of the env > var has no effect. Hello, I'll try to clarify my previous statement. Tcl/Tk libs are not placed in the default directory ($ruby/lib) but instead in a custom directory ($ruby/lib/tcltk) Because of it, attempting to require 'tk' fails because is unable to find init.tcl anywhere in the whole path options for lib. What we did, as this patch shows: https://github.com/oneclick/rubyinstaller/blob/master/resources/patches/tk/0002-Use-Tcl-Tk-from-different-directory.diff Is set TCL_LIBRARY before loading the C extension. This works perfectly against 1.9.3 (trunk), but fails on 1.8.7 TCL_LIBRARY is set inside Ruby and can't be set/exported from outside ruby code because that will pollute the environment. Your example works on trunk: V:\sandbox>ruby -v ruby 1.9.3dev (2011-06-21 trunk 32188) [i386-mingw32] V:\sandbox>ruby -r tk -e 'p Tk.tk_call("info", "library")'" "V:/sandbox/ruby19_mingw/lib/tcltk/tcl8.5" But fails with ruby_1_8_7 branch: V:\sandbox>ruby -v ruby 1.8.7 (2011-06-16 patchlevel 348) [i386-mingw32] V:\sandbox>ruby -r tk -e 'p Tk.tk_call("info", "library")'" V:/sandbox/ruby18_mingw/lib/ruby/1.8/tk.rb:1132:in `initialize': Can't find a usable init.tcl in the following directories: (RuntimeError) V:/sandbox/ruby18_mingw/lib/tcl8.5 V:/sandbox/ruby18_mingw/lib/tcl8.5 V:/sandbox/lib/tcl8.5 V:/sandbox/ruby18_mingw/library V:/sandbox/library V:/sandbox/tcl8.5.9/library V:/tcl8.5.9/library This probably means that Tcl wasn't installed properly. from V:/sandbox/ruby18_mingw/lib/ruby/1.8/tk.rb:1132:in `new' from V:/sandbox/ruby18_mingw/lib/ruby/1.8/tk.rb:1132 === As you can see, it is ignoring TCL_LIBRARY value set from inside Ruby itself. Now, setting it from outside the process works: V:\sandbox>set TCL_LIBRARY Environment variable TCL_LIBRARY not defined V:\sandbox>SET TCL_LIBRARY=V:\sandbox\ruby18_mingw\lib\tcltk\tcl8.5 V:\sandbox>ruby -r tk -e 'p Tk.tk_call("info", "library")'" "V:\\sandbox\\ruby18_mingw\\lib\\tcltk\\tcl8.5" === Which could indicate another problem with TCL_LIBRARY? -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup�ry