echan00
echan00

Reputation: 2807

Third party libraries on heroku

I have added the GNU library 'wdiff' to my Ruby on Rails application via https://github.com/echan00/wdiff and added the executable to my /vendor/usr/bin directory.

Via heroku run bash I am able to execute the wdiff library at ~/vendor/usr/bin.

I have added /app/vendor/usr/bin as a LD_LIBRARY_PATH environment variable but my Ruby on Rails application cannot find wdiff.

What am I doing wrong?

Upvotes: 0

Views: 166

Answers (2)

Chris
Chris

Reputation: 136909

I have added /app/vendor/usr/bin as a LD_LIBRARY_PATH environment variable but my Ruby on Rails application cannot find wdiff

LD_LIBRARY_PATH tells the OS where to find libraries to be dynamically linked at runtime. For example, if you're running an application that requires OpenSSL but doesn't include OpenSSL itself the operating system can find it via LD_LIBRARY_PATH.

Directories the OS should search for binaries are listed in the PATH variable. Try using that instead.

Note that it would be very unusual to just set this to a single value. A more common approach would be to prepend or append your custom location to whatever value PATH already has, e.g. via something like

export PATH="$PATH:/app/vendor/usr/bin"

In case multiple binaries with the same name exist, ones found earlier in the path take precedence over ones found later.

Finally, something Heroku-specific:

and added the executable to my /vendor/usr/bin directory

How did you do this? If the binary is part of your repository you should be okay, but if you've added it manually (e.g. via heroku run bash) you'll find that it disappears after a certain amount of time. This is due to Heroku's ephemeral filesystem.

You'll need to include wdiff at build time. One good way of doing that would be by adding a second buildpack like heroku-buildpack-apt and then installing the regular wdiff package via your Aptfile.

Upvotes: 1

echan00
echan00

Reputation: 2807

I ended up hard-coding my rails gem to find the executable in the directory instead of going through the LIBRARY PATH

Upvotes: 0

Related Questions