msg: Failed to find required executable gem

2,535 views
Skip to first unread message

Tze Yang Ng

unread,
Aug 2, 2014, 12:09:26 AM8/2/14
to ansible...@googlegroups.com
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:

---

- name: Ruby | Install Ruby

  apt: pkg=ruby update-cache=yes

  sudo: yes

  tags: ruby


- name: Ruby | Install compass gem

  gem: name=compass

  sudo: yes

  tags: ruby

Please help.

Michael DeHaan

unread,
Aug 2, 2014, 1:49:57 PM8/2/14
to ansible...@googlegroups.com
What version of Ansible are you running?

ansible-playbook --version




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a811190d-df33-41e8-8fe5-0051d671455a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tze Yang Ng

unread,
Aug 2, 2014, 3:48:41 PM8/2/14
to ansible...@googlegroups.com

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

Michael DeHaan

unread,
Aug 3, 2014, 12:15:19 PM8/3/14
to ansible...@googlegroups.com
Sounds like you may need to pass the executable parameter.





Tze Yang Ng

unread,
Aug 3, 2014, 1:32:51 PM8/3/14
to ansible...@googlegroups.com
Don't think that is the issue, i already tried below before.Same issue.

---
- name: Ruby | Install Ruby
  apt: pkg=ruby update-cache=yes
  sudo: yes
  tags: ruby

- name: Ruby | Install compass gem
  gem: name=compass state=latest
  sudo: yes
  tags: ruby

Michael DeHaan

unread,
Aug 3, 2014, 2:29:03 PM8/3/14
to ansible...@googlegroups.com
FWIW, in what you have pasted above, you are not passing the executable parameter.

Where is the gem executable on your machine?




Dick Davies

unread,
Aug 3, 2014, 6:07:55 PM8/3/14
to ansible list

Tze Yang Ng

unread,
Aug 3, 2014, 9:43:31 PM8/3/14
to ansible...@googlegroups.com, di...@hellooperator.net

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/

Michael DeHaan

unread,
Aug 4, 2014, 8:06:19 AM8/4/14
to ansible...@googlegroups.com, di...@hellooperator.net
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 :)

Thanks!




Tze Yang Ng

unread,
Aug 6, 2014, 12:34:44 AM8/6/14
to ansible...@googlegroups.com, di...@hellooperator.net
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.

Michael DeHaan

unread,
Aug 6, 2014, 11:17:25 AM8/6/14
to ansible...@googlegroups.com, di...@hellooperator.net
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).




yaron idan

unread,
Feb 18, 2016, 12:20:20 PM2/18/16
to Ansible Project
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 -
---
- hosts: "{{ host_name }}"
  become: yes
  become_user : deploy3
  tasks:
    - name: get gpg
      shell: "gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3"
    - name: install rvm
      shell: "curl -L https://get.rvm.io | bash -s stable"
    - name: install rvm 2.1.2
      shell: "/home/deploy2/.rvm/bin/rvm install 2.1.2"
    - name: use rvm 2.1.2 by default and install compass
      shell: "bash -lc \"/home/deploy2/.rvm/bin/rvm use 2.1.2 --default && /usr/bin/gem install compass\""
...

deploy is not a sudoer, but when I try to install compass manually it succeeds, and as a playbook I receive the following error - You don't have write permissions into the /var/lib/gems/1.9.1 directory.

I've tried installing compass any other way, including the one suggested here, but everything I try fails with various errors.
Has anyone encountered this issue and prevailed?
Reply all
Reply to author
Forward
0 new messages