- Docs »
- gem – Manage Ruby gems
- 
        
            
            
              
                
                
                  
 
 
          
          
           
            
  
gem – Manage Ruby gems
    
        | Parameter | Choices/Defaults | Comments | 
                
                                                            | build_flags 
                    -
                                                                 |  | Allow adding build flags for gem compilation | 
                            
                                                            | env_shebang 
                    boolean
                                                                 |  | Rewrite the shebang line on installed scripts to use /usr/bin/env. | 
                            
                                                            | executable 
                    -
                                                                 |  | Override the path to the gem executable | 
                            
                                                            | force 
                    boolean
                                                                 added in 2.8 |  | Force gem to install, bypassing dependency checks. | 
                            
                                                            | gem_source 
                    -
                                                                 |  | The path to a local gem used as installation source. | 
                            
                                                            | include_dependencies 
                    boolean
                                                                 |  | Whether to include dependencies or not. | 
                            
                                                            | include_doc 
                    boolean
                                                                 |  | Install with or without docs. | 
                            
                                                            | install_dir 
                    -
                                                                 added in 2.6 |  | Install the gems into a specific directory. These gems will be independent from the global installed ones. Specifying this requires user_install to be false. | 
                            
                                                            | name 
                    -
                                             / required                     |  | The name of the gem to be managed. | 
                            
                                                            | pre_release 
                    boolean
                                                                 |  | Allow installation of pre-release versions of the gem. | 
                            
                                                            | repository 
                    -
                                                                 |  | The repository from which the gem will be installed aliases: source
 | 
                            
                                                            | state 
                    -
                                                                 | Choices:
                                                                                                                                                                                            present ←absentlatest | The desired state of the gem. latestensures that the latest version is installed. | 
                            
                                                            | user_install 
                    boolean
                                                                 |  | Install gem in user's local gems cache or for all users | 
                            
                                                            | version 
                    -
                                                                 |  | Version of the gem to be installed/removed. | 
                    
 
# Installs version 1.0 of vagrant.
- gem:
    name: vagrant
    version: 1.0
    state: present
# Installs latest available version of rake.
- gem:
    name: rake
    state: latest
# Installs rake version 1.0 from a local gem on disk.
- gem:
    name: rake
    gem_source: /path/to/gems/rake-1.0.gem
    state: present
 
Authors
Hint
If you notice any issues in this documentation, you can edit this document to improve it.