运行 passenger_native_support.so 在 heroku 上

Running passenger_native_support.so on heroku

当我在 heroku 上使用 Passenger 5.3.1 部署我的 Rails 3 应用程序时,我在日志中看到以下失败的下载

Could not download https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/5.3.1/rubyext-ruby-2.2.7-x86_64-linux.tar.gz: The requested URL returned error: 404 Not Found

Could not download https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release/5.3.1/rubyext-ruby-2.2.7-x86_64-linux.tar.gz: The requested URL returned error: 403 Forbidden

有人可以建议我如何解决这个问题吗?我检查说 URLs 并且文件位于不同的 URL(我的应用程序尝试从中下载的路径略有错误)。 我可以在某处配置下载 URL 吗?

由于在 heroku 上缺少 SSH 访问,我不太确定从这里去哪里。

我也不确定 PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 禁用的优点 以及在部署到 heroku 时我将在哪里配置它。

日志:

2018-05-22T14:22:02.337983+00:00 app[web.1]: --> Downloading a Phusion Passenger agent binary for your platform 2018-05-22T14:22:02.709603+00:00 app[web.1]: 2018-05-22T14:22:02.709640+00:00 app[web.1]: --> Installing Nginx 1.14.0 engine 2018-05-22T14:22:02.779900+00:00 app[web.1]: 2018-05-22T14:22:02.779946+00:00 app[web.1]: -------------------------- 2018-05-22T14:22:02.779967+00:00 app[web.1]: 2018-05-22T14:22:02.792581+00:00 app[web.1]: [passenger_native_support.so] trying to compile for the current user (u56245) and Ruby interpreter... 2018-05-22T14:22:02.792586+00:00 app[web.1]: (set PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 to disable) 2018-05-22T14:22:03.114593+00:00 app[web.1]: Warning: compilation didn't succeed. To learn why, read this file: 2018-05-22T14:22:03.114653+00:00 app[web.1]: /tmp/passenger_native_support-fgpk65.log 2018-05-22T14:22:03.114732+00:00 app[web.1]: [passenger_native_support.so] finding downloads for the current Ruby interpreter... 2018-05-22T14:22:03.114766+00:00 app[web.1]: (set PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 to disable) 2018-05-22T14:22:03.837288+00:00 app[web.1]: Could not download https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/5.3.1/rubyext-ruby-2.2.7-x86_64-linux.tar.gz: The requested URL returned error: 404 Not Found 2018-05-22T14:22:03.837312+00:00 app[web.1]: Trying next mirror... 2018-05-22T14:22:04.331785+00:00 app[web.1]: Could not download https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release/5.3.1/rubyext-ruby-2.2.7-x86_64-linux.tar.gz: The requested URL returned error: 403 Forbidden 2018-05-22T14:22:04.332030+00:00 app[web.1]: [passenger_native_support.so] will not be used (can't compile or download) 2018-05-22T14:22:04.332036+00:00 app[web.1]: --> Passenger will still operate normally. 2018-05-22T14:22:04.410350+00:00 app[web.1]: =============== Phusion Passenger Standalone web server started =============== 2018-05-22T14:22:04.410358+00:00 app[web.1]: PID file: /app/passenger.11176.pid 2018-05-22T14:22:04.410360+00:00 app[web.1]: Log file: /app/log/passenger.11176.log 2018-05-22T14:22:04.410361+00:00 app[web.1]: Environment: production

TL;DR:您可以通过将 Ruby 升级到它们捆绑的版本来使用来自 oss-binaries.phusionpassenger.com 的预编译二进制文件,例如v2.2.8 如果你使用 Passenger gem v.5.3.1, or by downgrading the Passenger gem to v5.1.9 如果你喜欢 Ruby 2.2.7.

不过binaries are not critical要客运。正如日志所说:Passenger will still operate normally. 缺少二进制文件 Passenger 尝试下载 is also ok - 他们不会为每个 Ruby 版本发布二进制文件。您可以安全地设置 PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 和 PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 以将两者都静音 - 这是在您的 Heroku 应用程序的 Config Vars 设置中。

有关 Passenger 编译问题的详细信息: Passenger 无法在 Heroku 上编译本地二进制文件,至少在新的 heroku-16 堆栈上是这样。我们可以检查 /tmp/passenger_native_support-fgpk65.log 然后 mkmf.log 通过这样做:

heroku run bash 
bundle exec passenger start # just to make it fill the error log file
# hit [ctrl-c]
cat /tmp/passenger_native_support-*.log

它的输出是这样的:

# /app/vendor/ruby-2.3.1/bin/ruby /app/vendor/bundle/ruby/2.3.0/gems/passenger-5.3.4/src/ruby_native_extension/extconf.rb
checking for alloca.h... *** /app/vendor/bundle/ruby/2.3.0/gems/passenger-5.3.4/src/ruby_native_extension/extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

虽然不清楚 mkmf.log 文件在哪里,但我们可以通过 运行 /app/vendor/bundle/ruby/2.3.0/gems/passenger-5.3.4/src/ruby_native_extension/extconf.rb 手动使用与上面日志相同的命令使其出现在当前目录中:

/app/vendor/ruby-2.3.1/bin/ruby /app/vendor/bundle/ruby/2.3.0/gems/passenger-5.3.4/src/ruby_native_extension/extconf.rb
cat mkmf.log

然后我们有这个:

"gcc -o conftest -I/app/vendor/ruby-2.3.1/include/ruby-2.3.0/x86_64-linux -I/app/vendor/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/app/vendor/ruby-2.3.1/include/ruby-2.3.0 -I/app/vendor/bundle/ruby/2.3.0/gems/passenger-5.3.4/src/ruby_native_extension     -O3 -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wno-maybe-uninitialized  -fPIC -g conftest.c  -L. -L/app/vendor/ruby-2.3.1/lib -Wl,-R/app/vendor/ruby-2.3.1/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-rpath,'/../lib' -Wl,-R'/../lib' -lruby  -lpthread -lgmp -ldl -lcrypt -lm   -lc"
sh: 1: gcc: not found
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

因此,根本问题是 gcc 在 heroku-16 堆栈运行时中不可用 - 这可能是故意的。使 gcc 在那里可用并不容易,尽管它看起来是 possible,但我不会这样做,前提是我们可以通过其他方式解决此问题。