title: Ruby require 'tk' yields LoadError: no such file to load -- tk
body: <p>I'm not able to get ruby to <strong>require  'tk'</strong> successfully. I'm using rvm, ruby 2.0.0, ActiveTcl-8.6, and Ubuntu 12.04 LTS. I have run <strong>wish</strong> provided with ActiveTcl and it seems to be working.</p>
  
  <p>I've looked on the RVM site <a href="http://rvm.io/integration/tk" rel="nofollow noreferrer">http://rvm.io/integration/tk</a> and several StackOverflow questions like this one <a href="https://stackoverflow.com/questions/16113143/rvm-ruby-with-tk-installation-osx">RVM Ruby with TK installation (OSX)</a>.</p>
  
  <p>I have tried <strong>rvm reinstall 2.0.0 --enable-shared --enable-pthread --with-tk --with-tcl</strong> several times on different versions of ruby with no success.</p>
  
  <p>Any thoughts?</p>
  
  <p>When I run irb and do <strong>require'tk'</strong> I get the following:</p>
  
  <pre><code>LoadError: cannot load such file -- tk
  from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from (irb):2
  from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `&lt;main&gt;'
  </code></pre>
  
  <p>When this works I think you should get <strong>true</strong> returned.</p>
  
  <p>I haven't tried anything else mainly because I can't figure out what else to do. I've been looking into how require works and checking the load path with <strong>ruby -e '$:'</strong> I get</p>
  
  <pre><code>[brooks@ubuntu:~/sites/depot]$ruby -e 'puts $:'
  /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0
  /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/x86_64-linux
  /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby
  /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/vendor_ruby/2.0.0
  /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/vendor_ruby/2.0.0/x86_64-linux
  /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/vendor_ruby
  /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0
  /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/x86_64-linux
  </code></pre>
  
  <p>This looks like what you would expect, I think. Sorry for the formatting, I'm new to the editor.</p>
  
  <p>Following up on the idea that it's a path problem, I found tk.rb in my files and tried the following in irb:</p>
  
  <pre><code>2.0.0-p353 :003 &gt; require '/home/brooks/.rvm/src/ruby-2.0.0-p353/ext/tk/lib/tk'   
  LoadError: cannot load such file -- tcltklib
  from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /home/brooks/.rvm/src/ruby-2.0.0-p353/ext/tk/lib/tk.rb:6:in `&lt;top (required)&gt;'
  from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from (irb):3
  from /home/brooks/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `&lt;main&gt;'
  </code></pre>
  
  <p>So now it's <strong>require 'tcltklib'</strong> in the tk.rb file that's causing the problem. This seems to confirm that there is some issue with $PATH or $load_path. But a search for the file tcltklib.rb turns up nothing. There is a tcltklib.c file.</p>
  
  <hr>
  
  <p>I tried a few more things. After a more careful reading of the output of the ruby installs via rvm, there was a warning about the X11 lib not being installed and that Tk wouldn't be active after the ruby build. I did <strong>sudo apt-get install libx11-dev</strong> and then <strong>rvm reinstall 2.0.0 --enable-shared --enable-pthread --with-tk --with-tcl</strong> again. This time in irb <strong>require 'tk'</strong> caused a core dump. I tried it another time and it worked. I then ran a short ruby script that also uses <strong>require 'tk'</strong>. It also core dumped, but worked after a few tries. Now it's hit or miss for both, sometimes works, sometimes it core dumps. </p>