You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It has been really hard to figure out some of the issues I ran into related to setting up postgresql with lamby so far, so I'm going to share some progress here since I'm sure other people might experience these issues and benefit from this.
Issue with pg native extension
I've been able to resolve most of pg installation issues with these lines in my Dockerfile-build:
RUN yum update -y
RUN yum install -y amazon-linux-extras
RUN amazon-linux-extras enable postgresql13
RUN yum install -y postgresql postgresql-server postgresql-devel
but then I started getting the following error once my stack is deployed.
pg_ext.s issue with rails + aws lambda and postgreqsl
"errorMessage": "libpq.so.5: cannot open shared object file: No such file or directory - /var/task/vendor/bundle/ruby/2.7.0/gems/pg-1.4.5/lib/pg_ext.so",
status: Resolved
In my attempt to resovle the issue above I tried to add the missing library manually in the bin/_build file
source: rubyonjets/jets#104
mkdir -p /var/task/lib
cp -a /usr/lib64/libpq.so.5 /var/task/lib/libpq.so.5
cp -a /usr/lib64/libldap_r-2.4.so.2 /var/task/lib/libldap_r-2.4.so.2
cp -a /usr/lib64/liblber-2.4.so.2 /var/task/lib/liblber-2.4.so.2
cp -a /usr/lib64/libsasl2.so.3 /var/task/lib/libsasl2.so.3
cp -a /usr/lib64/libssl3.so /var/task/lib/
cp -a /usr/lib64/libsmime3.so /var/task/lib/
cp -a /usr/lib64/libnss3.so /var/task/lib/
cp -a /usr/lib64/libnssutil3.so /var/task/lib/
Line 6 on application.rb was theBundler.require(*Rails.groups) it made me realized that the issue could be because of a mismatch of ruby version in my gemfile and the app configuration since my gemfile had the version:
ruby "2.7.6"
gem 'rails', '~> 7.0.1'
I noticed a couple area in the app that were pointing to the same ruby version listed in the error:
docker-compose.yml environment had this configuration GEM_HOME=/var/task/vendor/bundle/ruby/2.7.0
There were also a couple location in the app that expected 2.7.0. I removed the ruby "2.7.6" mention from my gemfile
So I removed the ruby version from my gemfile ( alternatively you can update all the references – but you will also need to update the image of ruby being loaded most likely since Docker line FROM public.ecr.aws/sam/build-ruby2.7 might be pointing to 2.7.0)
then I got this error: "errorMessage": "Could not find pg-1.4.5, nio4r-2.5.8, websocket-driver-0.7.5, nokogiri-1.13.9, racc-1.6.0 in locally installed gems",
It looks like some of these gems failed to install . I know this because I ssh'd into the container and ran bundle doctor and notice that some of the gem where throwing native extension errors. I figure out a way to resolve it in the container; but it doesn't seem to resolve the issue on lambda.
I added this line to my Dockerfile-build to help install all related lib dependency:
RUN yum install -y gcc ruby-devel zlib-devel libxml2 libxml2-devel libxslt libxslt-devel make
RUN yum install -y rubygem-nokogiri libxml2-devel libxslt libxslt-devel
and these two line helped in my bin/_build file for nio4r and nokogiri
UPDATE: I wasn't able to make it work – Too many dependency to resolves. Let me know if you find a solution. Hopefully what I shared here will make it easier to get to a solution.
The text was updated successfully, but these errors were encountered:
richardsondx
changed the title
Lamby with pg gem ( postgresql )
Setting Lamby with pg gem ( postgresql )
Nov 25, 2022
richardsondx
changed the title
Setting Lamby with pg gem ( postgresql )
How to Set up Lamby with pg gem – rails + aws lambda + postgresql
Nov 25, 2022
So I would recommend switching to official Ruby images with the RIC installed. I recently refactored the Lamby Cookiecutter to follow this pattern and outlined all the changes. It actually simplifies a lot. Review here.
It has been really hard to figure out some of the issues I ran into related to setting up postgresql with lamby so far, so I'm going to share some progress here since I'm sure other people might experience these issues and benefit from this.
Issue with pg native extension
I've been able to resolve most of pg installation issues with these lines in my
Dockerfile-build
:but then I started getting the following error once my stack is deployed.
pg_ext.s issue with rails + aws lambda and postgreqsl
status: Resolved
In my attempt to resovle the issue above I tried to add the missing library manually in the
bin/_build
filesource: rubyonjets/jets#104
Here is the full error:
Line 6 on application.rb was the
Bundler.require(*Rails.groups)
it made me realized that the issue could be because of a mismatch of ruby version in my gemfile and the app configuration since my gemfile had the version:I noticed a couple area in the app that were pointing to the same ruby version listed in the error:
GEM_HOME=/var/task/vendor/bundle/ruby/2.7.0
2.7.0
. I removed theruby "2.7.6"
mention from my gemfileSo I removed the ruby version from my gemfile ( alternatively you can update all the references – but you will also need to update the image of ruby being loaded most likely since Docker line
FROM public.ecr.aws/sam/build-ruby2.7
might be pointing to 2.7.0)then I got this error:
"errorMessage": "Could not find pg-1.4.5, nio4r-2.5.8, websocket-driver-0.7.5, nokogiri-1.13.9, racc-1.6.0 in locally installed gems",
status: Resolved
Full error:
It looks like some of these gems failed to install . I know this because I ssh'd into the container and ran
bundle doctor
and notice that some of the gem where throwing native extension errors. I figure out a way to resolve it in the container; but it doesn't seem to resolve the issue on lambda.I added this line to my Dockerfile-build to help install all related lib dependency:
and these two line helped in my
bin/_build
file for nio4r and nokogirithen I got this error:
"libexslt.so.0: cannot open shared object file: No such file or directory
status: Unresolved
Here is the full stacktrace:
UPDATE: I wasn't able to make it work – Too many dependency to resolves. Let me know if you find a solution. Hopefully what I shared here will make it easier to get to a solution.
The text was updated successfully, but these errors were encountered: