{

How to install and uninstall gem in Ruby Programming| Ruby on Rails by Example


This post explains about to install and uninstall gem with versions in the Ruby application.

It also includes a specific range of versions

Ruby gem install with a specific version

gem install command installs the library. You can use either a specific version or version comparator

  • Specific version using -v or --version You can include -v or --version to install a specific version
gem install library -v versionnumber
or
gem install library --version versionnumber

For example, you want to install the package with version 1.2.0

gem install package -v 1.2.0

With ruby version 1.19.0 onwards, You can use the colon

gem install package1:1.0.1 
  • Version Comparator.

Version comparator does not give a specific version, Instead, It gives version comparison such as greater or less than. The symbols being used are >= or ~>.

For example,

  gem install package -v '~> 1.1.0'

It installs versions greater than 1.1.0.

gem install package -v '~> 1.1.0, < 1.2.0'

The package version selected is greater than 1.1.0 and less than 1.2.0

You can also specify multiple gem packages with different versions

gem install package1:1.0.1 package2:'> 2'

Ruby gem uninstall with version

`gem uninstall command removes library. you can also include the version number.

Here is a command

gem uninstall library -v versionnumber
or
gem uninstall library --version versionnumber
THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.





Related posts

How to do sum of array numbers in Ruby with examples

How to check the type of a variable is Ruby| Ruby on Rails By Example

How to convert Class or Hash Object to JSON Object Ruby| Ruby on Rails By Example

How to remove duplicate elements from an array in Ruby with examples

How to Convert current Unix timestamp epoch to DateTime in Ruby Programming| Ruby on Rails by Example

How to remove an element from an array in Ruby Programming| Ruby on Rails by Example

How to print the name of a Ruby class| Ruby on Rails By Example