jenkinsci / rbenv-plugin

Deprecated, see https://www.jenkins.io/jep/7
MIT License
59 stars 19 forks source link

$HOME not being interpolated on remote node. #26

Open ampledata opened 10 years ago

ampledata commented 10 years ago

From the build's console log:

$ bash -c "[ -d \$HOME/.rbenv ]"
$ bash -c "[ -d \$HOME/.rbenv/plugins/ruby-build ]"
$ bash -c "cd /home/jenkins/workspace/xxx && env RBENV_ROOT\=\$HOME/.rbenv RBENV_VERSION\=2.1.1 \$HOME/.rbenv/bin/rbenv local 2>/dev/null || true"
$ bash -c "mkdir \$HOME/.rbenv.lock"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv RBENV_VERSION\=2.1.1 \$HOME/.rbenv/bin/rbenv versions --bare"
Updating rbenv...
$ bash -c "cd \$HOME/.rbenv && git checkout master && git pull"
Already on 'master'
Already up-to-date.
Updated rbenv.
Updating ruby-build...
$ bash -c "cd \$HOME/.rbenv/plugins/ruby-build && git checkout master && git pull"
Already on 'master'
Already up-to-date.
Updated ruby-build.
Installing 2.1.1...
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv RBENV_VERSION\=2.1.1 \$HOME/.rbenv/bin/rbenv install 2.1.1"
Downloading ruby-2.1.1.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/e57fdbb8ed56e70c43f39c79da1654b2
Installing ruby-2.1.1...

BUILD FAILED

Inspect or clean up the working tree at /tmp/ruby-build.20140307194332.8158
Results logged to /tmp/ruby-build.20140307194332.8158.log

Last 10 log lines:
                              io-console 0.4.2
                              json 1.8.1
                              minitest 4.7.5
                              psych 2.0.3
                              rake 10.1.0
                              rdoc 4.1.0
                              test-unit 2.1.1.0
installing rdoc:              /home/jenkins/$(HOME)/.rbenv/versions/2.1.1/share/ri/2.1.0/system
installing capi-docs:         /home/jenkins/$(HOME)/.rbenv/versions/2.1.1/share/doc/ruby
$HOME/.rbenv/plugins/ruby-build/bin/ruby-build: line 781: /home/jenkins/$HOME/.rbenv/versions/2.1.1/bin/ruby: No such file or directory
$ bash -c "rmdir \$HOME/.rbenv.lock"
FATAL: (CommandError) failed: "env RBENV_ROOT\\=\\$HOME/.rbenv RBENV_VERSION\\=2.1.1 \\$HOME/.rbenv/bin/rbenv install 2.1.1"
org.jruby.exceptions.RaiseException: (CommandError) failed: "env RBENV_ROOT\\=\\$HOME/.rbenv RBENV_VERSION\\=2.1.1 \\$HOME/.rbenv/bin/rbenv install 2.1.1"
    at RUBY.run(/Users/Shared/Jenkins/Home/plugins/rbenv/WEB-INF/classes/lib/rbenv/invoke.rb:18)
    at RUBY.setup!(/Users/Shared/Jenkins/Home/plugins/rbenv/WEB-INF/classes/lib/rbenv.rb:29)
    at RUBY.synchronize(/Users/Shared/Jenkins/Home/plugins/rbenv/WEB-INF/classes/lib/rbenv/semaphore.rb:15)
    at RUBY.setup!(/Users/Shared/Jenkins/Home/plugins/rbenv/WEB-INF/classes/lib/rbenv.rb:24)
    at RUBY.setup(/Users/Shared/Jenkins/Home/plugins/rbenv/WEB-INF/classes/models/rbenv_wrapper.rb:61)
    at RUBY.setUp(/Users/Shared/Jenkins/Home/plugins/rbenv/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/model/environment_proxy.rb:8)
yyuu commented 10 years ago

Please describe more about your configuration. I will try to reproduce this if it is possible.

  1. Jenkins version
  2. rbenv plugin version
  3. Slave configuration
    1. the launcher type of the slave (JNLP, SSH or others)
    2. expected value for the $HOME on the master/slave
