Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RVM is not a function, selecting rubies with 'rvm use ...' will not work from jenkinsfile

I am trying to use a version of ruby via RVM in my Jenkinsfile like this:

sh 'rvm use ruby 2.3.1'

However, I believe the above command isn't doing what is intended because i get this message after it

+ rvm use ruby 2.3.1
 RVM is not a function, selecting rubies with 'rvm use ...' will not work.

I read other answers that suggest adding #!/bin/bash -xl, however, I am using this from Jenkinsfile and not a bash script.

is there a way to resolve this? I just want to set ruby to 2.3.1 and then run one command.

I've also tried using create default but still the version of ruby being printed is 2.0.0

  sh '''
    #!/bin/bash -xl
    echo $PATH
    rvm install ruby-2.3.1
    rvm alias create default 2.3.1 && ruby --version
    ruby --version
  '''
like image 975
Anthony Avatar asked Mar 30 '17 04:03

Anthony


People also ask

Is not a function selecting rubies with RVM use will not work?

RVM is not a function, selecting rubies with 'rvm use ...' will not work. You need to change your terminal emulator preferences to allow login shell. Sometimes it is required to use `/bin/bash --login` as the command. Please visit https://rvm.io/integration/gnome-terminal/ for an example.

How do I use Jenkins RVM?

From Jenkins' homepage, go to Manage Jenkins → Configure System and fill out RVM installation path under the Rake section. Now at your project configuration, when you add a new build step to invoke Rake task, you will see a list of Ruby versions and available gemsets ready at your disposal.

What are the functions of RVM?

rvm can only be used for regression at the moment. the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a dot product between two vector arguments.

Why can't I select rubies with RVM use?

RVM is not a function, selecting rubies with 'rvm use ...' will not work. Successfully installed wirble-0.1.3 1 gem installed Installing ri documentation for wirble-0.1.3... Installing RDoc documentation for wirble-0.1.3...

How do I change the default ruby version in RVM?

If you would like to make one specific Ruby be the default ruby that is selected when you open a new terminal shell, use the --default flag: $ rvm --default use 2.1.1 $ ruby -v ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0] The next time you open a window Ruby 2.1.1 will be the selected ruby. To switch back to your system ruby:

Why can’t I use Ruby on my terminal?

the problem is that terminals do not start login shell-this in turn makes rvm not being sourced and ending up you are not able to use rubies, to prevent the problem you tried to use ruby without knowing it I have added the message you see.


1 Answers

Put #!/bin/bash -l as the first line of your script. It creates a login shell.

You could also source rvm first before calling rvm use:

source /usr/local/rvm/scripts/rvm

like image 56
Clintm Avatar answered Sep 22 '22 06:09

Clintm