title: libmysqlclient.so.18: cannot open shared object file: No such file or directory
body: <p>I'm currently trying to AWS Lambda a Ruby application. I was having issues installing <code>mysql2</code>, when I ran <code>bundle install</code> I was getting the following error:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I came across a Stackoverflow post to create a Docker container to load the dependencies, here is the post. <a href="https://stackoverflow.com/questions/53854487/cannot-load-file-mysql2-on-aws-lambda">Cannot load file mysql2 on AWS Lambda</a></p>
  
  <p>I followed the steps in the post:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>and I was able to install, as mentioned in the post the files can not be symlink because it breaks once you <code>zip</code> the directory. I tried using <code>mv</code> but the files don't persist in the directory after I exit the container. Once I <code>zip</code> the application and deploy to AWS Lambda I get the following error:</p>
  
  <pre><code>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&lt;LoadError&gt;",
    "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 `&lt;top (required)&gt;'",
      "/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 `&lt;top (required)&gt;'",
      "/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 `&lt;top (required)&gt;'",
      "/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'"
    ]
  }
  </code></pre>
  
  <p>But I'm able to see the file <code>mysql2.so</code> in the vendor directory:</p>
  
  <pre><code>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# 
  </code></pre>
  
  <p>I'm also able to see the files <code>libmysqlclient.so</code> and <code>/mysql2/mysql2.so</code>.
  <a href="https://i.stack.imgur.com/swska.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/swska.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/6SgM3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6SgM3.png" alt="enter image description here"></a></p>
  
  <p>Why it is not finding the file?</p>