Calab has asked for the wisdom of the Perl Monks concerning the following question:

I'm running RHEL9 with perl 5.32. I am trying to get httpd (v2.4.62) to serve some perl scripts through a web browser. When a script is executed that uses Oracle, I get the following error appearing in the httpd/ssl_error_log:

Can't locate loadable object for module DBD::Oracle in @INC (@INC cont +ains: /usr/local/lib64/perl5/5.32 /usr/local/share/perl5/5.32 /usr/li +b64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 / +usr/share/perl5)

The Oracle instantclient v11.2 is installed (I need this version for the DB I connect to) and appears to be working properly. sqlplus runs without issues from the CLI. I've also installed the DBI v1.643 perl module from source. If I install DBI through CPAN it installs v1.647, which causes mismatch issues. When I installed DBI the make test passed, so I assume that it installed properly. make install also seemed to work fine.

When it says that it can't locate a loadable object for DBD::Oracle, I'm not sure what it's looking for, so I'm having issues verifying that everything did install as expected.

One thing to note... If I execute the perl script from the CLI as a user, I see the same error. If I execute it as root, it appears to work fine. All the files that I can find appear to have the correct permissions so I don't understand why this is happening.

Can anyone suggest why this is happening and what I should do to resolve this problem?

Thanks!

Update... This doesn't appear to have anything to do with httpd. If I execute the following I can see that root works, but other users do not:

As root there is no error:
perl -e 'use DBD::Oracle'

As a user there is an error:
perl -e 'use DBD::Oracle' Can't locate loadable object for module DBD::Oracle in @INC (@INC cont +ains: /usr/local/lib64/perl5/5.32 /usr/local/share/perl5/5.32 /usr/li +b64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 / +usr/share/perl5) at -e line 1. Compilation failed in require at -e line 1. BEGIN failed--compilation aborted at -e line 1.

Replies are listed 'Best First'.
Re: Can't locate loadable object for module DBD::Oracle in @INC
by Fletch (Bishop) on Apr 09, 2025 at 15:54 UTC

    If the perl -MDBD::Oracle -E 0 works as root but not as another (non-priviledged) user then the first thing I'd check is the permissions on the directories where it is found when running as root. As root run something like perl -MDBD::Oracle -E 'say $INC{qq{DBD/Oracle.pm}}' and then look at the containing and parent directories as well as their contents. Feels like something is missing the o+rx bits somewhere (either a directory or the shared object .so file in question).

    Edit: Another thing in addition to permissions is to look for differences in the environment between root and the not-working user(s; stuff running under apache won't have your usual login environment). Check that things like PERL5LIB or LD_LIBRARY_PATH aren't set to something for the former that's not for the others.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      I ran that command as root and the file is found:

      $ perl -MDBD::Oracle -E 'say $INC{qq{DBD/Oracle.pm}}' /usr/local/lib64/perl5/5.32/DBD/Oracle.pm

      Permissions on the file allow access to the file by the users as well as root. I can tail Oracle.pm as a user.

      Regarding the environment variables. That was an issue, but not THE issue. I had to add my environment variables to /etc/httpd/conf.d/env.conf and restart httpd for apache to see them. I'm not sure how else I could update the environment variables for the apache user. One thing I can't seem to do is add the /usr/local/instantclient directory to the path, since the env.conf file doesn't support expanding $PATH.

      Thanks for the help. It's appreciated!

        Regarding the environment variables. That was an issue, but not THE issue. I had to add my environment variables to /etc/httpd/conf.d/env.conf and restart httpd for apache to see them. I'm not sure how else I could update the environment variables for the apache user.

        Apache has PassEnv, SetEnv, and UnsetEnv in mod_env.

        One thing I can't seem to do is add the /usr/local/instantclient directory to the path, since the env.conf file doesn't support expanding $PATH.

        I don't think you need to do that. You basically need some DLLs from the instant client, that are referenced in the XS part of DBD::Oracle. So that's more a LD_LIBRARY_PATH problem and less a PATH problem. Installing instant client should already have taken care of that problem.

        There is an old trick that will probably still work. The environent variables for Oracle don't have to be set when the perl executable starts. It runs fine without them. The variables need to be set before perl loads DBD/Oracle.so and the DLLs from the Oracle client. So, you can set up the environment variables from within perl. That just has to happen before DBD::Oracle is loaded. The DBI module may already load DBD::Oracle way before you try to connect to Oracle, so it has to happen before loading DBI. Or, in a few lines of code:

        #!/usr/bin/perl use strict; use warnings; BEGIN { # This BEGIN block must come before "use DBI" and before "use DBD: +:Oracle", or this trick won't work! $ENV{'WHATEVER_ORACLE_WANTS'}='is set here'; $ENV{'MAYBE_EVEN_SEVERAL'}='environment variables'; } use DBI qw( ... ); # maybe hidden in your database handling module

        If you don't run a CGI or FastCGI script, but use mod_perl, you probably need to put the BEGIN block into a startup file (see PerlRequire for the ancient mod_perl 1.0, PerlConfigRequire and PerlPostConfigRequire for mod_perl 2.0).

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        "Can't locate loadable object for module DBD::Oracle" can also means it can't find/access dependencies. Use ldd on DBD/Oracle.so. It's probably going to be in a subdir of /usr/local/lib64/perl5/5.32. I'm guessing /usr/local/lib64/perl5/5.32/auto

Re: Can't locate loadable object for module DBD::Oracle in @INC
by hippo (Archbishop) on Apr 09, 2025 at 14:59 UTC
    When it says that it can't locate a loadable object for DBD::Oracle, I'm not sure what it's looking for, so I'm having issues verifying that everything did install as expected.

    You explained in detail about how you installed DBI but you have not mentioned installing DBD::Oracle. Did you do that? If not, that is what you must do.


    🦛

      Yes. DBD::Oracle has been installed using CPAN.