
将 Ruby Gem 更新到特定版本
- 打开 Gemfile。
- 在 gem 前面指定版本号。
- 运行 捆绑安装 。
How do I use RubyGems?
The gem command allows you to interact with RubyGems. Ruby 1.9 and newer ships with RubyGems built-in but you may need to upgrade for bug fixes or new features. To upgrade RubyGems or install it for the first time (if you need to use Ruby 1.9) visit the download page. If you want to see how to require files from a gem, skip ahead to What is a gem
How to update Ruby gems on rails?
Updating Ruby gems is a common task you have to do as a Ruby developer. Let’s briefly discuss how to update Ruby Gems on Rails. The command below only updates the RubyGems software, not the installed gems. To upgrade a gem to a specific version, re-install the gem and specify the version number.
How do I know if RubyGems is installed or not?
The list command shows your locally installed gems: (Ruby ships with some gems by default, bigdecimal, io-console, json, minitest, psych, rake, rdoc, test-unit for ruby 2.0.0). The uninstall command removes the gems you have installed. If you uninstall a dependency of a gem RubyGems will ask you for confirmation.
What is a RubyGems spec?
A specification (“.spec”) file that comes with every gem describes dependencies (other required gems) so the code has everything it needs to work Thanks to RubyGems, we have a rich ecosystem of helpful libraries just one gem install away!