ampledata commented 10 years ago
  1. Jenkins ver. 1.558
  2. 0.0.16git
  3. i. JNLP ii. $HOME on slave should be '/home/jenkins-node'.

yyuu commented 10 years ago

I've been using rbenv plugin with ssh slaves, but there's no problem on my environment. I will try the JNLP slaves to reproduce the issue.

ampledata commented 10 years ago

Thanks, I appreciate it. I'm not sure if you saw my other note but this bug applies to the pyenv-plugin as well (probably same code path).

On Tue, Apr 29, 2014 at 7:26 PM, Yamashita, Yuu notifications@github.comwrote:

I've been using rbenv plugin with ssh slaves, but there's no problem on my environment. I will try the JNLP slaves to reproduce the issue.

— Reply to this email directly or view it on GitHubhttps://github.com/jenkinsci/rbenv-plugin/issues/26#issuecomment-41754588 .

Greg Albrecht gba@onbeep.com 310-621-9598 Cofounder & CTO, OnBeep, Inc. http://get.onbeep.com

ThaiMurugappan commented 10 years ago

Any updates on this? I get the same error even with SSH.

yyuu commented 10 years ago

I have tried to reproduce with both JNLP and SSH slaves, but could not see any problems. It seems that the environment variables like $HOME are properly expanded on remote hosts.

I suspect that the cause of the error is just a build problem of ruby in ruby-build, possibly missing build dependencies.

itsSaad commented 9 years ago

Any progress here? I'm having the same issue here. still

ghost commented 9 years ago

I kind of experience the same. My setup is rather simple. jenkins and a github repo with a rails project. No remote node.

Excuse if this is obvious but in the failing line of code the backslashes are duplicated.

Building in workspace /Users/timeoforigin-tsmacminiserver/.jenkins/jobs/backend-tryout/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@github.com:silvio/BACKEND.git # timeout=10
Fetching upstream changes from git@github.com:silvio/BACKEND.git
 > git --version # timeout=10
using GIT_SSH to set credentials 
 > git -c core.askpass=true fetch --tags --progress git@github.com:silvio/BACKEND.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 45762e95b5d3b3234abe7c80faa9fe666 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 45762e95b5d3b34abe7c80faa9fe666
 > git rev-list 45762e95b5d3b34abe7c80faa9fe666 # timeout=10
$ bash -c "[ -d \$HOME/.rbenv ]"
$ bash -c "[ -d \$HOME/.rbenv/plugins/ruby-build ]"
Just ignoring local Ruby version.
$ bash -c "mkdir \$HOME/.rbenv.lock"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv RBENV_VERSION\=2.1.6 \$HOME/.rbenv/bin/rbenv versions --bare"
$ bash -c "rm -rf \$HOME/.rbenv.lock"
FATAL: (CommandError) failed: "env RBENV_ROOT\\=\\$HOME/.rbenv RBENV_VERSION\\=2.1.6 \\$HOME/.rbenv/bin/rbenv versions --bare"
org.jruby.exceptions.RaiseException: (CommandError) failed: "env RBENV_ROOT\\=\\$HOME/.rbenv RBENV_VERSION\\=2.1.6 \\$HOME/.rbenv/bin/rbenv versions --bare"
    at RUBY.run(/Users/timeoforigin-tsmacminiserver/.jenkins/plugins/rbenv/WEB-INF/classes/lib/rbenv/invoke.rb:18)
    at RUBY.capture(/Users/timeoforigin-tsmacminiserver/.jenkins/plugins/rbenv/WEB-INF/classes/lib/rbenv/invoke.rb:11)
    at RUBY.setup!(/Users/timeoforigin-tsmacminiserver/.jenkins/plugins/rbenv/WEB-INF/classes/lib/rbenv.rb:25)
    at RUBY.synchronize(/Users/timeoforigin-tsmacminiserver/.jenkins/plugins/rbenv/WEB-INF/classes/lib/rbenv/semaphore.rb:15)
    at RUBY.setup!(/Users/timeoforigin-tsmacminiserver/.jenkins/plugins/rbenv/WEB-INF/classes/lib/rbenv.rb:24)
    at RUBY.setup(/Users/timeoforigin-tsmacminiserver/.jenkins/plugins/rbenv/WEB-INF/classes/models/rbenv_wrapper.rb:61)
    at RUBY.setUp(/Users/timeoforigin-tsmacminiserver/.jenkins/plugins/rbenv/WEB-INF/classes/vendor/gems/gems/jenkins-plugin-runtime-0.2.3/lib/jenkins/model/environment_proxy.rb:8)
