msg: [Errno 2] No such file or directory when using bundle

Hello Ansible community!

I’m just getting started with Ansible, and seem to be not understanding why this happens.

My playbook

  • name: bundle install
    command: “bundle install”

args:
chdir: “~/ai_grading_production/”

I get the error msg: [Errno 2] No such file or directory when using bundle

When I actually specify the full path it works
command: “/home/ubuntu/.rvm/gems/ruby-2.2.2/wrappers/bundle install”

When I use the shell module it error with this message
stderr: /bin/sh: 1: bundle: not found

Does anyone know why I have to specify the full path to use the bundle command. And how can I fix? Thank you!

bundle is not in your PATH, changing to a directory does not include
it in your PATH (unless your PATH has ./ which is really not
recommended).

Hi

You are running into a typical rvm error. I assume you have some special rvm ruby version with a custom gemset.

The problem is, Ansible has to do the same rvm use ruby-2.1.5@gemset like you would do in your shell. Unless you are using the .ruby-(version|gemset) dotfiles.

Ansible does not know about this magick and is running your system ruby’s bundler command.

Kind regards
/mf