我正在使用AWS Lambda运行一个简单的红宝石脚本,其github project具有适合我需求的框架。AWS Lambda:无法加载'active_record/connection_adapters/postgresql_adapter'
由于作为堆栈一部分的Traveling Ruby的限制,在面对几个ruby和bundler版本冲突之后。
我能够在本地成功,但后来当我打包和我测试更新的lambda函数,我得到了AWS控制台上的一个奇怪的错误运行脚本:
START RequestId: feab102b-5da5-11e7-bf18-739c73eb4ef0 Version: $LATEST
2017-06-30T15:08:39.144Z feab102b-5da5-11e7-bf18-739c73eb4ef0 Starting process: ./app
2017-06-30T15:08:51.403Z feab102b-5da5-11e7-bf18-739c73eb4ef0 stderr:
/var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
2017-06-30T15:08:51.403Z feab102b-5da5-11e7-bf18-739c73eb4ef0 stderr:
: Could not load 'active_record/connection_adapters/postgresql_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `block in require'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:240:in `load_dependency'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
from /var/task/lib/vendor/ruby/2.1.0/gems/pg-0.21.0/lib/pg.rb:4:in `<top (required)>'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `block in require'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:240:in `load_dependency'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
from /var/task/lib/vendor/ruby/2.1.0/gems/activerecord-4.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:17:in `<top (required)>'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `block in require'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:240:in `load_dependency'
from /var/task/lib/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
from /var/task/lib/vendor/ruby/2.1.0/gems/activerecord 4.2.9/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
from /var/task/lib/vendor/ruby/2.1.0/gems/activerecord 4.2.9/lib/active_record/connection_handling.rb:50:in `establish_connection'
from /var/task/lib/app/app.rb:12:in `<main>'
2017-06-30T15:08:51.744Z feab102b-5da5-11e7-bf18-739c73eb4ef0 {"errorMessage":"Process \"./app\" exited with code: 1"}
END RequestId: feab102b-5da5-11e7-bf18-739c73eb4ef0
在db/config.yml
(它调用config/database.yml
,因为它应该默认为rails树)我已经设置了adapter: postgresql
和所有其他必需的设置。
的代码完全存储在.zip
文件,我已经解开了,就能够找到我的猜测拉姆达环境中的/var/task
被提取,因为它显示在日志中的lib/vendor/ruby/2.1.0/gems/activerecord-4.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb
。
我能想到的唯一的事情是,在require
那一刻,它在基础路径上迷路了,因此没有找到要加载的文件。
我会很感激任何我可能会失踪的任何见解或解决此问题的任何线索。
谢谢!