Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4622

Failing to load Ruby's tk on Ubuntu

$
0
0

I am really new to Ruby and I need to use this library for a specific GUI project. I am using:

  • Ubuntu 18.04.5 LTS;
  • ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

My problem is similar to the one this person described a few months ago. I have tried the solution posted on that SO page which is based on this blog post.

After running:

sudo apt-get install tcl8.5-dev tk8.5-dev

And:

sudo gem install tk

I get the following error message:

    Building native extensions. This could take a while...ERROR:  Error installing tk:    ERROR: Failed to build gem native extension.    current directory: /var/lib/gems/2.5.0/gems/tk-0.4.0/ext/tk/usr/bin/ruby2.5 -r ./siteconf20210424-11015-1mre8d0.rb extconf.rbmkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.hextconf failed, exit code 1Gem files will remain installed in /var/lib/gems/2.5.0/gems/tk-0.4.0 for inspection.Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/tk-0.4.0/gem_make.out

This error message is different from the one described in the blog post which is:

$ gem install tkBuilding native extensions. This could take a while...ERROR:  Error installing tk:  ERROR: Failed to build gem native extension.# ...Search tcl.hchecking for tcl.h... noSearch tk.hchecking for tk.h... noSearch Tcl library............*** extconf.rb failed ***# ...Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options.Can't find proper Tcl/Tk libraries. So, can't make tcltklib.so which is required by Ruby/Tk.If you have Tcl/Tk libraries on your environment, you may be able to use them with configure options (see ext/tk/README.tcltklib).The gem provides many switches for specifying the configuration parameters, however, the related parameters (--with-tk-lib and --with-tcl-lib) don’t yield the desired effect (actually, any effect at all).The workaround, originally found in a Ruby forum is to symlink the libraries to the paths where the extension expects 

Then, after running:

sudo ln -s /usr/lib/x86_64-linux-gnu/tcl8.5/tclConfig.sh /usr/lib/sudo ln -s /usr/lib/x86_64-linux-gnu/tk8.5/tkConfig.sh /usr/lib/sudo ln -s /usr/lib/x86_64-linux-gnu/libtcl8.5.so.0 /usr/lib/sudo ln -s /usr/lib/x86_64-linux-gnu/libtk8.5.so.0 /usr/lib/

I get this (probably because I tried the same steps before):

ln: failed to create symbolic link '/usr/lib/libtk8.5.so.0': File exists

Finally, running the last step does not work:

sudo gem install tk

And the terminal returns the following error message:

Building native extensions. This could take a while...ERROR:  Error installing tk:    ERROR: Failed to build gem native extension.    current directory: /var/lib/gems/2.5.0/gems/tk-0.4.0/ext/tk/usr/bin/ruby2.5 -r ./siteconf20210424-21301-8u83wl.rb extconf.rbmkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.hextconf failed, exit code 1Gem files will remain installed in /var/lib/gems/2.5.0/gems/tk-0.4.0 for inspection.

What should I do?

Thanks in advance.


Viewing all articles
Browse latest Browse all 4622


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>