2

I was installing the latest version of perl using brew on my Mac OSX and was then prompted by perl to use local::lib to create my own directory of Perl Packages downloaded from CPAN. Here is a history of my commands:

  431  brew install perl
#recommended to do by brew
  432    PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
  433    echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >> ~/.bash_profile
#executing recommendation
  434  sudo   PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
  436  echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >> ~/.bash_profile
  437  perl program.pl

I then tried running my perl script, but got this error:

Can't locate getopts.pl in @INC

So I installed Getopt::Std, which replaced getopt.pl

sudo cpan> install Perl4::CoreLibs

Then the perl script worked fine. However, it only worked in the terminal where I did all the above installations. I then tried to call other environment variables like 'python' or 'open -a TextEdit ~/.bash_profile' to see if those could be executed, but I get:

-bash: command: command not found

I tried looking for the bash_profile file, and can't seem to find that anywhere, perhaps it was deleted when this new directory was made? When I try to look for the path variable I get this, just not sure how to interpret:

    echo PATH=$PATH
PATH="/Users/miseq/perl5/bin${PATH:+:${PATH}}"; export PATH; PERL5LIB="/Users/miseq/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; PERL_LOCAL_LIB_ROOT="/Users/miseq/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; PERL_MB_OPT="--install_base \"/Users/miseq/perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=/Users/miseq/perl5"; export PERL_MM_OPT;

In addition, when I open a new terminal, I get this message:

-bash: perl: command not found

This leads me to believe that the perl installation I did is giving me this problem of not being able to call any environment variables from the shell. Any help with this?

Many Thanks

  • 1
    Logout and login – Rui F Ribeiro Aug 12 '16 at 16:58
  • I tried this. No help. Even restarted. – Labrat Aug 12 '16 at 17:02
  • Do you get an error calling /Users/miseq/perl5/bin/perl? – Julie Pelletier Aug 14 '16 at 6:35
0

The command you posted look correct, but evidently what ended up in your .bash_profile is not correct. The PATH variable contains the list of directories where the shell and other programs look for commands. This list is represented with the items joined together with a colon (:). For example, a simple PATH would be /usr/local/bin:/usr/bin:/bin, set with the shell command

PATH=/usr/local/bin:/usr/bin:bin

and then when you type the command ls, the shell looks for /usr/local/bin/ls, then for /usr/bin/ls, then /bin/ls, and executes the first one it finds.

In your case, the content of the variable is instructions to set the variable, rather than the actual list of directories. Since the list of directories doesn't contain any of the standard directories, your shell doesn't find any command except the few built-in ones.

Edit the file ~/.bash_profile and remove the invalid PATH settings, then open a new terminal. You can put # at the beginning of a line to comment it out. If you want to edit the file from a terminal, first set a sensible PATH, e.g. the one above (when you run this on the command line, it only has effect inside that terminal).

If you aren't sure what's good and what isn't, edit your question and copy-paste the content of ~/.bash_profile.

  • Thanks, what you recommended perfectly fixed things. Thanks a lot! – Labrat Aug 15 '16 at 1:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.