2

I'm trying to bootstrap a rails dev environment with ansible on Ubuntu 14.04, using rbenv to handle managing ruby versions. I have a playbook that does various things that work successfully but I've taken out the relevant parts in this gist

Upon running this task:

- name: Install ruby with rbenv
  sudo_user: "{{ username }}"
  #command: rbenv install {{ ruby_version }}
  command: zsh -lc "rbenv install {{ ruby_version }}"

I get the following error

failed: [localhost] => {"changed": true, "cmd": ["zsh", "-lc", "rbenv install 2.1.2"], "delta": "0:00:00.005791", "end": "2015-04-21 09:31:19.184810", "rc": 127, "start": "2015-04-21 09:31:19.179019"}
stderr: zsh:1: command not found: rbenv

All previous tasks are successful, including getting For some reason upon running this I get an error that rbenv is not installed.

You can see I commented out just using "rbenv install" because someone suggested that since rbenv counts on your certain things being in your .bashrc (or .zshrc in my case) you need to run it with the shell. But this didn't work either.

I also tried adding a task to restart my shell using the raw module. And I tried running with shell instead of command.

Here's my zshrc in case that's relevant.

I checked this answer but they just mentioned a problem with using "when" with newer version. Also no one answered this question, which is similar.

Community
  • 1
  • 1
  • The rbenv binary isn't being found in your PATH. Have you tried sourcing your `~/.bashrc` (or whatever file you're declaring your `rbenv init` in)? Moreover, did you remember to add these lines after installing rbenv https://github.com/sstephenson/rbenv#basic-github-checkout? – Josh Bodah Apr 21 '15 at 19:35

1 Answers1

1

It looks like for some reason the command zsh -lc is not properly loading the value of PATH to include the rbenv command, even though you have it set in your .zshrc.

This is a bit of a hack, but I was able to get rbenv running by replacing

command: zsh -lc "rbenv install {{ ruby_version }}"

with

command: zsh -lc "{{home_dir}}.rbenv/bin/rbenv install {{ ruby_version }}"

dex
  • 159
  • 7