Eli Foster
Eli Foster

Reputation: 68

Can't locate custom module in @INC

I have a basic Perl script that runs code from a module. After switching to a new computer, I am no longer able to run this script. The directory tree is set up like so:

SatanicBot
  src
    SatanicBot
      Bot.pm
      Utils.pm
  run.pl <-- The script that uses the module

The use statements in run.pl are like so:

use warnings;
use strict;
use diagnostics;

use Bot::BasicBot;

use Cwd qw(abs_path);
use FindBin;
use lib abs_path("$FindBin::Bin/SatanicBot");
# Without this, I get an error that is essentially caused by it not being to find the module.
use SatanicBot::Bot; 

When I run run.pl, I get the following error:

Can't locate SatanicBot/Bot.pm in @INC (you may need to install the SatanicBot::Bot module) (@INC contains: /Users/elifoster/Desktop/Dev/SatanicBot/src/SatanicBot /Users/elifoster/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/darwin-2level /Users/elifoster/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0 /Users/elifoster/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/darwin-2level /Users/elifoster/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0 .) at src/run.pl line 12.

As you can see, it states that @INC contains the directory that the SatanicBot::Bot module is in, yet it cannot find it. I'm seriously stumped.

Upvotes: 1

Views: 1602

Answers (1)

mob
mob

Reputation: 118665

@INC contains:

/Users/elifoster/Desktop/Dev/SatanicBot/src/SatanicBot

but to find the SatanicBot::Bot package in the file /Users/elifoster/Desktop/Dev/SatanicBot/src/SatanicBot/Bot.pm, you want @INC to contain

/Users/elifoster/Desktop/Dev/SatanicBot/src

Upvotes: 4

Related Questions