diff --git a/lib/version.js b/lib/version.js
index 25effa9edf56e45d9fb2e22e51f05d32ad0ea781..5efd6167a92bc93ce96a4d2af472bbc3a21015b7 100644
--- a/lib/version.js
+++ b/lib/version.js
@@ -12,23 +12,26 @@ fs = require('fs'),
 path = require('path'),
 logger = require('./logging.js').logger,
 spawn = require('child_process').spawn,
-secrets = require('./secrets.js');
+secrets = require('./secrets.js'),
+config = require('./configuration');
 
 var sha;
 
 // first try ver.txt which by convention is placed in repo root at
 // deployment time
-try {
-  var contents = fs.readFileSync(path.join(__dirname, '..', 'resources', 'static', 'ver.txt'));
-  sha = contents.toString().split(' ')[0];
-  if (sha.length != 7) throw "bad sha in ver.txt";
-} catch(e) {
-  sha = undefined;
-  logger.debug('cannot read code version from ver.txt: ' + e);
+if (config.get('env') === 'production') {
+  try {
+    var contents = fs.readFileSync(path.join(__dirname, '..', 'resources', 'static', 'ver.txt'));
+    sha = contents.toString().split(' ')[0];
+    if (sha.length != 7) throw "bad sha in ver.txt";
+  } catch(e) {
+    sha = undefined;
+    logger.debug('cannot read code version from ver.txt: ' + e);
+  }
 }
 
 // now set the SHA to either the read SHA or a random string
-module.exports = function() { return sha; }
+module.exports = function() { return sha; };
 
 // if ver.txt discovery failed, try using git to get the sha.
 if (!sha) {
@@ -40,10 +43,10 @@ if (!sha) {
   p.stdout.on('data', function(d) {
     buf += d;
   });
-  p.on('exit', function(code, signal) {
+  p.stdout.on('end', function(code, signal) {
     var gitsha = buf.toString().trim();
     if (gitsha && gitsha.length === 7) {
-      sha = gitsha
+      sha = gitsha;
       logger.info('code version (via git) is: ' + module.exports());
     } else {
       logger.warn('code version (randomly generated) is: ' + module.exports());