Re: Tk using Ruby

In addition ro ruby (and tk), you'll need to have the ruby (and tk)
development headers:

  mkmf.rb can't find header files for ruby at
  /usr/lib/ruby/include/ruby.h
  You might have to install separate package for the ruby
  development environment, ruby-dev or ruby-devel for example.

The details differ from OS to OS, e.g. I've used something like this to
play with ruby, tk, and glimmer on Debian:

···

On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:

I want to fool around with the `Tk' GUI environment.
tried `gem install tk'. No Joy! Output at:
5665a011 - Ruby Tk

Thanks Frank! Sadly, I can't get it installed. Appears to be too
much of a PITA to use Tk with Ruby, IMHO. Patience running out.
Much obliged for your input.

···

On Sat, 18 Dec 2021 14:11:47 -0500 "Frank J. Cameron" <fjc@fastmail.net> wrote:

On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:
> I want to fool around with the `Tk' GUI environment.
> tried `gem install tk'. No Joy! Output at:
> 5665a011 - Ruby Tk

In addition ro ruby (and tk), you'll need to have the ruby (and
tk) development headers:

  mkmf.rb can't find header files for ruby at
  /usr/lib/ruby/include/ruby.h
  You might have to install separate package for the ruby
  development environment, ruby-dev or ruby-devel for
example.

The details differ from OS to OS, e.g. I've used something like
this to play with ruby, tk, and glimmer on Debian:

Installing Ruby Tk bindings/gem on Ubuntu – Saverio Miroddi – 64K RAM SYSTEM  38911 BASIC BYTES FREE

--
Duke
** Text only please. Bottom post is best. **

Yes, whenever you get into building native extensions, there's potentially
a lot of details to sort out, even down to different Linux distribution
flavors. Native libraries can be a PITA.

I would say, keep a list of the problems, take it a little chunk at a time,
and treat it as a learning experience. You'll definitely learn a bunch
about the Tk ecosystem. Good news is, you generally have to fix native
compilation problems only one time.

Good luck, Tk is cool !! :+1:

···

On Sat, Dec 18, 2021 at 1:12 PM Frank J. Cameron <fjc@fastmail.net> wrote:

On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:
> I want to fool around with the `Tk' GUI environment.
> tried `gem install tk'. No Joy! Output at:
> 5665a011 - Ruby Tk

> > I want to fool around with the `Tk' GUI environment.
> > tried `gem install tk'. No Joy! Output at:
> > 5665a011 - Ruby Tk
>

[snip]

I would say, keep a list of the problems, take it a little chunk
at a time, and treat it as a learning experience. You'll
definitely learn a bunch about the Tk ecosystem. Good news is,
you generally have to fix native compilation problems only one
time.

I agree! I've used Tk in other languages. I like it. I think that
part of my problems id the version of the Linux distro that I'm
using - antiX. It's a Debian/buster based distro.

Anyway, I'll keep learning Ruby w/o Tk etc for the time being. Thx!!

···

On Sat, 18 Dec 2021 13:41:52 -0600 Sean Felipe Wolfe <ether.joe@gmail.com> wrote:

On Sat, Dec 18, 2021 at 1:12 PM Frank J. Cameron > <fjc@fastmail.net> wrote:
> On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:

--
Duke
** Text only please. Bottom post is best. **

This laptop is running Debian 11, but I have an antiX one too (just not
handy at the moment). But, I would think that the steps in the blog
post from Saverio Miroddi for installing ruby/tk on Ubuntu should work
on antiX as well.

···

Duke Normandin <dukeofpurl@gmx.com> wrote:

I've used Tk in other languages. I like it. I think that part of my
problems id the version of the Linux distro that I'm using - antiX. It's
a Debian/buster based distro.

Anyway, I'll keep learning Ruby w/o Tk etc for the time being. Thx!!

If I get a chance to grab the antiX laptop tonight, I'll give it a shot
and let you know. :slight_smile:

···

On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:

Thanks Frank! Sadly, I can't get it installed. Appears to be too
much of a PITA to use Tk with Ruby, IMHO. Patience running out.
Much obliged for your input.

Much obliged! I followed the steps given at that site, but nothing
seems to work.

···

On Sat, 18 Dec 2021 15:13:46 -0500 "Frank J. Cameron" <fjc@fastmail.net> wrote:

On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:
> Thanks Frank! Sadly, I can't get it installed. Appears to be too
> much of a PITA to use Tk with Ruby, IMHO. Patience running out.
> Much obliged for your input.

If I get a chance to grab the antiX laptop tonight, I'll give it
a shot and let you know. :slight_smile:

--
Duke
** Text only please. Bottom post is best. **

Ah, I see; that page just covered the tk bits, but skipped the general
ruby development headers:

  sudo apt-get install ruby-dev

(or, install ruby-full which should pull ruby-dev as a dependency)

···

On 12/18/21, Frank J. Cameron <fjc@fastmail.net> wrote:

