我在 AWS Lambda 上遇到了一个gem加载错误的问题。
{
"errorMessage": "LoadError: libpq.so.5: cannot open shared object file: No such file or directory - /var/task/vendor/bundle/ruby/2.5.0/gems/pg-1.1.4/lib/pg_ext.so",
"errorType": "Function<Sequel::AdapterNotFound>",
"stackTrace": [
"/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'",
"/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/pg-1.1.4/lib/pg.rb:4:in `<top (required)>'",
"/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'",
"/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/sequel-5.16.0/lib/sequel/adapters/postgres.rb:6:in `<top (required)>'",
"/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'",
"/var/lang/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/sequel-5.16.0/lib/sequel/database/connecting.rb:88:in `load_adapter'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/sequel-5.16.0/lib/sequel/database/connecting.rb:17:in `adapter_class'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/sequel-5.16.0/lib/sequel/database/connecting.rb:45:in `connect'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/sequel-5.16.0/lib/sequel/core.rb:121:in `connect'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/sequel-5.16.0/lib/sequel/core.rb:399:in `adapter_method'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/sequel-5.16.0/lib/sequel/core.rb:406:in `block (2 levels) in def_adapter_method'",
"/var/task/lib/warehouse/loader.rb:5:in `connection'",
"/var/task/lib/warehouse/loader.rb:24:in `initialize'",
"/var/task/lib/warehouse/update.rb:43:in `new'",
"/var/task/lib/warehouse/update.rb:43:in `block in handle'",
"/var/task/lib/warehouse/update.rb:42:in `each'",
"/var/task/lib/warehouse/update.rb:42:in `handle'",
"/var/task/lambda.rb:11:in `handler'"
]
}
我正在使用Sequel库从AWS Lambda建立PSQL连接,但似乎该函数无法找到so文件。 我已经将依赖项打包在vendor / bundle中,在CodeBuild上在Ubuntu中构建,并验证了.so文件存在于上传到lambda的结果工件中。 我还编辑了$ LOAD_PATH,但似乎没有帮助。
有其他人遇到这种困难吗? 有任何进一步解决或调试的提示吗?
./vendor/bundle/ruby/2.5.0/gems/pg-1.1.4/lib
,但上面的错误引用了/var/task/vendor/bundle/ruby/2.5.0/gems/pg-1.1.4/lib/pg.rb
。我认为这是相同的路径...但我需要更明确吗? - 1ijk