Skip Menu |

This queue is for tickets about the Tcl-pTk CPAN distribution.

Report information
The Basics
Id: 127552
Status: resolved
Priority: 0/
Queue: Tcl-pTk

People
Owner: CAC [...] cpan.org
Requestors: dm564009 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.95



Subject: macOS macPort
Date: Fri, 2 Nov 2018 16:27:32 +0100
To: bug-Tcl-pTk [...] rt.cpan.org
From: Dirk Miami <dm564009 [...] gmail.com>
Hello, I am not so sure this is a bug (or it is me missing some point), but I get the following error when trying to run a pTk script on a macOS with Tcl (8.6.8) installed through macports (the only Tcl installation available). Tcl.pm has been installed after I installed Tcl, so I do not think this is the problem. Error: Tcl procedure 'winfo' not found at /Users/dirk/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1/Tcl/pTk.pm line 788. I must admit that I am new to Tcl::pTk but I could not find any reference to this error.
On Fri Nov 02 10:27:50 2018, dm564009@gmail.com wrote:
Show quoted text
> Hello,
>
> I am not so sure this is a bug (or it is me missing some point), but I get
> the following error when trying to run a pTk script on a macOS with Tcl
> (8.6.8) installed through macports (the only Tcl installation available).
> Tcl.pm has been installed after I installed Tcl, so I do not think this is
> the problem. Error:
>
> Tcl procedure 'winfo' not found at
> /Users/dirk/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1/Tcl/pTk.pm
> line 788.
>
> I must admit that I am new to Tcl::pTk but I could not find any reference
> to this error.

It looks like you have both MacPorts’ perl and perlbrew present. I am not familiar with perlbrew, but what I imagine could be happening is that perlbrew’s perl command might be what appears first on your PATH, rather than the MacPorts’ perl command. Which perl command/binary is your script trying to use? A workaround might be to use the MacPorts-specific `perl5.26` command. However, if want to use anything specific to your perlbrew installation, then you might need to install Tcl::pTk from perlbrew instead.
 
I am not certain about this, but I am under the impression that Tcl::pTk (or any Perl module) installed from shouldn't be used with anything other than the MacPorts' Perl (currently /opt/local/bin/perl5.26, with symlinks /opt/local/bin/perl and /opt/local/bin/perl5). Likewise MacPorts' perl might not be able to use any modules not installed “outside” of MacPorts, whether from MacPorts’ perl, cpanm, etc. or with the `port` command if there’s already a port for them. It might still be safe to use MacPorts' Tcl/Tk from another Perl installation though.
 
The Tcl::pTk port is relatively new and is a work in progress, so I appreciate you having tried it out. You may want to make sure that the installed Tk port is installed as the +quartz variant rather than +x11 in order to use the aqua UI. However some of the Tcl::pTk dependencies (e.g. Tix) don’t yet support Tk +quartz; see https://trac.macports.org/ticket/56807
 
I believe I misunderstood your issue, and which port in MacPorts you were referring to. I apologize for doing so. If I understand correctly now, you've installed Tcl from MacPorts, and Tcl.pm and Tcl::pTk from perlbrew.

I believe your issue is that you have installed Tcl from MacPorts without also installing Tk, since I can replicate the Tcl procedure 'winfo' not found at …/Tcl/pTk.pm line 786 error if Tcl is installed but not Tk. Tk is a separate port from Tcl, as is the case for many package managers. Normally, if installing Tcl::pTk using its Makefile.PL, there will be an error like the following if Tcl is present but not Tk:



#####################  Error   ####################################
Your Tcl installation (/opt/local/bin/tclsh8.6) doesn't appear to include the Tk package.
One of possible reasons is missing file 'pkgIndex.tcl' in ..../tk8.4/
directory; Please check if you can feed 'package require Tk' to tclsh

 
Though it might be a good idea if Tcl::pTk produced a more useful error message.

It should be fine to use Tcl/Tk from MacPorts and Tcl.pm, Tcl::pTk from perlbrew. In your case either sudo port install tk +quartz or sudo port install tk +x11 should work. You may need to install additional Tk extensions like Tklib and Tix; again, MacPorts currently only provides Tix for the X11 variant of Tk.
 
On Tue Nov 06 15:39:57 2018, CAC wrote:
Show quoted text
> Normally, if installing Tcl::pTk using its Makefile.PL, there will be an error like
> the following if Tcl is present but not Tk:
>
>
> ##################### Error ####################################
Show quoted text
> Your Tcl installation (/opt/local/bin/tclsh8.6) doesn't appear to include the
> Tk package.One of possible reasons is missing file 'pkgIndex.tcl' in
> ..../tk8.4/directory;
> Please check if you can feed 'package require Tk' to tclsh
>
> Though it might be a good idea if Tcl::pTk produced a more useful error message.

Tcl::Tk (which Tcl::pTk is based on) recently did just this, so I will probably copy that change over for the next version of Tcl::pTk. That way, if Tk is missing, it would produces errors like these instead:

can't find package Tk 8.6 at …/lib/Tcl/pTk.pm line 1173.
can't find package Tk at …/lib/Tcl/pTk.pm line 1173.
On Wed Nov 07 16:19:06 2018, CAC wrote:
Show quoted text
> On Tue Nov 06 15:39:57 2018, CAC wrote:
> > Normally, if installing Tcl::pTk using its Makefile.PL, there will be
> > an
> error like
> > the following if Tcl is present but not Tk:
> >
> >
> > ##################### Error ####################################
> > Your Tcl installation (/opt/local/bin/tclsh8.6) doesn't appear to
> > include the
> > Tk package.One of possible reasons is missing file 'pkgIndex.tcl' in
> > ..../tk8.4/directory;
> > Please check if you can feed 'package require Tk' to tclsh
> >
> > Though it might be a good idea if Tcl::pTk produced a more useful
> > error
> message.
>
> Tcl::Tk (which Tcl::pTk is based on) recently did just this, so I will
> probably
> copy that change over for the next version of Tcl::pTk. That way, if
> Tk is
> missing, it would produces errors like these instead:
>
> can't find package Tk 8.6 at …/lib/Tcl/pTk.pm line 1173.can't find
> package Tk
> at …/lib/Tcl/pTk.pm line 1173.

https://github.com/chrstphrchvz/perl-tcl-ptk/commit/a635b44c98aba6064b6302dc6e2bc5f6af5dbfe8
Hi Dirk,

I had released Tcl::pTk 0.95 to improve the error shown if Tk isn't found. Feel free to reopen if there's more to this issue that needs to be addressed.

Also, the Tk extensions used by Tcl::pTk (Tix, tkImg, tktable) are all now available in MacPorts with +quartz variants.