Linux command
gem 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Install gem
gem install [package_name]
Install specific version
gem install [package_name] -v [1.2.3]
List installed gems
gem list
Update gem
gem update [package_name]
Uninstall gem
gem uninstall [package_name]
说明
gem is RubyGems' command-line package manager for installing, managing, and distributing Ruby libraries and applications. It provides access to RubyGems.org, the central repository hosting hundreds of thousands of community-contributed Ruby packages called "gems". The tool handles dependency resolution automatically, installing required gems and their dependencies in the correct order. It supports installing specific versions, updating existing gems, and managing multiple versions of the same gem simultaneously. Each gem includes metadata specifying its dependencies, Ruby version requirements, and other constraints. gem installs packages either system-wide (requiring sudo/administrator privileges) or in user-specific locations. It integrates with bundler for project-specific dependency management, allowing different projects to use different gem versions without conflict. The Gemfile and Gemfile.lock workflow, managed by bundler, has become the standard for Ruby applications. Beyond installation, gem provides commands for searching available packages, viewing documentation, building and publishing your own gems, and managing local gem caches. It's the cornerstone of Ruby's package ecosystem and an essential tool for all Ruby developers. RubyGems has been part of Ruby's standard library since version 1.9, making gem available with every Ruby installation.
参数
- install _GEM_
- Install gem package.
- uninstall _GEM_
- Remove gem.
- list
- List installed gems.
- update
- Update gems.
- search _TERM_
- Search for gems.
- -v _VERSION_
- Specify version.
- --help
- Display help information.
FAQ
What is the gem command used for?
gem is RubyGems' command-line package manager for installing, managing, and distributing Ruby libraries and applications. It provides access to RubyGems.org, the central repository hosting hundreds of thousands of community-contributed Ruby packages called "gems". The tool handles dependency resolution automatically, installing required gems and their dependencies in the correct order. It supports installing specific versions, updating existing gems, and managing multiple versions of the same gem simultaneously. Each gem includes metadata specifying its dependencies, Ruby version requirements, and other constraints. gem installs packages either system-wide (requiring sudo/administrator privileges) or in user-specific locations. It integrates with bundler for project-specific dependency management, allowing different projects to use different gem versions without conflict. The Gemfile and Gemfile.lock workflow, managed by bundler, has become the standard for Ruby applications. Beyond installation, gem provides commands for searching available packages, viewing documentation, building and publishing your own gems, and managing local gem caches. It's the cornerstone of Ruby's package ecosystem and an essential tool for all Ruby developers. RubyGems has been part of Ruby's standard library since version 1.9, making gem available with every Ruby installation.
How do I run a basic gem example?
Run `gem install [package_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does install _GEM_ do in gem?
Install gem package.