Search code examples
rubyrubygemsansiblecompass

Ansible : compass-core missing in gem list


I face an issue with a grunt build so I check the version of compass (compass -v) and the same message happen :

stderr: /usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find compass-core (~> 1.0.2) amongst [compass-1.0.3, sass-3.4.18] (Gem::LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:777:in `block in activate_dependencies'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:766:in `each'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:750:in `activate'
    from /usr/lib/ruby/1.9.1/rubygems.rb:1232:in `gem'
    from /usr/local/bin/compass:22:in `<main>'

I've provide my server with ansible and I've already checked that sass :

Sass 3.4.18 (Selective Steve)

Does anyone know how to debug this ?


EDIT

The fact is I was using an old way to install sass and compass. After uninstalling and replaying the task ansible, I saw that only root has the gem installed.

$ gem list

*** LOCAL GEMS ***


$ sudo gem list

*** LOCAL GEMS ***

chunky_png (1.3.4)
compass (1.0.3)
compass-core (1.0.3)
compass-import-once (1.0.5)
ffi (1.9.10)
multi_json (1.11.2)
rb-fsevent (0.9.5)
rb-inotify (0.9.5)
sass (3.4.18)

So my question has change : How to install gem for a specific user or for all the user with ansible ?

Here my ansible script :

  - name: Install ruby gems as Grunt dependencies
    gem: name="{{ item }}" state=present include_dependencies=yes user_install=yes
    with_items:
      - sass
      - compass

the include_depencies and user_install are optional flags


Solution

  • To install the gem for a specific user you would need to run it in the context of the user, e.g.

      - name: Install ruby gems as Grunt dependencies
        gem: name="{{ item }}" state=present include_dependencies=yes user_install=yes
        with_items:
          - sass
          - compass
        become: yes
        become_user: someuser
    

    To install it globally, set user_install to a falsy value:

      - name: Install ruby gems as Grunt dependencies
        gem: name="{{ item }}" state=present include_dependencies=yes user_install=no
        with_items:
          - sass
          - compass
        become: yes
        become_user: root