How do I install DBI module for Perl on Heroku machine

隐身守侯 提交于 2019-12-11 06:38:48

问题


So I have my Ruby-on-rails app that i successfully released to heroku. However to populate the database I have several perl scripts that basically sync up tables on local database with a remote database.

On my development machine (on ec2) it works fine but I also have a lot of stuff i have installed on it over time.

When I try to run my scripts I get the following error (latest perl is installed by the way)

Can't locate DBI.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at copyStaff.pl line 4.
BEGIN failed--compilation aborted at copyStaff.pl line 4.

How do I install DBI module for Perl on heroku? I tried through bash

apt-get install libdbi-perl

This gave me an output of

W: Not using locking for read only lock file /var/lib/dpkg/lock
E: Unable to write to /var/cache/apt/
E: The package lists or status file could not be parsed or opened.

[This might be irrelevant] I tried to run this command

dpkg --configure -a

But it told me it requires super user privileges

su -l root -c "dpkg --configure -a"
  • asked for root password and apparently I don't know the password (it's not the heroku login), no clue what it might be.

I also downloaded the file directly, but I need super user access. I also tried

$perl -MCPAN -e shell
cpan> install DBI

(this had same problem of not beng able to save the file)

I have a feeling i might be going at it completely the wrong way, but I can't figure out what I need to do to run those scripts.


回答1:


You're going to have to investigate Perl Buildpacks for Heroku, of which I know of the existence of Perloku, and two others calling themselves something along the lines of perl-heroku.

Buildpacks attempt to install environments that Heroku does not support natively, like Perl. I found some install Mojolicious, another installs an apache2/mod_perl env.

You'll have to talk to the buildpack maintainers to find out if they have DBI/ DBD::mysql installed, but it is likely they do, just based on the popularity of those modules.

If you get that far, then all you have to do is sync the databases :-)




回答2:


Well I got the answer from customer support, just pasting it here


Unfortunately we don't support installing additional libraries or binaries to our stacks. The best workaround is to vendor these into your project. You'll need to use 64-bit Linux versions to make them work on Heroku; compiling statically can also help ensure that any dependencies needed are included. Similarly, for gems that depend on external libraries, we recommend compiling the gem statically and vendoring it into your project.

If you do wish to try to vendor your binary, library, or gem, you can use Heroku as your build environment. One of our engineers created a build server that allows you to upload source code, run the compilation step, and then download the resulting binary. You can find this project here: https://github.com/heroku/vulcan



来源:https://stackoverflow.com/questions/13187433/how-do-i-install-dbi-module-for-perl-on-heroku-machine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!