The error message is almost comically bad, but I think the problem is that you need to pass the return value of the parse_file method into the validate method:
my $doc = XML::LibXML->new()->parse_file('stsdef.xml');
my $rng = new XML::LibXML::RelaxNG(location => 'stsdef.rng');
$rng->validate($doc);