title: rbenv in production triggering mongodb connection error
body: <p>I've switched to rbenv in production (staging to be correct) and most of the switch seemed to work just fine. I've followed the guidelines outlined here: <a href="http://blog.danielpietzsch.com/post/14005159872/running-a-rails-app-in-production-using-rbenv-apache" rel="nofollow">http://blog.danielpietzsch.com/post/14005159872/running-a-rails-app-in-production-using-rbenv-apache</a></p>
  
  <p>However, running <code>rake assets:precompile</code> throws this <strong>Failed to connect to a master node at localhost:27017</strong>. My guess is that this is a symptom of something else missing or being astray.</p>
  
  <p><strong>which rake</strong></p>
  
  <pre><code>root@staging1:/var/www/staging# which rake
  /usr/local/rbenv/shims/rake
  </code></pre>
  
  <p><strong>rbenv version</strong></p>
  
  <pre><code>root@staging1:/var/www/staging# rbenv version
  1.9.3-p125 (set by /usr/local/rbenv/version)
  </code></pre>
  
  <p><strong>mongod is running on localhost:27017</strong></p>
  
  <pre><code>root@staging1:/var/www/staging# mongo --port 27017 --host localhost
  MongoDB shell version: 1.8.0
  connecting to: localhost:27017/test
  &gt; exit
  bye
  </code></pre>
  
  <p><strong>rake task that triggers the error</strong></p>
  
  <pre><code>root@staging1:/var/www/staging# rake assets:precompile
  /usr/local/rbenv/versions/1.9.3-p125/bin/ruby /usr/local/rbenv/versions/1.9.3-p125/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
  rake aborted!
  Failed to connect to a master node at localhost:27017  &lt;--------------- ERROR
  
  Tasks: TOP =&gt; environment
  (See full trace by running task with --trace)
  rake aborted!
  Command failed with status (1): [/usr/local/rbenv/versions/1.9.3-p125/bin/r...]
  
  Tasks: TOP =&gt; assets:precompile
  (See full trace by running task with --trace)
  </code></pre>
  
  <p>Here is the rake task with --trace: <a href="http://pastie.org/private/ww9wm0wlm6le6wbtmq89ia" rel="nofollow">http://pastie.org/private/ww9wm0wlm6le6wbtmq89ia</a></p>
  
  <p>I've found a few others with the same problem on heroku, but in that case it seem to be because mongo really isn't running: <a href="http://blog.noizeramp.com/2011/10/14/rails-3-asset-pipeline-on-heroku-when-using-mongoid/" rel="nofollow">http://blog.noizeramp.com/2011/10/14/rails-3-asset-pipeline-on-heroku-when-using-mongoid/</a></p>
  
  <p>I'd be happy to provide more details if needed. Just let me know and I'll update the question with more details.</p>