Finished: FAILURE
thom4parisot commented 9 years ago

Had a similar issue. Removed $HOME/.rbenv from the agent and suddenly it worked again for the next builds of the same Job. Don't ask my why…

lnhrdt commented 9 years ago

$HOME doesn't seem to be set when I run my jobs. My CI is running on OSX. I tried setting it to the path (set by Jenkins) stored in $JENKINS_HOME

screen shot 2015-09-06 at 1 57 50 pm

And the effect can be seen in Build / Execute Shell. But it doesn't seem to have an effect on on the rbenv-plugin. I'm still getting this:

Building in workspace /var/root/.jenkins/jobs/ruby test/workspace
$ bash -c "[ -d \$HOME/.rbenv ]"
$ bash -c "[ -d \$HOME/.rbenv/plugins/ruby-build ]"
$ bash -c "cd /var/root/.jenkins/jobs/ruby\ test/workspace && env RBENV_ROOT\=\$HOME/.rbenv RBENV_VERSION\=2.2.2 \$HOME/.rbenv/bin/rbenv local 2>/dev/null || true"
$ bash -c "mkdir \$HOME/.rbenv.lock"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv RBENV_VERSION\=2.2.2 \$HOME/.rbenv/bin/rbenv versions --bare"
Updating rbenv...
$ bash -c "cd \$HOME/.rbenv && git checkout master && git pull"
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Already up-to-date.
Updated rbenv.
Updating ruby-build...
$ bash -c "cd \$HOME/.rbenv/plugins/ruby-build && git checkout master && git pull"
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Already up-to-date.
Updated ruby-build.
Installing 2.2.2...
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv RBENV_VERSION\=2.2.2 \$HOME/.rbenv/bin/rbenv install 2.2.2"
Downloading openssl-1.0.1p.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/bd5ee6803165c0fb60bbecbacacf244f1f90d2aa0d71353af610c29121e9b2f1
Installing openssl-1.0.1p...
$HOME/.rbenv/plugins/ruby-build/bin/ruby-build: line 923: //$HOME/.rbenv/versions/2.2.2/openssl/ssl/cert.pem: No such file or directory

BUILD FAILED (OS X 10.10.4 using ruby-build 20150818-4-g8d6ff29)

And this plugin created a "/$HOME" directory:

$ ls -la /\$HOME
drwxr-xr-x   3 root  wheel   102 Sep  6 13:43 .
drwxr-xr-x  34 root  wheel  1224 Sep  6 13:13 ..
drwxr-xr-x  14 root  wheel   476 Sep  6 13:12 .rbenv

Any reason why this plugin is using $HOME instead of $JENKINS_HOME?

lnhrdt commented 9 years ago

Solved my problem by running Jenkins as a regular user instead of root (which was unintentional in the first place).

I also realized I might have been able to solve it by changing this setting (hidden in the advanced settings): screen shot 2015-09-06 at 8 13 32 pm

Suraj-Project commented 5 years ago

I encountered with same error when trying to set rbenv from Jenkins. I tried the build removing RBENV_ROOT parameter as well. It gets set again to same. So no difference. Its still failing. Can someone help ?

$ bash -c "git clone https://github.com/sstephenson/rbenv.git \$HOME/.rbenv && cd \$HOME/.rbenv && git checkout master" Cloning into '/var/lib/jenkins/.rbenv'... fatal: unable to access 'https://github.com/sstephenson/rbenv.git/': Failed connect to github.com:443; Operation now in progress FATAL: (CommandError) failed: "git clone https://github.com/sstephenson/rbenv.git \$HOME/.rbenv && cd \$HOME/.rbenv && git checkout master" org.jruby.exceptions.RaiseException: (CommandError) failed: "git clone https://github.com/sstephenson/rbenv.git \$HOME/.rbenv && cd \$HOME/.rbenv && git checkout master"