opatch auto failing "Can't locate Switch.pm in @INC"

This post is also available in: Português

Those days, when trying to run "opatch auto" on a Enterprise Linux 7 server to automatically patch my GI Home and all the Database Homes, I faced the following error:

[root@localhost 20834621]# opatch auto ./20485808 -ocmrf /tmp/ocm.rsp
Can't locate Switch.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /u01/app/11.2.4/grid/OPatch/crs/auto_patch.pl line 2730.
BEGIN failed--compilation aborted at /u01/app/11.2.4/grid/OPatch/crs/auto_patch.pl line 2730.

The problem was that Switch.pm lib was missing. Checking at MOS, I found the Doc ID 1915430.1 (Opatch Auto fails with: Can't locate Switch.pm) saying that in Perl 5.10 and above, the Switch module has been is deprecated and giving a workaround to download and install Switch.pm from www.cpan.org and then retry "opatch auto".

However, I did a much simpler thing that worked.

First, I looked for this file in my sever:

[root@localhost ~]# find / -name Switch.pm
/u01/app/oracle/product/11.2.4/dbhome_1/perl/lib/5.10.0/CGI/Switch.pm
/u01/app/oracle/product/11.2.4/dbhome_1/perl/lib/5.10.0/Switch.pm
/u01/app/11.2.4/grid/perl/lib/5.10.0/CGI/Switch.pm
/u01/app/11.2.4/grid/perl/lib/5.10.0/Switch.pm

Finally, I copied one of them to my perl lib dir:

[root@localhost ~]# cp -p $ORACLE_HOME/perl/lib/5.10.0/Switch.pm /usr/lib64/perl5/vendor_perl/

When re executing "opatch auto", everything worked like a charm.

Have you enjoyed? Please leave a comment or give a 👍!

6 comments

Skip to comment form

    • Manfred Konrad on August 25, 2015 at 03:42
    • Reply

    Thank you for your solution.

    First trial failed for me, because I copied the wrong Switch.pm First I used /grid/.../CGI/Switch.pm --> This gave many errors at opatch startup

    Second trial: cp -p perl/lib/5.10.0/Switch.pm /usr/share/perl5/vendor_perl/ --> Opatch works like a charm

    • Andreas on April 18, 2016 at 22:32
    • Reply

    Thanks, Really it works like a charm.

    • Edwin on October 21, 2016 at 03:30
    • Reply

    works like a charm, Thanks

    • Siraj on March 10, 2017 at 12:44
    • Reply

    Thanks for solution

    • Venkat on January 10, 2018 at 05:56
    • Reply

    Thanks for the solution!

    • Venkat on January 10, 2018 at 05:57
    • Reply

    Thanks!

Leave a Reply

Your email address will not be published.