msg: Failed to find required executable gem

Hi,

I am new to Vagrant and Ansible. Trying to use a playbook to install compass using gem command but got the following error. Seem like i miss some setting on env?

TASK: [ruby | Ruby | Install compass gem] *************************************

failed: [default] => {“failed”: true}

msg: Failed to find required executable gem

FATAL: all hosts have already failed – aborting

This is the playbook content:

What version of Ansible are you running?

ansible-playbook --version

ansible-playbook 1.7 (devel 27a73f2c11) last updated 2014/08/01 15:00:46 (GMT -500)

Sounds like you may need to pass the executable parameter.

http://docs.ansible.com/gem_module.html

Don’t think that is the issue, i already tried below before.Same issue.

FWIW, in what you have pasted above, you are not passing the executable parameter.

Where is the gem executable on your machine?

Where is the gem command on your system?

RubyGems Environment:

  • RUBYGEMS VERSION: 1.6.2

  • RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [i686-linux]

  • INSTALLATION DIRECTORY: /opt/vagrant_ruby/lib/ruby/gems/1.8

  • RUBY EXECUTABLE: /opt/vagrant_ruby/bin/ruby

  • EXECUTABLE DIRECTORY: /opt/vagrant_ruby/bin

  • RUBYGEMS PLATFORMS:

  • ruby

  • x86-linux

  • GEM PATHS:

  • /opt/vagrant_ruby/lib/ruby/gems/1.8

  • /home/vagrant/.gem/ruby/1.8

  • GEM CONFIGURATION:

  • :update_sources => true

  • :verbose => true

  • :benchmark => false

  • :backtrace => false

  • :bulk_threshold => 1000

  • REMOTE SOURCES:

  • http://rubygems.org/

Looks like you definitely need to pass the executable flag again.

I know you said you tried this, so if so, please show the playbook and the output. Otherwise, I’m going off the paste above that shows it not being passed :slight_smile:

Thanks!

Thanks. Finally this time around it work, i might type some things wrong last time.

Just a follow-up question, what is the expected default path to avoid providing the executable path? thanks.

If not specified, it will look in the standard system path.

Note that ansible will take measures to ensure any user config (.bashrc) is not loaded, because it wants things to be predictable and repeatable, so this would be the normal things like /usr/bin/gem, etc, where you would find gem if you did a normal OS package install (like yum/apt).

I’m also receiving an error when trying to install compass using a playbook (on an AWS EC2 instance)
Usually we use the following script to install compass -

curl -L https://get.rvm.io | bash -s stable
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.2
rvm use 2.1.2 --default
gem install compass

I’ve tried converting this to script to the following playbook -