On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:

Thanks Frank! Sadly, I can't get it installed. Appears to be too
much of a PITA to use Tk with Ruby, IMHO. Patience running out.
Much obliged for your input.

If I get a chance to grab the antiX laptop tonight, I'll give it a shot
and let you know. :slight_smile:

sudo apt-get install ruby-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ruby-dev is already the newest version (1:2.5.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

···

On Sat, 18 Dec 2021 15:30:55 -0500 "Frank J. Cameron" <fjc@fastmail.net> wrote:

On 12/18/21, Frank J. Cameron <fjc@fastmail.net> wrote:
> On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:
>> Thanks Frank! Sadly, I can't get it installed. Appears to be
>> too much of a PITA to use Tk with Ruby, IMHO. Patience running
>> out. Much obliged for your input.
>
> If I get a chance to grab the antiX laptop tonight, I'll give
> it a shot and let you know. :slight_smile:

Ah, I see; that page just covered the tk bits, but skipped the
general ruby development headers:

  sudo apt-get install ruby-dev

(or, install ruby-full which should pull ruby-dev as a dependency)

--
Duke
** Text only please. Bottom post is best. **

I'd just follow the Pre-Requisite instructions in Glimmer DSL for Tk:

I've never had any issues compiling the tk gem on any platform, be it Mac,
Windows, or Linux.

Tk setup is supposed to be totally straight-forward with those instructions
regardless of native extensions.

Cheers,

···

On Sat, Dec 18, 2021 at 3:48 PM Duke Normandin <dukeofpurl@gmx.com> wrote:

On Sat, 18 Dec 2021 15:30:55 -0500 > "Frank J. Cameron" <fjc@fastmail.net> wrote:

> On 12/18/21, Frank J. Cameron <fjc@fastmail.net> wrote:
> > On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:
> >> Thanks Frank! Sadly, I can't get it installed. Appears to be
> >> too much of a PITA to use Tk with Ruby, IMHO. Patience running
> >> out. Much obliged for your input.
> >
> > If I get a chance to grab the antiX laptop tonight, I'll give
> > it a shot and let you know. :slight_smile:
>
> Ah, I see; that page just covered the tk bits, but skipped the
> general ruby development headers:
>
> sudo apt-get install ruby-dev
>
> (or, install ruby-full which should pull ruby-dev as a dependency)

sudo apt-get install ruby-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ruby-dev is already the newest version (1:2.5.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
--
Duke
** Text only please. Bottom post is best. **

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Andy Maleh

LinkedIn: Andy Maleh - Lexop | LinkedIn
<https://www.linkedin.com/in/andymaleh&gt;
Blog: http://andymaleh.blogspot.com
GitHub: http://www.github.com/AndyObtiva

Seem to have multiple rubies? From the first email:

  /usr/bin/ruby2.7
  ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23)

But, ruby-dev was v. 2.5.1. How did you install the ruby2.7?

···

On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:

  sudo apt-get install ruby-dev

$ sudo apt-get install ruby-dev
ruby-dev is already the newest version (1:2.5.1).

Can't recall! But it works OK.
Installed ruby-dev today with `synaptic'.

···

On Sat, 18 Dec 2021 16:42:52 -0500 "Frank J. Cameron" <fjc@fastmail.net> wrote:

On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:
>> sudo apt-get install ruby-dev
>
> $ sudo apt-get install ruby-dev
> ruby-dev is already the newest version (1:2.5.1).

Seem to have multiple rubies? From the first email:

  /usr/bin/ruby2.7
  ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23)

But, ruby-dev was v. 2.5.1. How did you install the ruby2.7?

The specific instructions I am referring to for Linux (regardless of
distro) are:

   - Download the ActiveTcl Linux package from ActiveState.com (VERY
   IMPORTANT REQUIRED STEP! ALTERNATIVE DIRECT-PACKAGE-INSTALL METHODS ARE OLD
   AND OUTDATED. AVOID THEM!)
   - Extract the tar gz file using this command (anywhere under home ~
   directory): `tar zxvf ActiveTcl-version-number.tar.gz`
   - Run included install shell script:
   `./ActiveTcl-version-number/install.sh`
   - Install RVM by running: `\curl -sSL https://get.rvm.io | bash -s
   stable` (and run: `curl -sSL https://rvm.io/pkuczynski.asc | gpg
   --import -` if needed for mentioned security reasons)
   - Run: `rvm install 3.0.2 --enable-shared --enable-pthread --with-tk
   --with-tcl` (VERY IMPORTANT STEP IN STREAMLINING LATER INSTALLATION OF TK
   GEM WITHOUT ISSUE. NOTE THAT RUBY CAN BE ANY VERSION YOU WANT, BUT LATEST
   IS RECOMMENDED)
   - Run: gem install tk
   - Run: gem install glimmer-dsl-tk

Every once in a while, I run into people complaining about not being able
to get Tk to run while INTENTIONALLY not following the correct
instructions. Obviously, that won't work! Nothing is surprising there!
Follow the correct instructions, the source of which is the official Tcl/Tk
instructions, and you will get Tk working in no time!

···

On Sat, Dec 18, 2021 at 4:51 PM Duke Normandin <dukeofpurl@gmx.com> wrote:

On Sat, 18 Dec 2021 16:42:52 -0500 > "Frank J. Cameron" <fjc@fastmail.net> wrote:

> On 12/18/21, Duke Normandin <dukeofpurl@gmx.com> wrote:
> >> sudo apt-get install ruby-dev
> >
> > $ sudo apt-get install ruby-dev
> > ruby-dev is already the newest version (1:2.5.1).
>
> Seem to have multiple rubies? From the first email:
>
> /usr/bin/ruby2.7
> ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23)
>
> But, ruby-dev was v. 2.5.1. How did you install the ruby2.7?

Can't recall! But it works OK.
Installed ruby-dev today with `synaptic'.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Andy Maleh

LinkedIn: Andy Maleh - Lexop | LinkedIn
<https://www.linkedin.com/in/andymaleh&gt;
Blog: http://andymaleh.blogspot.com
GitHub: http://www.github.com/AndyObtiva

Okay, I'll take a look at an antiX laptop tonight.
Andy's rvm-based install should also work on antiX.

···

Duke Normandin <dukeofpurl@gmx.com> wrote:

How did you install the ruby2.7?

Can't recall! But it works OK.
Installed ruby-dev today with `synaptic'.

I don't see why I need to install a ruby VM and ActiveState Tcl/Tk
when I have ruby _and_ tcl working on my laptop. I'm sure that it
works just dandy, but ...

···

On Sat, 18 Dec 2021 17:21:40 -0500 "Frank J. Cameron" <fjc@fastmail.net> wrote:

Duke Normandin <dukeofpurl@gmx.com> wrote:
>> How did you install the ruby2.7?
>
> Can't recall! But it works OK.
> Installed ruby-dev today with `synaptic'.

Okay, I'll take a look at an antiX laptop tonight.
Andy's rvm-based install should also work on antiX.

--
Duke
** Text only please. Bottom post is best. **

Got my antiX laptop, the default system packages are ruby-2.5:

$ ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]

