![]() |
Ruby: How to install a specific version of a ruby gem? - Printable Version +- 0Day Forums (https://0day.red) +-- Forum: Coding (https://0day.red/Forum-Coding) +--- Forum: Ruby (https://0day.red/Forum-Ruby) +--- Thread: Ruby: How to install a specific version of a ruby gem? (/Thread-Ruby-How-to-install-a-specific-version-of-a-ruby-gem) |
Ruby: How to install a specific version of a ruby gem? - racist454076 - 07-18-2023 Using the command-line `gem` tool, how can I install a specific version of a gem? RE: Ruby: How to install a specific version of a ruby gem? - earthstar705 - 07-18-2023 Use the `-v` flag: $ gem install fog -v 1.8 RE: Ruby: How to install a specific version of a ruby gem? - leukodystrophy789593 - 07-18-2023 **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 Packagesruby | 4.5 | [To see links please register here] squeeze/main amd64 PackagesThen 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. RE: Ruby: How to install a specific version of a ruby gem? - ruiiqfo - 07-18-2023 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 RE: Ruby: How to install a specific version of a ruby gem? - Mrentoproctqunb - 07-18-2023 For installing `gem install gemname -v versionnumber` For uninstall `gem uninstall gemname -v versionnumber` RE: Ruby: How to install a specific version of a ruby gem? - hatchability203189 - 07-18-2023 for Ruby 1.9+ use colon. gem install sinatra:1.4.4 prawn:0.13.0 RE: Ruby: How to install a specific version of a ruby gem? - trunk744 - 07-18-2023 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] RE: Ruby: How to install a specific version of a ruby gem? - deliberative915 - 07-18-2023 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). RE: Ruby: How to install a specific version of a ruby gem? - alieqmw - 07-18-2023 Prior to installing, you can check the available versions with the list command. ``` gem list ^[gemname]$ --remote --all gem install [gemname] -v [version] ``` |