         pid.stdin.end()
         pidCallback(pid)
 
-    checkForServerCP(20) # 40 sec should be enough?
+
+    if(not classpathFileOk(cpF))
+      withSbt (sbtCmd) =>
+        updateEnsimeServer(sbtCmd, scalaVersion, ensimeServerVersion)
+        checkForServerCP(20) # 40 sec should be enough?
+    else
+      checkForServerCP(20) # 40 sec should be enough?
+
+
 
 
 


  fs.writeFileSync(tempdir + path.sep + 'project' + path.sep + 'build.properties', 'sbt.version=0.13.8\n')

  sbtCmd = atom.config.get('Ensime.sbtExec')
  if sbtCmd
    updateServer(sbtCmd)
  else
    dialog = remote.require('dialog')
    dialog.showOpenDialog({title: "Sorry, but we need you to point out your SBT executive", properties:['openFile']}, (filename) =>
        sbtCmd = filename
        atom.config.set('Ensime.sbtExec', filename)
        updateServer(sbtCmd)
      )

  updateServer = (cmd) =>
    console.log("sbt: " + cmd)

    # run sbt "saveClasspath" "clean"
    pid = spawn("#{cmd}", ['-Dsbt.log.noformat=true', 'saveClasspath', 'clean'], {cwd: tempdir})
    pid.stdout.on 'data', (chunk) -> log(chunk.toString('utf8'))
    pid.stderr.on 'data', (chunk) -> log('ensime startup exec error: ' + chunk.toString('utf8'))

    pid.stdout.on 'data', (chunk) => @serverUpdateLog.addRow(chunk.toString('utf8'))
    pid.stderr.on 'data', (chunk) => @serverUpdateLog.addRow('ensime startup exec error: ' + chunk.toString('utf8'))

    pid.stdin.end()


versions = ->

    updateEnsimeServer(scalaVersion, ensimeServerVersion)


updateEnsimeServer = (sbtCmd, scalaVersion, ensimeServerVersion) ->
  @serverUpdateLog = new EnsimeServerUpdateLogView()

  pane = atom.workspace.getActivePane()
