krisdigitx
krisdigitx

Reputation: 7126

jenkins cannot run program "ruby" No such file or directory

I am running this job from jenkins and its failing constantly....

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/deploy-mapreduce/workspace
Capturing environment variables produced by 'rvm use ruby-1.9.3-p484'
$ bash -c export
$ bash -c "test -f ~/.rvm/scripts/rvm"
$ bash -c "test -f /usr/local/rvm/scripts/rvm"
[workspace] $ bash -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create ruby-1.9.3-p484 && export > rvm.env"
Using /usr/local/rvm/gems/ruby-1.9.3-p484
[workspace] $ ruby -v /tmp/hudson4593249725887441871.rb
FATAL: command execution failed
java.io.IOException: Cannot run program "ruby" (in directory "/var/lib/jenkins/jobs/deploy-mapreduce/workspace"): java.io.IOException: error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:773)
    at hudson.Launcher$ProcStarter.start(Launcher.java:353)
    at hudson.Launcher$ProcStarter.join(Launcher.java:360)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:94)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:63)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
    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:566)
    at hudson.model.Run.execute(Run.java:1677)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:231)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
    at java.lang.ProcessImpl.start(ProcessImpl.java:65)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
    ... 16 more

however i can run a test ruby file same from shell and it works OK

[root@jenkins01 etc]# su -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create ruby-1.9.3-p484 && export > rvm.env ; ruby -v /tmp/test.rb" -s /bin/bash jenkins
Using /usr/local/rvm/gems/ruby-1.9.3-p484
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
hello

I think its missing this file..." /tmp/hudson4593249725887441871.rb" but as user "jenkins" I can create files in /tmp directory fine....

Any ideas where the issue will be?

Upvotes: 2

Views: 2527

Answers (2)

Abhishek Singhal
Abhishek Singhal

Reputation: 1

Most likely, Jenkins cannot find the Ruby path, which is why it is giving a file not found exception. Try the below steps:

  1. Execute 'which ruby' - this will give you the full ruby path
  2. Replace this path in your program so instead of just writing ruby, give the full path.

Upvotes: 0

Jifeng Zhang
Jifeng Zhang

Reputation: 5147

The stack trace basically means the build process Jenkins started can not find ruby executable.

Use RVM Jenkins plugin if you can. And it:

Runs your entire build (from SCM check out to post-build actions) within the context of an RVM managed environment of your choice (as opposed to your doing "source ~/.rvm/scripts/rvm && rvm foo@bar", which only affects your current shell)

If the Ruby/gemset you specified doesn't exist on a slave that the build is running, it'll be automatically installed and created (via rvm_install_on_use_flag)

Upvotes: 1

Related Questions