rvm / rvm1-ansible

The official ansible RVM role to install and manage your Ruby versions.
MIT License
271 stars 136 forks source link

Error while evaluating conditional (rvm1_delete_ruby): 'ruby' is undefined #156

Closed geerlingguy closed 4 years ago

geerlingguy commented 7 years ago

When I try to delete an older version of ruby using rvm1_delete_ruby, I get the following error:

TASK [rvm_io.ruby : Detect if ruby version can be deleted] *************************************************************
fatal: [hostname]: FAILED! => {"failed": true, "msg": "The conditional check 'rvm1_delete_ruby' failed. The error was: error while evaluating conditional (rvm1_delete_ruby): 'ruby' is undefined\n\nThe error appears to have been in '/Users/jeff.geerling/playbook/roles/rvm_io.ruby/tasks/rubies.yml': line 65, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Detect if ruby version can be deleted\n  ^ here\n"}

Tried this on two servers where I had rvm1_rubies: ['ruby-2.3.3'] originally, then set rvm1_rubies: ['ruby-2.3.4'], and added the variable rvm1_delete_ruby: ruby-2.3.1 and ran the playbook again.

geerlingguy commented 7 years ago

For now, on the servers where this was happening, I manually ran sudo /usr/local/rvm/bin/rvm remove ruby-2.3.1 to get the old version removed. Couldn't figure out why the error was happening though :-/

Scaramush commented 6 years ago

I was able to fix it by changing when statement in "Detect if ruby version can be deleted" and "Delete ruby version" from when: rvm1_delete_ruby to when: rvm1_delete_ruby is defined in "Detect if ruby version can be deleted" and from when: rvm1_delete_ruby and detect_delete_ruby.rc == 0 to when: (rvm1_delete_ruby is defined) and (detect_delete_ruby.rc == 0) in "Delete ruby version"

thbar commented 4 years ago

This is being addressed in https://github.com/rvm/rvm1-ansible/pull/212 (wip).

thbar commented 4 years ago

212 has been merged in master and seems to work well (except a bug on "check" mode #218). I believe we can close for now!