At the moment I'm working on Ansible role that installs ruby with rbenv. In order not to install same ruby version every time I run setup task I have to check that no needed ruby is already installed.

However, I have two cases:

1) when no ruby installed at all;

2) when some ruby versions already present.

For that purpose I use rbenv versions | grep {{ needed_ruby_version }}.

If system has at least one ruby version installed - everything is OK.

However, if there is no ruby at all - command rbenv versions | grep {{ needed_ruby_version }} returns Warning: no Ruby detected on the system, so that pipe and grep does nothing any more.

Is it possible to somehow modify this command and prevent this warning (or suppress it) and pass output to grep?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.