【问题标题】:How to install man on Heroku如何在 Heroku 上安装 man
【发布时间】:2018-01-23 02:38:47
【问题描述】:

我的应用需要包:man,但默认情况下它没有安装在 heroku/nodejs buildpack 上。

所以根据the documentationheroku/heroku-buildpack-apt 是当您的应用需要额外的 apt 依赖项时的工作工具。

我分配了新的 buildpack 并在项目的根目录中添加了 Aptfile 一行:

man

这是我的完整 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"
  }
}

这是我的 Procfile:

web: node ./bin/www

这会成功安装依赖项,因为我现在运行which man 时看到它。但它不起作用。

当我尝试使用man 程序时出现此错误:

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

我确实找到了this blog postthis other blog post,它们都表明与权限和文件位置有关的问题...我通过 SSH 连接到我的测功机并运行:/sbin/ldconfig -v,它最终抛出了这个错误:

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

^ 该命令需要使用sudo 运行,而这在测功机中不可用。 :-( 所以我又卡住了。

【问题讨论】:

  • 你能分享你的 Procfile 和 package.json 吗?
  • @YoniRabinovitch 完成。我更新了上面的问题。

标签: node.js heroku apt-get manpage


【解决方案1】:

不是 100% 肯定,但这可能值得一试: 将 package.json 中的“prestart”替换为 heroku-prebuild(或 heroku-postbuild),如下所示:

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

你在“prestart”中有这个,这意味着它在你运行 npm start 时被执行。 但是,从您的问题来看,您似乎正在访问one-off Heroku dyno(例如使用“heroku run bash”),然后尝试在其中运行“man cat”。所以当你这样做时,你根本没有在你的测功机上运行“npm start”。 通过将“apt-get”放在Heroku specific build steps 之一中,它会在您的slug 构建时执行,因此您安装的任何内容都应该在您应用程序中的任何测功机上可用(包括一次性测功机)。

【讨论】:

  • 谢谢。将 Aptfile 与 heroku/heroku-buildpack-apt 一起使用似乎可以成功安装依赖项。当我 SSH 进入盒子并运行 which man 时,我看到了它。但它似乎没有以无需额外配置即可运行的方式安装。我将在上面添加更新...
猜你喜欢
  • 1970-01-01
  • 2015-06-12
  • 2017-01-04
  • 2020-11-01
  • 2017-09-21
  • 2018-06-14
  • 2019-01-31
  • 2013-05-31
  • 2012-07-27
相关资源
最近更新 更多