$ dpkg -l ruby ruby-dev
ii ruby 1:2.5.1 amd64 Interpreter of
object-oriented scripting language Ruby (default version)
ii ruby-dev:amd64 1:2.5.1 amd64 Header files for
compiling extension modules for Ruby (default version)

$ ls -l /usr/bin/ruby*
lrwxrwxrwx 1 root root 7 Mar 21 2018 /usr/bin/ruby -> ruby2.5
-rwxr-xr-x 1 root root 14328 Oct 13 2020 /usr/bin/ruby2.5

Following that blog post:

# install tcl/tk and dev

$ sudo gem install tk -- \

  --with-tcltkversion="$latest_version" \
  --with-tcl-lib=/usr/lib/x86_64-linux-gnu \
  --with-tk-lib=/usr/lib/x86_64-linux-gnu \
  --with-tcl-include=/usr/include/tcl"$latest_version" \
  --with-tk-include=/usr/include/tcl"$latest_version" \
  --enable-pthread

Fetching: tk-0.4.0.gem (100%)
Building native extensions with: '--with-tcltkversion=8.6
--with-tcl-lib=/usr/lib/x86_64-linux-gnu
--with-tk-lib=/usr/lib/x86_64-linux-gnu
--with-tcl-include=/usr/include/tcl8.6
--with-tk-include=/usr/include/tcl8.6 --enable-pthread'
This could take a while...
Successfully installed tk-0.4.0
Parsing documenke it easitation for tk-0.4.0
Installing ri documentation for tk-0.4.0
Done installing documentation for tk after 45 seconds
1 gem installed

It would be helpful if we knew how you installed the ruby2.7; that
could make it easier to ind the right ruby headers. Or, you could
rollback and use the system ruby2.5. Or, do I new, clean install of
ruby2.7 (manual build, rbenv, rvm, fullstaq packages) and use that
instead (should still work with the system tk without needing
activestate, but your chice).

Great! Saved your post!
Here's what I've got:

ls /lib/ruby
2.5.0 2.7.0 gems vendor_ruby

ls -l /usr/bin/ruby*
lrwxrwxrwx 1 root root 7 Oct 18 2020 /usr/bin/ruby -> ruby2.7
-rwxr-xr-x 1 root root 14328 Jul 8 13:10 /usr/bin/ruby2.7

So I'm linked to a newer version. I suppose that I'll have to link
to 2.5.0 if I want to pursue the Ruby/Tk experiment.

···

On Sat, 18 Dec 2021 18:06:07 -0500 "Frank J. Cameron" <fjc@fastmail.net> wrote:

Got my antiX laptop, the default system packages are ruby-2.5:

--
Duke
** Text only please. Bottom post is best. **