0

My app needs the package: man, but by default it's not installed on the heroku/nodejs buildpack.

So according to the documentation, heroku/heroku-buildpack-apt is the tool for the job when your app needs additional apt dependencies.

I assigned the new buildpack and added a Aptfile to the root of the project with one line:

man

Here is my full package.json

{
  "name": "unix-translator",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www",
    "test": "mocha --exit"
  },
  "dependencies": {
    "body-parser": "~1.18.2",
    "cookie-parser": "~1.4.3",
    "debug": "~2.6.9",
    "express": "~4.15.5",
    "jade": "~1.11.0",
    "morgan": "~1.9.0",
    "node-dev": "^3.1.3",
    "serve-favicon": "~2.4.5",
    "dateTools": "file:lib/unix-command"
  },
  "devDependencies": {
    "chai": "^4.1.2",
    "mocha": "^4.1.0"
  }
}

Here's my Procfile:

web: node ./bin/www

This gets the dependency successfully installed because I see it when I run which man now. But it doesn't work.

I get this error when I try to use the man program:

~ $ man cat
man: error while loading shared libraries: libmandb-2.7.5.so: cannot open shared object file: No such file or directory

I did found this blog post and this other blog post which both suggest the problem related to permissions and the location of files... I SSHed into my dyno and ran: /sbin/ldconfig -v and it eventually threw this error:

/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Read-only file system

^ The command needs to be run with sudo and that's not available inside a dyno. :-( So I'm stuck again.

emersonthis
  • 32,822
  • 59
  • 210
  • 375

1 Answers1

0

Not 100% sure, but this might be worth a shot: Replace the "prestart" in your package.json with heroku-prebuild (or heroku-postbuild), as follows:

"scripts": {
   "start": "node ./bin/www",
   "test": "mocha --exit",
   "heroku-prebuild": "apt-get update && apt-get install man"
},

You had this in "prestart", which means it gets executed when you run npm start. However, from your question, it looks like you are accessing a one-off Heroku dyno (e.g. with "heroku run bash"), and then trying to run "man cat" therein. So when you do that, you are not running "npm start" at all on your dyno. By putting the "apt-get" in one of the Heroku specific build steps, it executes when your slug gets built, and hence whatever you install should be available on any dyno in your app (including one-off dynos).

Yoni Rabinovitch
  • 5,171
  • 1
  • 23
  • 34
  • Thanks. Using the Aptfile with heroku/heroku-buildpack-apt seems to get the dependency installed successfully. I see it when I SSH into the box and run `which man`. But it doesn't seem to be installed in such a way that it can be run without additional configuration. I'll add an update above... – emersonthis Jan 22 '18 at 18:30