title: Jenkins - Rake plugin can not find Rake
body: <p>I'm using several Rake steps in my Jenkins job (through Rake plugin), but it claims to be unable to find Rake:</p>
  
  <pre><code>+ bundle update
  .................................
  Using rake (0.9.2.2) 
  .................................
  [workspace] $ rake db:drop
  FATAL: rake execution failed
  java.io.IOException: Cannot run program "rake" (in directory "/var/lib/jenkins/jobs/myproject/workspace"): java.io.IOException: error=2, No such file or directory
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
      at hudson.Proc$LocalProc.&lt;init&gt;(Proc.java:244)
      at hudson.Proc$LocalProc.&lt;init&gt;(Proc.java:216)
      at hudson.Launcher$LocalLauncher.launch(Launcher.java:709)
      at hudson.Launcher$ProcStarter.start(Launcher.java:338)
      at hudson.Launcher$ProcStarter.join(Launcher.java:345)
      at hudson.plugins.rake.Rake.perform(Rake.java:141)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717)
      at hudson.model.Build$BuildExecution.build(Build.java:199)
      at hudson.model.Build$BuildExecution.doRun(Build.java:160)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
      at hudson.model.Run.execute(Run.java:1502)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:236)
  Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
      at java.lang.UNIXProcess.&lt;init&gt;(UNIXProcess.java:164)
      at java.lang.ProcessImpl.start(ProcessImpl.java:81)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:468)
      ... 15 more
  Build step 'Invoke Rake' marked build as failure
  Finished: FAILURE
  </code></pre>
  
  <p>And if I manually specify the Ruby path in Jenkins's config:</p>
  
  <pre><code>[workspace] $ rake db:drop
  [31mERROR: Gem rake is not installed, run `gem install rake` first.(B[m
  Build step 'Invoke Rake' marked build as failure
  Finished: FAILURE
  </code></pre>
  
  <p>If I execute rake in Jenkins as a plain shell command, without Rake plugin:</p>
  
  <pre><code>+ rake db:drop
  /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/yaml.rb:56:in `&lt;top (required)&gt;':
  It seems your ruby installation is missing psych (for YAML output).
  To eliminate this warning, please install libyaml and reinstall your ruby.
  </code></pre>
  
  <p>When I execute "bundle exec rake db:drop" happens the same but twice.</p>
  
  <p>Temporarily including two lines in the job:</p>
  
  <pre><code>rvm pkg install libyaml
  rvm reinstall 1.9.3
  </code></pre>
  
  <p>does not help. (Update: this is only warning and does not affect anything, but is quite annoying).</p>
  
  <p>I have another RVM + Ruby bundle installed outside of Jenkins in ~/.rvm directory, and it works just fine.</p>