Rake causing LoadError: libruby.so.2.1: cannot open shared object file - file exists
<p>I am trying to use the chef community cookbook <a href="https://github.com/ajgon/opsworks_ruby" rel="nofollow noreferrer">opsworks_ruby</a> to deploy a rails app. I am currently running into an issue with one of my gems, <a href="https://github.com/rails-sqlserver/tiny_tds" rel="nofollow noreferrer">tiny_tds</a> version <a href="https://github.com/rails-sqlserver/tiny_tds/tree/v0.9.5.beta.10" rel="nofollow noreferrer">0.9.5.beta.10</a>.</p>

<p>When trying to migrate the database with the following command:</p>

<pre><code>/usr/local/bin/bundle exec rake db:migrate
</code></pre>

<p>I am getting this error:</p>

<pre><code>STDERR: rake aborted!
LoadError: libruby.so.2.1: cannot open shared object file: No such file or directory - /srv/www/api/shared/vendor/bundle/ruby/2.2/extensions/x86_64-linux/2.2/tiny_tds-0.9.5.beta.10/tiny_tds/tiny_tds.so
/srv/www/api/shared/vendor/bundle/ruby/2.2/gems/tiny_tds-0.9.5.beta.10/lib/tiny_tds.rb:36:in `require'
/srv/www/api/shared/vendor/bundle/ruby/2.2/gems/tiny_tds-0.9.5.beta.10/lib/tiny_tds.rb:36:in `&lt;top (required)&gt;'
/usr/local/share/ruby/gems/2.2/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `require'
/usr/local/share/ruby/gems/2.2/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/usr/local/share/ruby/gems/2.2/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
/usr/local/share/ruby/gems/2.2/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
/usr/local/share/ruby/gems/2.2/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
/usr/local/share/ruby/gems/2.2/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
/usr/local/share/ruby/gems/2.2/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
</code></pre>

<p>However when I ssh into the server and</p>

<pre><code>file /srv/www/api/shared/vendor/bundle/ruby/2.2/extensions/x86_64-linux/2.2/tiny_tds-0.9.5.beta.10/tiny_tds/tiny_tds.so
</code></pre>

<p>I get this as a response:</p>

<pre><code>[...]tiny_tds.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=cce05b6143516778339554cb7b1e2db232bb155e, not stripped
</code></pre>

<p>So the file is clearly there, why can't it be found?</p>

<p>I currently have ruby 2.2.4 installed.</p>

<p>Calling </p>

<pre><code>ldd /srv/www/api/shared/vendor/bundle/ruby/2.2/extensions/x86_64-linux/2.2/tiny_tds-0.9.5.beta.10/tiny_tds/tiny_tds.so
</code></pre>

<p>Gives me this:</p>

<pre><code>linux-vdso.so.1 =&gt;  (0x00007ffe73dcf000)
libruby.so.2.1 =&gt; not found
libct.so.4 =&gt; not found
libsybdb.so.5 =&gt; not found
libpthread.so.0 =&gt; /lib64/libpthread.so.0 (0x00007fee58fe0000)
libdl.so.2 =&gt; /lib64/libdl.so.2 (0x00007fee58ddb000)
libcrypt.so.1 =&gt; /lib64/libcrypt.so.1 (0x00007fee58ba4000)
libm.so.6 =&gt; /lib64/libm.so.6 (0x00007fee588a2000)
libc.so.6 =&gt; /lib64/libc.so.6 (0x00007fee584df000)
/lib64/ld-linux-x86-64.so.2 (0x0000556740bd7000)
libfreebl3.so =&gt; /lib64/libfreebl3.so (0x00007fee582dd000)
</code></pre>

<p>Also, looking into paths and whatnot:</p>

<pre><code>$ echo $PATH
&gt; /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin

$ echo $GEM_HOME
&gt;

$ echo $GEM_PATH
&gt; 

$ which ruby
&gt; /usr/bin/ruby

$ /usr/bin/ruby -v
&gt; ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux-gnu]
</code></pre>

<p>I notice I have no GEM_HOME or GEM_PATH, but my ruby looks correct?</p>

<p>Can anyone help me resolve this issue?</p>