sqitchers / homebrew-sqitch

Homebrew Formulas for Sqitch
22 stars 10 forks source link

Error deploying to Oracle from macOS Catalina #51

Closed carragom closed 3 years ago

carragom commented 3 years ago

Hi,

Have a couple of projects with PostgreSQL without issues. Now trying to start an Oracle project but getting an error when deploying. Deploy command is like this.

$ sqitch deploy db:oracle://myuser:secret@172.16.113.10/orcl 
DBD::Oracle 1.23 required to manage Oracle

Sqitch was installed with the following command and no errors were reported.

export HOMEBREW_ORACLE_HOME=$ORACLE_HOME; brew install sqitch --with-postgres-support --with-sqlite-support --with-oracle-support --verbose

My $ORACLE_HOME points to /usr/local/oracle/product/19.8/instantclient where I have the instant client version 19.8 which works fine at least sqlplus does. Looks like Sqitch is not finding the Oracle driver but the Perl module seems to correctly exists here

/usr/local/Cellar/sqitch/v1.1.0/lib/perl5/darwin-thread-multi-2level/DBD/Oracle.pm

I also tried with other versions of the instant client, namely 11.2 and 12.2 with the same result. Am I missing something? Thanks in advance.

carragom commented 3 years ago

Reading #46 I saw the command to test the driver and this is what I'm getting

Oracle driver is not loading

$ perl -I/usr/local/Cellar/sqitch/v1.1.0/lib/perl5/darwin-thread-multi-2level -MDBD::Oracle -E 'say DBD::Oracle->VERSION'
Can't load '/usr/local/Cellar/sqitch/v1.1.0/lib/perl5/darwin-thread-multi-2level/auto/DBD/Oracle/Oracle.bundle' for module DBD::Oracle: dlopen(/usr/local/Cellar/sqitch/v1.1.0/lib/perl5/darwin-thread-multi-2level/auto/DBD/Oracle/Oracle.bundle, 1): Library not loaded: @rpath/libclntsh.dylib.19.1
  Referenced from: /usr/local/Cellar/sqitch/v1.1.0/lib/perl5/darwin-thread-multi-2level/auto/DBD/Oracle/Oracle.bundle
  Reason: image not found at /usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/darwin-thread-multi-2level/DynaLoader.pm line 197.
 at -e line 0.
Compilation failed in require.
BEGIN failed--compilation aborted.

The library can be found at /usr/local/oracle/product/19.8/instantclient/libclntsh.dylib.19.1 but for some reason DBD::Oracle is not finding it there. This seems to be a problem with DBD::Oracle but no idea how to proceed.

carragom commented 3 years ago

Got it working. Created a link in /usr/local/lib and now it's working. Looks like DBD::Oracle looks for libs on standard places and does not remember where the lib was when it got built. There seems to be an option to define DYLD_LIBRARY_PATH and point it to extra places to look at. But according to the docs it does not get propagated to sub-shells so I'm not sure that could be used to improve Sqitch.

I guess not many use DBD::Oracle in macOS.

cd /usr/local/lib
ln -s /usr/local/oracle/product/19.8/instantclient/libclntsh.dylib.19.1
theory commented 3 years ago

Yeah, the only way I've found to get DYLD_LIBRARY_PATH to work on Catalina and later is to disable SIP.

carragom commented 3 years ago

The interesting part here is that when compiling DBD::Oracle actually uses $ORACLE_HOME to look for the libs, shouldn't it also look at $ORACLE_HOME at runtime?. Do you think this is something that could be requested from DBD::Oracle?.

Sorry, I know this is not your domain.

theory commented 3 years ago

Yeah, that's worth a try. You can post you request to the DBD::Oracle bug queue here or by emailing bug-DBD-Oracle@rt.cpan.org.

carragom commented 3 years ago

Thanks for the tip, turns out the venerable RT instance of CPAN is retiring. And the new issue tracker for this module is actually at Github. So I opened an issue at perl5-dbi/DBD-Oracle#128. Lets see if they can provide a better way. Meanwhile looks like the following also works without having to link anything.

export DYLD_LIBRARY_PATH=$ORACLE_HOME
perl -I/usr/local/Cellar/sqitch/v1.1.0/lib/perl5/darwin-thread-multi-2level -MDBD::Oracle -E 'say DBD::Oracle->VERSION'

Does not look like there is more that can be done on the Sqitch side to improve the user experience. I guess all things Oracle need to be ugly and uncomfortable. Otherwise it's just not Oracle 😂

theory commented 3 years ago

Ah, glad you found the GitHub project for DBD::Oracle; I only found the RT, and also saw the retiring announcement, so went through my RT backlog and closed a few things in my own projects.

I guess all things Oracle need to be ugly and uncomfortable. Otherwise it's just not Oracle 😂

Ain't that the truth!