title: Environment variables with Rackup, Thin, and Oracle
body: <p>I've written a server using Sinatra that accesses an Oracle database using ActiveRecord (though this is not a Rails app). I wrote it in Sinatra's "classic" style and previously started the server like this:</p>
  
  <pre><code>bundle exec ruby bin/server.rb
  </code></pre>
  
  <p>I also used <code>require 'thin'</code> and Thin was magically used as the HTTP server. However, I needed to change Thin's default timeout, so I transitioned to a rackup <code>config.ru</code> file. I now start the server like this:</p>
  
  <pre><code>bundle exec thin -C config/thin.yml -R config/config.ru start
  </code></pre>
  
  <p>However, since doing this I can't connect to the Oracle database with the server. I'm using a service name and the <code>TNS_ADMIN</code> environment variable is set correctly and I can connect with <code>sqlplus</code> or even the same server if not launched using Thin. Launching with Thin, when I try to start the connection I get <code>OCIError - ORA-12154: TNS:could not resolve the connect identifier specified</code>.</p>
  
  <p><strong>What is the right way to set environment variables for servers launched with Thin?</strong> The solution <a href="https://stackoverflow.com/questions/10294815/getting-thin-to-read-configured-user-environment">here</a> doesn't work because I can't give ruby-oci8 the information, it automatically reads them from the environment. </p>