Rvm Loading error -Playbook,ruby,rails

this is the anisble script file :

- name: Install RVM and Ruby 3.0.0
 shell: |

   curl -sSL https://rvm.io/mpapis.asc | gpg --import -
   curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
   curl -sSL https://get.rvm.io | bash -s stable
   curl -sSL https://get.rvm.io -o rvm.sh
   cat /tmp/rvm.sh | bash -s stable --rails
 become_user: root 

- name: Install RVM and Ruby 3.0.0
 shell: |
   source /home/ubuntu/.rvm/scripts/rvm
   rvm install 3.0.0
   rvm use 3.0.0 --default

when i run the ansible command got this error :
TASK [redisup : Install RVM and Ruby 3.0.0] ********************************************************************************************************************************
fatal: [node2]: FAILED! => {“changed”: true, “cmd”: “source /home/ubuntu/.rvm/scripts/rvm\nrvm install 3.0.0\nrvm use 3.0.0 --default\n”, “delta”: “0:00:00.003529”, “end”: “2023-09-12 20:45:28.672586”, “msg”: “non-zero return code”, “rc”: 127, “start”: “2023-09-12 20:45:28.669057”, “stderr”: “/bin/sh: 1: source: not found\n/bin/sh: 2: rvm: not found\n/bin/sh: 3: rvm: not found”, “stderr_lines”: [“/bin/sh: 1: source: not found”, “/bin/sh: 2: rvm: not found”, “/bin/sh: 3: rvm: not found”], “stdout”: “”, “stdout_lines”: }

2 Likes

Hey,

source command is a bash builtin, not sh builtin. Try using bash instead !

3 Likes

Hi @shekhar123! It looks like the post might be solved - could you check to see if the response by @ptn worked for you?

If so, it would be super helpful if you could click the :heavy_check_mark: on their post to accept the solution - it helps users find solutions (solved topics have a higher search priority), recognises the input of the people who help you, helps our volunteers find new issues to answer, and keeps the forum nice and tidy. It’s just a nice way to give back, and only takes a moment :slight_smile:

Thanks!
(this is template reply, do feel free to reply if I’ve misunderstood the situation!)

1 Like

after loading when i tried to install the rvm it not installing
i have shared the script file :slight_smile:

- name: Download and install RVM
  get_url:
    url: "https://get.rvm.io"
    dest: "/tmp/rvm_install.sh"

- name: Run RVM installation script
  script:
    cmd: "/bin/bash /tmp/rvm_install.sh"


- name: Load RVM environment
  ansible.builtin.shell:
    cmd: "~/.rvm/scripts/rvm"
    executable: /bin/bash

- name: Install RVM requirements
  ansible.builtin.shell: 
    cmd: "source ~/.rvm/scripts/rvm && rvm requirements"
    executable: /bin/bash 


#- name: Install RVM
#  shell: sudo chmod +x /etc/profile.d/rvm.sh
#  become: yes
#  shell: "curl -sSL https://get.rvm.io | bash -s stable; source ~/.rvm/scripts/rvm; rvm requirements"
#  shell: curl -sSL https://get.rvm.io | bash -s stable

#- name: load rvm
#  shell: bash -c "source ~/.rvm/scripts/rvm"

#- name: installing reuqiemnmet of the rvm 
#  ansible.builtin.shell:
#    cmd: "rvm install 3.1.2"
#    executable: bin/bash

- name: installing rvm
  command: rvm install 3.1.2

![image|690x68](upload://hro0y7Fs50sBURT6hsRPGJgApdP.png)

Hey,

I’m glad to see you fixed this thread issue ! I also see you opened a new one for your now current issue, so I guess you could resolve this one to avoid having a duplicate thread lying around.

1 Like