Comment installer Perl DBD :: Oracle avec Oracle Instant Client sur macOS Catalina

Dec 17 2020

J'exécute macOS Catalina 10.15.7 et je dois installer Oracle Instant Client pour exécuter un script Perl qui se connecte à une base de données.

1. Installation d'Oracle Instant Client

J'ai téléchargé les packages dont j'avais besoin:

  • Ensemble d'éclairage de base (DMG)
  • Package SDK (DMG)
  • Package ODBC (DMG)

À partir d'Instant Client 19.8 et suivi les instructions d'installation sans aucun problème (il suffit de copier et coller)

Les fichiers sont extraits dans /Users/username/Downloads/instantclient_19_8

2. Réglage ORACLE_HOME

Ensuite, j'ai défini ORACLE_HOME sur /Users/username/Downloads/instantclient_19_8

export ORACLE_HOME=/Users/username/Downloads/instantclient_19_8

3. Installation DBD::Oracle

Lorsque j'ai essayé d'installer, DBD::Oraclej'ai eu l'erreur suivante:

$ cpanm DBD::Oracle
--> Working on DBD::Oracle
Fetching http://www.cpan.org/authors/id/M/MJ/MJEVANS/DBD-Oracle-1.80.tar.gz ... OK
Configuring DBD-Oracle-1.80 ... N/A
! Configure failed for DBD-Oracle-1.80. See /Users/username/.cpanm/work/1608142485.48272/build.log for details.

Le contenu du fichier journal:

$ cat /Users/username/.cpanm/work/1608142485.48272/build.log
cpanm (App::cpanminus) 1.7044 on perl 5.032000 built for darwin-thread-multi-2level
Work directory is /Users/username/.cpanm/work/1608142485.48272
You have make /usr/bin/make
You have LWP 6.47
You have /usr/bin/tar: bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6
You have /usr/bin/unzip
Searching DBD::Oracle () on cpanmetadb ...
--> Working on DBD::Oracle
Fetching http://www.cpan.org/authors/id/M/MJ/MJEVANS/DBD-Oracle-1.80.tar.gz
-> OK
Unpacking DBD-Oracle-1.80.tar.gz
Entering DBD-Oracle-1.80
Checking configure dependencies from META.json
Checking if you have Config 0 ... Yes (5.032000)
Checking if you have Encode 0 ... Yes (3.06)
Checking if you have Math::BigInt 0 ... Yes (1.999818)
Checking if you have Devel::Peek 0 ... Yes (1.28)
Checking if you have Test::More 0 ... Yes (1.302177)
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.44)
Checking if you have Data::Dumper 0 ... Yes (2.174)
Checking if you have DBI 1.623 ... Yes (1.643)
Checking if you have Test::NoWarnings 0 ... Yes (1.04)
Configuring DBD-Oracle-1.80
Running Makefile.PL
Using DBI 1.643 (for perl 5.032000 on darwin-thread-multi-2level) installed in /usr/local/Cellar/perl/5.32.0/lib/perl5/site_perl/5.32.0/darwin-thread-multi-2level/auto/DBI/
Configuring DBD::Oracle for perl 5.032000 on darwin (darwin-thread-multi-2level)

If you encounter any problem, a collection of troubleshooting
guides are available under lib/DBD/Oracle/Troubleshooting.
'DBD::Oracle::Troubleshooting' is the general troubleshooting
guide, while platform-specific troubleshooting hints
live in their labelled sub-document (e.g., Win32
hints are gathered in 'lib/DBD/Oracle/Troubleshooting/Win32.pod').

Trying to find an ORACLE_HOME
Your DYLD_LIBRARY_PATH env var is set to ''

      The ORACLE_HOME environment variable is not set and I couldn't guess it.
      It must be set to hold the path to an Oracle installation directory
      on this machine (or a machine with a compatible architecture).
      See the appropriate troubleshooting guide for your OS for more information.
      ABORTED!

-> N/A
-> FAIL Configure failed for DBD-Oracle-1.80. See /Users/username/.cpanm/work/1608142485.48272/build.log for details.

J'ai lu ici qui ORACLE_HOMEdevrait être défini sur la valeur du répertoire qui contient le /binrépertoire mais je n'en trouve pas /bin.

Réponses

2 ChristopherJones Dec 17 2020 at 05:12

macOS est en constante évolution, mais sur Mojave, j'ai installé Instant Client à partir des DMG, puis j'ai fait:

brew install perl
ln -s $HOME/Downloads/instantclient_19_8 $HOME/instantclient
export DYLD_LIBRARY_PATH=$HOME/instantclient
cpan -i -T DBI
cpan -i -T DBD::Oracle

En général, ne définissez jamais ORACLE_HOME pour Instant Client. (Cela peut entraîner la lecture de mauvais fichiers de configuration). ORACLE_HOME est utilisé pour une base de données «complète» ou une installation client complète, pas pour Instant Client. Cependant, certains installateurs font toujours référence à la variable pour trouver les fichiers de construction, vous en aurez donc besoin - au moins au moment de la construction. DBD :: Oracle recherchera en interne Instant Client et utilisera $ HOME / instantclient si $ ORACLE_HOME n'est pas défini.

macOS a progressivement supprimé l'utilité de DYLD_LIBRARY_PATH, car il n'est pas propagé aux sous-shell. Cela signifie qu'il ne peut pas être utilisé de manière fiable. Sur Mojave, j'ai trouvé que je pouvais également copier les bibliothèques Instant Client dans $ HOME / lib / et que je n'avais pas besoin de définir DYLD_LIBRARY_PATH.

Remarque: si vous utilisez DBD :: Oracle, vous n'avez pas besoin du package ODBC Instant Client.