libmysqlclient.so.18: cannot open shared object file: No such file or directory

五迷三道 提交于 2020-07-10 01:47:12

问题


I'm currently trying to AWS Lambda a Ruby application. I was having issues installing mysql2, when I ran bundle install I was getting the following error:

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling

I came across a Stackoverflow post to create a Docker container to load the dependencies, here is the post. Cannot load file mysql2 on AWS Lambda

I followed the steps in the post:

move the mysql folder from /usr/lib64/mysql to /usr/mysql
mkdir -p /var/task/lib
cp -a /usr/mysql/.so. /var/task/lib/
bundle config --local build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
bundle install with and without deployment

and I was able to install, as mentioned in the post the files can not be symlink because it breaks once you zip the directory. I tried using mv but the files don't persist in the directory after I exit the container. Once I zip the application and deploy to AWS Lambda I get the following error:

Response:
{
  "errorMessage": "libmysqlclient.so.18: cannot open shared object file: No such file or directory - /var/task/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.so",
  "errorType": "Init<LoadError>",
  "stackTrace": [
    "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
    "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
    "/var/task/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2.rb:33:in `<top (required)>'",
    "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
    "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
    "/var/task/my_sql.rb:1:in `<top (required)>'",
    "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
    "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
    "/var/task/lambda_function.rb:8:in `<top (required)>'",
    "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
    "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'"
  ]
}

But I'm able to see the file mysql2.so in the vendor directory:

bash-4.2# cd /var/task/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/
bash-4.2# ls
client.rb  console.rb  em.rb  error.rb  field.rb  mysql2.so  result.rb  statement.rb  version.rb
bash-4.2# 

I'm also able to see the files libmysqlclient.so and /mysql2/mysql2.so.

Why it is not finding the file?

来源:https://stackoverflow.com/questions/62218696/libmysqlclient-so-18-cannot-open-shared-object-file-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!