installing ruby with rbenv on OS X fails

This task

  • name: Install Ruby
    command: /usr/local/bin/rbenv install 2.2.3

fails with a

stderr: rbenv: no such command `install

message

I’ve tried shell and raw as well and I get the same message.

Any ideas on a fix?

some more information:

/usr/local/bin/rbenv install 2.2.3

works if I just ssh into the box

if I prelude the task with another that

git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

then rbenv picks up the ruby-build plug and the Install Ruby task starts

However now the task never exits, although the correct version of ruby has been installed

Anyone got this working?

Eventually settled on

  • name: Install Ruby
    shell: ‘export PATH=/usr/local/bin:$PATH; /usr/local/bin/rbenv install 2.2.3’
    args:
    creates: /Users/jenkins/.rbenv/versions/2.2.3
    become: yes
    become_user: jenkins