# Upgrade ruby from 2.7.4 - 3.3.5 using Ansible

**URL:** <https://forum.ansible.com/t/upgrade-ruby-from-2-7-4-3-3-5-using-ansible/11172>\
**Category:** Get Help\
**Tags:** ubuntu, aws\
**Created:** [November 26, 2024, 9:37pm UTC](https://forum.ansible.com/t/upgrade-ruby-from-2-7-4-3-3-5-using-ansible/11172 "2024-11-26T21:37:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renzo](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@Renzo](https://forum.ansible.com/u/Renzo)\
**Post date:** [November 26, 2024, 9:37pm UTC](https://forum.ansible.com/t/upgrade-ruby-from-2-7-4-3-3-5-using-ansible/11172/1 "2024-11-26T21:37:07Z")

</div>

Hi all, im new to ansible and Ruby but Ive been tasked with creating a new AWS AMI using Packer and Ansible.

I have updated the following application.yml from version 2.7.4 to 3.3.5 and the build fails.

Heres the relevant part of the applications.yml file that ive updated:

rbenv:  
env: user  
version: v1.3.0  
default\_ruby: 3.3.5  
rubies:  
- version: 3.3.5  
rbenv\_users:

- ‘{{ user }}’

and heres the config in main.yml

* * *

- name: xxx-xxx-application  
hosts: all  
gather\_facts: true  
become: true  
tasks:

The command I run to trigger the build is:  
AWS\_PROFILE=staging packer build -var “env=staging” -var “terraform-env=stage” packer-application

This results in the following error that seems to be related to zzet.rbenv having issues with ‘psych’ package which I cannot resolve. I cannot log into the instance to check the logfile that is mentioned in the error message. I am running this command from my M1 macbook pro

TASK [zzet.rbenv : install specified ruby versions for select users] \*\*\*\*\*\*\*\*\*\*\*

failed: [default] (item=Install 3.3.5 for deploy) =\> {“ansible\_loop\_var”: “item”, “changed”: true, “cmd”: “$0 -lc "~/.rbenv/bin/rbenv install --skip-existing 3.3.5"”, “delta”: “0:54:15.124169”, “end”: “2024-11-26 19:35:25.609907”, “item”: [“deploy”, {“version”: “3.3.5”}], “msg”: “non-zero return code”, “rc”: 1, “start”: “2024-11-26 18:41:10.485738”, “stderr”: " % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0\r 43 21.1M 43 9386k 0 0 28.7M 0 --:–:-- --:–:-- --:–:-- 28.6M\r100 21.1M 100 21.1M 0 0 34.0M 0 --:–:-- --:–:-- --:–:-- 33.9M\n\*\*\* Following extensions are not compiled:\npsych:\n\tCould not be configured. It will not be installed.\n\tCheck /tmp/ruby-build.20241126184111.18009.DRx5Qy/ruby-3.3.5/ext/psych/mkmf.log for more details.\n\nBUILD FAILED (Ubuntu 20.04 on x86\_64 using ruby-build 20241105-9-g7ccb143c)\n\nYou can inspect the build directory at /tmp/ruby-build.20241126184111.18009.DRx5Qy\nSee the full build log at /tmp/ruby-build.20241126184111.18009.log", “stderr\_lines”: [" % Total % Received % Xferd Average Speed Time Time Time Current", " Dload Upload Total Spent Left Speed", “”, " 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0", " 43 21.1M 43 9386k 0 0 28.7M 0 --:–:-- --:–:-- --:–:-- 28.6M", “100 21.1M 100 21.1M 0 0 34.0M 0 --:–:-- --:–:-- --:–:-- 33.9M”, “\*\*\* Following extensions are not compiled:”, “psych:”, “\tCould not be configured. It will not be installed.”, “\tCheck /tmp/ruby-build.20241126184111.18009.DRx5Qy/ruby-3.3.5/ext/psych/mkmf.log for more details.”, “”, “BUILD FAILED (Ubuntu 20.04 on x86\_64 using ruby-build 20241105-9-g7ccb143c)”, “”, “You can inspect the build directory at /tmp/ruby-build.20241126184111.18009.DRx5Qy”, “See the full build log at /tmp/ruby-build.20241126184111.18009.log”], “stdout”: “==\> Downloading ruby-3.3.5.tar.gz…\n → curl -q -fL -o ruby-3.3.5.tar.gz [https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.5.tar.gz\n==](https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.5.tar.gz%5Cn==)\> Installing ruby-3.3.5…\n → ./configure "–prefix=$HOME/.rbenv/versions/3.3.5" --enable-shared --with-ext=openssl,psych,+\n → make -j 2”, “stdout\_lines”: [“==\> Downloading ruby-3.3.5.tar.gz…”, “-\> curl -q -fL -o ruby-3.3.5.tar.gz [https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.5.tar.gz](https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.5.tar.gz)”, “==\> Installing ruby-3.3.5…”, “-\> ./configure "–prefix=$HOME/.rbenv/versions/3.3.5" --enable-shared --with-ext=openssl,psych,+”, “-\> make -j 2”]}

would appreciate if someone could point me in the right direction on how to fix this as ive added the “libyaml-dev” package that is a pre-req for the “psych” package but it makes no difference.

Many thanks in advance

---

<div class="post-metadata">

**Author:** ![Renzo](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@Renzo](https://forum.ansible.com/u/Renzo)\
**Post date:** [December 11, 2024, 11:31am UTC](https://forum.ansible.com/t/upgrade-ruby-from-2-7-4-3-3-5-using-ansible/11172/2 "2024-12-11T11:31:01Z")

</div>

Ive now resolved this issue as ive found that the ansible.builtin.apt command did not deploy the any of the packages I listed in the ansible.yaml file.

I found this out by accessing the temp EC2 instance that was creating the AMI and listing installed packages. In the end I installed libyaml-dev from the command line and after a while ruby 3.3.5 was installed.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [January 10, 2025, 11:31am UTC](https://forum.ansible.com/t/upgrade-ruby-from-2-7-4-3-3-5-using-ansible/11172/3 "2025-01-10T11:31:11Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