How do you update a ruby gem?
RubyGemsUpdate RubyGems. To update to its latest version with: gem update --system.Install gems. To install a gem (Ruby package), run: gem install
How do I upgrade a specific version of a gem?
The correct way to update the version of a gem to a specific version is to specify the version you want in your Gemfile, then run bundle install . As for why your command line was failing, there is no -version option.
How do I update Ruby and rails?
To move between versions:Change the Rails version number in the Gemfile and run bundle update .Change the versions for Rails JavaScript packages in package. json and run yarn install , if running on Webpacker.Run the Update task.Run your tests.
How do I check my gem version?
To check if a specific version is installed, just add --version , e.g.: gem list -i compass --version 0.12.
How do you upgrade gems in Lost Ark?
With three gems inserted you can combine them into a new gem that is one level higher than the previous gems by pressing the Fuse button. If you don't want to manually fuse gems, then you can select the Auto-Fuse Stg. button and configure what level gems you want to upgrade to.
How do I update Ruby on my Mac?
Update Ruby Version in macOS Using rbenvInstall rbenv. Ruby. Copy brew install rbenv.Set up rbenv in your shell. Ruby. Copy rbenv init.Close and re-open your terminal so your changes can take effect.Install a Ruby version. Ruby. Copy rbenv install 2.7.
How do I upgrade ruby to Rbenv?
Upgrade rbenv. To include Ruby 3.1 as one of the available install options, first upgrade ruby-build: ... Install Ruby 3.1.0. rbenv install 3.1.0.Set local Ruby version. rbenv local 3.1.0. ... Update Gemfile. # old ruby "3.0.3" # new ruby "3.1.0" ... Debug gem. The debug gem is the new preferred debugger. ... New Features.
How do I change ruby to Rbenv?
2.1 Basic GitHub CheckoutAdd ~/. rbenv/bin to your $PATH for access to the rbenv command-line utility. ... Add rbenv init to your shell to enable shims and autocompletion. ... Restart your shell so the path changes take effect. ... Install Ruby versions into ~/.rbenv/versions . ... Rebuild the shim binaries.
How do I upgrade a Rails to a specific version?
If you already have a Rails project you should:Specify the desired version in your Gemfile (e.g. gem 'rails', '~> 5.2. ... Run bundle install ( bundle update may be needed)Run rails app:update ( rake rails:update for 4.2 and earlier)Follow instructions on screen.More items...
How do I know what version of Ruby I have installed?
For more information on rbenv, check the official GitHub repository.List the installed Ruby versions. To list the installed Ruby versions in your machine with rbenv, run the following command: rbenv version. ... Install a Ruby version. ... Use a specific Ruby version for a project.
What is the latest version of gem?
latest version of GEM (version 3.4)
How do I use a specific gem version?
You can install a specific gem version with gem install [name] -v [version] and use it as [name] _[version]_ [command] [line] [args] .
How do I use a specific gem version?
You can install a specific gem version with gem install [name] -v [version] and use it as [name] _[version]_ [command] [line] [args] .
How do I uninstall a specific version of a gem?
Removing a specific gemsudo gem uninstall GEMNAME.sudo gem uninstall GEMNAME --version 1.1.0.sudo gem cleanup GEMNAME.sudo gem cleanup.
How do I downgrade my gem version?
If you want to automate it in a script (I had the same problem after a gem update ), just do the following:Install your favored version (if you don't have already) gem install compass -v 1.2.3.Uninstall newer versions. gem uninstall compass -v '>1.2.3' --force.
How do I install a specific version of Ruby on Mac?
chruby and ruby-installruby-install is used to install different versions of Ruby and chruby is used to switch to a specific version.You can install chruby and ruby-install using Homebrew. ... Next, you can install Ruby using ruby-install . ... Afte Ruby is installed, add these 2 lines on ~/. ... chruby.sh enables chruby .More items...•
Update a Ruby Gem to a Specific Version
The command below only updates the RubyGems software, not the installed gems.
Upgrade a Ruby Gem to a Latest Version
To upgrade a gem to the latest version, re-install the gem without specifying any version number.
What is the gem command in Ruby?
The gem command allows you to interact with RubyGems. Ruby 1.9 and newer ships with RubyGems built-in but you may need to upgrade for bug fixes or new features. To upgrade RubyGems or install it for the first time (if you need to use Ruby 1.9) visit the download page. If you want to see how to require files from a gem, skip ahead to What is a gem.
How to audit a gem without installing it?
If you wish to audit a gem’s contents without installing it you can use the fetch command to download the .gem file then extract its contents with the unpack command.
What is the install command?
The install command downloads and installs the gem and any necessary dependencies then builds documentation for the installed gems.
How many rb files are in lib?
The lib directory itself normally contains only one .rb file and a directory with the same name as the gem which contains the rest of the files.
Does Ruby depend on rbtree?
Here the drip command depends upon the rbtree gem which has an extension. Ruby installs the dependency rbtree and builds its extension, installs the drip gem, then builds documentation for the installed gems.
Can you unpack a gem?
You can also unpack a gem you have installed, modify a few files, then use the modified gem in place of the installed one:
Can you add details to a gem?
If you see a gem you want more information on you can add the details option. You’ll want to do this with a small number of gems, though, as listing gems with details requires downloading more files:
Why do you save memory in bundler?
The benefit is that you save memory in your app code because you only load that gem when you need it. You can also group gems by environment. That means you can have gems that are only installed & loaded in development (like capybara & pry ). Finally, bundler creates a Gemfile.lock.
What is a gem in Ruby?
A gem is a package that you can download & install. When you require an installed gem you’re adding extra functionality to your Ruby program. Gems allow you to: Add a login feature to your Rails app. Easily work with external services (like APIs) Build a web application. That’s just some examples.
What is the require_paths array?
The require_paths array is where Ruby will look for your gem files when you require them. This allows you to put your code under lib/<gem_name>/ & then require it with require "<gem_name>/<file_name>".
How to prepare files for a new gem?
You can prepare the files for a new gem by running bundle gem <name>.
What is gem version?
The gem version itself is defined as a constant in lib/<gem_name>/version.rb.
What is a spec file?
A specification (“.spec”) file that comes with every gem describes dependencies (other required gems) so the code has everything it needs to work
What is the gem file called?
A list of gems required for a given (non-gem) project can be listed on a special file called “Gemfile” so they can be automatically installed by Bundler. Both covered later in this guide.