ingydotnet / io-all-pm

All in One Perl IO
http://search.cpan.org/dist/IO-All/
38 stars 20 forks source link

io->catfile( $io, $str ) fails on windows #74

Closed samuelckaufman closed 7 years ago

samuelckaufman commented 9 years ago
use strict;                              
use warnings FATAL => 'all';             

BEGIN {                                  
    $^O = 'MSWin32';                     
};                                       

use IO::All;                             
io->catfile( io->dir('/'), 'test.json' );

Operation "eq": no method found,
    left argument in overloaded package IO::All::Dir,
    right argument has no overloaded magic at /home/skaufman/perl5/perlbrew/perls/perl-5.20.0/lib/5.20.0/x86_64-linux/File/Spec/Win32.pm line 135.

Also see: http://www.cpantesters.org/cpan/report/608781a5-9264-1014-8cee-01022b825c07 For when that bug shows up from another package.

Googling around I found: http://www.nntp.perl.org/group/perl.beginners/2005/04/msg74371.html Which somewhat suggests that overloading "" is not enough, you may have to overload 'eq' as well. That seems odd to me, but maybe.

samuelckaufman commented 9 years ago
skaufman@yibberdibber:~ $ perl -MFile::Spec::Win32 -e 'warn File::Spec::Win32->VERSION'
3.47 at -e line 1.
samuelckaufman commented 9 years ago

adding use overload 'eq' => '_overload_stringify'; to IO::All fixes it, haarg suggested adding a fallback to _overload_stringify.

xlat commented 9 years ago

Would'nt it be better to add a cmp overload?

samuelckaufman commented 9 years ago

@xlat as long as it fixes the 'Operation "eq": no method found' I'm happy. The answer to your question as far as I'm concerned is if overloading cmp overloads eq by proxy then sure, that would be better.

xlat commented 9 years ago

@ediblenergy yes, it looks like to be the case if you take a look at the first test I have added to overload.t ;)

samuelckaufman commented 9 years ago

Ah cool now I see it, looks good to me :) I'll ping in #io-all because github notifications are terrible.

frioux commented 9 years ago

I'll try to get a fix released for this soonish; thanks for the research all!

wesQ3 commented 7 years ago

I have this issue as well on Windows using ->relative($path).

perl -MCarp::Always -E "use IO::All; my $p = io->dir('C:\Inetpub\log');
 my $f =  $p->file('06-30-2017.txt'); say $f->relative($p)"

Operation "eq": no method found,
        left argument in overloaded package IO::All::Dir,
        right argument has no overloaded magic at C:/Inetpub/lynx/strawberry/perl/site/lib/File/Spec/Win32.pm line 186.
        File::Spec::Win32::canonpath("File::Spec", IO::All::Dir=GLOB(0x3faf3c)) called at C:/Inetpub/lynx/strawberry/perl/site/lib/File/Spec/Unix.pm line 414
        File::Spec::Unix::abs2rel("File::Spec", "..\\..\\log\\06-30-2017.txt", IO::All::Dir=GLOB(0x3faf3c)) called at C:/Inetpub/lynx/strawberry/perl/site/lib/IO/All/Filesys.pm line 77
        IO::All::Filesys::relative(IO::All::File=GLOB(0x228a354), IO::All::Dir=GLOB(0x3faf3c)) called at -e line 1
frioux commented 7 years ago

Wes told me he'd write a test; I'll incorporate one of the fixes above, have him ensure that the test passes on win32 (and ofc I'll run on linux) and then I'll cut a rel.

wesQ3 commented 7 years ago

This is resolved in the 0.87 release and can be closed.