Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 463 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ruby: How to install a specific version of a ruby gem?

#1
Using the command-line `gem` tool, how can I install a specific version of a gem?
Reply

#2
Use the `-v` flag:

$ gem install fog -v 1.8
Reply

#3
**Linux**

To install different version of ruby, check the latest version of package using `apt` as below:

$ apt-cache madison ruby
ruby | 1:1.9.3 |

[To see links please register here]

wheezy/main amd64 Packages
ruby | 4.5 |

[To see links please register here]

squeeze/main amd64 Packages

Then install it:

$ sudo apt-get install ruby=1:1.9.3

To check what's the current version, run:

$ gem --version # Check for the current user.
$ sudo gem --version # Check globally.

If the version is still old, you may try to switch the version to new by using ruby version manager (`rvm`) by:

rvm 1.9.3

Note: You may prefix it by `sudo` if `rvm` was installed globally. Or run `/usr/local/rvm/scripts/rvm` if your command `rvm` is not in your global `PATH`. If rvm installation process failed, see the troubleshooting section.

----------
Troubleshooting:

- If you still have the old version, you may try to install rvm (ruby version manager) via:

sudo apt-get install curl # Install curl first
curl -sSL

[To see links please register here]

| bash -s stable --ruby # Install only for the user.
#or:# curl -sSL

[To see links please register here]

| sudo bash -s stable --ruby # Install globally.

then if installed locally (only for current user), load rvm via:

source /usr/local/rvm/scripts/rvm; rvm 1.9.3

if globally (for all users), then:

sudo bash -c "source /usr/local/rvm/scripts/rvm; rvm 1.9.3"

- if you still having problem with the new ruby version, try to install it by rvm via:

source /usr/local/rvm/scripts/rvm && rvm install ruby-1.9.3 # Locally.
sudo bash -c "source /usr/local/rvm/scripts/rvm && rvm install ruby-1.9.3" # Globally.
- if you'd like to install some gems globally and you have rvm already installed, you may try:

rvmsudo gem install [gemname]

instead of:

gem install [gemname] # or:
sudo gem install [gemname]

> Note: It's prefered to NOT use sudo to work with RVM gems. When you do
> sudo you are running commands as root, another user in another shell
> and hence all of the setup that RVM has done for you is ignored while
> the command runs under sudo (such things as GEM_HOME, etc...). So to
> reiterate, as soon as you 'sudo' you are running as the root system
> user which will clear out your environment as well as any files it
> creates are not able to be modified by your user and will result in
> strange things happening.
Reply

#4
As others have noted, in general use the `-v` flag for the `gem install` command.

If you're developing a gem locally, after cutting a gem from your gemspec:

$ gem install gemname-version.gem


Assuming version 0.8, it would look like this:

$ gem install gemname-0.8.gem
Reply

#5
For installing
`gem install gemname -v versionnumber`

For uninstall
`gem uninstall gemname -v versionnumber`
Reply

#6
for Ruby 1.9+ use colon.

gem install sinatra:1.4.4 prawn:0.13.0
Reply

#7
You can use the `-v` or `--version` flag. For example

gem install bitclock -v '< 0.0.2'

To specify upper AND lower version boundaries you can specify the `--version` flag twice

gem install bitclock -v '>= 0.0.1' -v '< 0.0.2'

or use the syntax (for example)

gem install bitclock -v '>= 0.0.1, < 0.0.2'

The other way to do it is

gem install bitclock:'>= 0.0.1'

but with the last option it is not possible to specify upper and lower bounderies simultaneously.

[gem 3.0.3 and ruby 2.6.6]
Reply

#8
Use the `--version` parameter (shortcut `-v`):

$ gem install rails -v 0.14.1

Successfully installed rails-0.14.1

---

You can also use version comparators like `>=` or `~>`

$ gem install rails -v '~> 0.14.0'

Successfully installed rails-0.14.4

---

With newer versions of *rubygems* you can tighten up your requirements:

$ gem install rails -v '~> 0.14.0, < 0.14.4'

Successfully installed rails-0.14.3

---

Since some time now you can also specify versions of multiple gems:

$ gem install rails:0.14.4 rubyzip:'< 1'

Successfully installed rails-0.14.4
Successfully installed rubyzip-0.9.9

But this doesn't work for more than one comparator per gem (yet).
Reply

#9
Prior to installing, you can check the available versions with the list command.

```
gem list ^[gemname]$ --remote --all
gem install [gemname] -v [version]
```
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through