in reply to Can't locate loadable object for module DBD::Oracle in @INC

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.

Replies are listed 'Best First'.
Re^2: Can't locate loadable object for module DBD::Oracle in @INC
by Calab (Initiate) on Apr 09, 2025 at 17:01 UTC

    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

        Thank you very much!

        It was indeed a permissions issue in the auto directory. Everything appears to be working well now.

        Thanks for the help everyone!