khippy has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'd like to install Expect.pm and give it a try on a slackware 7.0 with
perl, v5.6.1 built for i686-linux. I started cpan to install
Bundle::Expect, because this solves dependencies to IO:STty and IO::Tty
but cpan couldn 't finish because it stopped having found an error.

So I went to .cpan/build/ and found

IO-Stty-.02
IO-Tty-0.04
Expect-1.11

IO - stuff comes without 'make test', so I installed them and went to Expect
using the 4-times-hop, but it stops at 'make test' with this error-message:

...

1..7
ok 1
Expect: Could not assign a pty at blib/lib/Expect.pm line 87.
make: *** [test_dynamic] Error 22

and line 86/87 are:

$name_of_tty = $self->IO::Pty::ttyname();
die "$class: Could not assign a pty" unless $self->IO::Pty::ttyname();

I took a look at the IO:STty and IO::Tty and it is there, where the error comes from,
because the IO::Tty 'try' script doesn't work:
Using /root/.cpan/build/IO-Tty-0.04/blib
Use of uninitialized value in sysopen at /usr/local/lib/perl5/5.6.1/i686-linux/IO/File.pm line 159.
Use of uninitialized value in concatenation (.) or string at /root/.cpan/build/IO-Tty-0.04/blib/lib/IO/Pty.pm line 41.
Use of uninitialized value in concatenation (.) or string at /root/.cpan/build/IO-Tty-0.04/blib/lib/IO/Pty.pm line 41.
Cannot open as :No such file or directory at ./try line 12

This all happens as root, so what is the missing link?


there are no silly questions
killerhippy

Replies are listed 'Best First'.
(tye)Re: Expect can't assign a pseudo-tty
by tye (Sage) on Jun 22, 2001 at 22:25 UTC

    Run the test script in the debugger and set a break point line 159 of IO::File.

    Looking at that file, it seems that the caller to IO::File->open() with an undefined value. Taking a guess, I'd think that the caller tries to look up the name of the next available pseudo TTY to use, fails, doesn't notice the failure, and then tries to open undef.

    But by using the debugger you can determine what is the real problem and then rerun the test with a break point earlier (and in the caller) and probably figure out why.

            - tye (but my friends call me "Tye")
      Hi tye,
      thank your for your quick answer. I had to take time to
      come to know the debugger, and here is the result:

      ---cut-here---
      ~/.cpan/build/IO-Tty-0.04# perl -d try
      Default die handler restored.

      Loading DB routines from perl5db.pl version 1.07
      Editor support available.

      Enter h or `h h' for help, or `man perldebug' for more
      help.

      Using /root/.cpan/build/IO-Tty-0.04/blib
      main::(try:5): require POSIX;
      DB<1> f /usr/local/lib/perl5/5.6.1/i686-linux/IO/File.pm
      1 #
      2
      3 package IO::File;
      4
      5 =head1 NAME
      6 7 8 9 10
      DB<2> b 159
      DB<3> f try
      1 #!/usr/local/bin/perl -w
      2
      3: use blib;
      4: use IO::Pty;
      5==> require POSIX;
      6
      7
      8: $pty = new IO::Pty;
      9
      10: unless (@ARGV)
      DB<4> n
      POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:3):
      3: our(@ISA, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD) = ( );
      DB<4> n
      POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:9):
      9: our $VERSION = "1.03" ;
      DB<4>n
      POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:12):
      12: my $loaded;
      DB<4> n
      POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:24):
      24: XSLoader::load 'POSIX', $VERSION;
      DB<4> n
      POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:26):
      26: my $EINVAL = constant("EINVAL", 0);
      DB<4> n
      POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:27):
      27: my $EAGAIN = constant("EAGAIN", 0);
      DB<4> n
      POSIX::(/usr/local/lib/perl5/5.6.1/i686-linux/POSIX.pm:80):

      80: 1;
      81: __END__
      DB<4> n
      main::(try:8): $pty = new IO::Pty;
      DB<4> n
      main::(try:10): unless (@ARGV)
      main::(try:11): {
      DB<4>n
      main::(try:12): my $slave = $pty->slave;
      DB<4> n
      IO::File::open(/usr/local/lib/perl5/5.6.1/i686-linux/IO/File.pm:159):
      159: return sysopen($fh, $file, $mode, $perms);
      DB<4> print $fh
      IO::Tty=GLOB(0x846bf5c)
      DB<5> print $file
      Use of uninitialized value in print at (eval 18)[/usr/local/lib/perl5/5.6.1/perl5db.pl:1521]line 2.

      DB<6> print $mode
      2
      DB<7> print $perms
      438
      DB<8>
      ---cut-ends---

      As we can see, $file is undef, so you are right with
      your assumption. I also tried the code from
      SYNOPSIS of the IO::Pty documentation and there is
      the same error, it has an undef filename.

      Now I know *what* is wrong, but I still don't know
      *why*.

      Is there a module experienced helper out there ???

      thanx so far

      there are no silly questions
      killerhippy

        You need to change that "b 159" to instead set a break point near the top of that routine so you can see how $file is being set and then investigate that further.

                - tye (but my friends call me "Tye")