简体   繁体   English

Rails:如何更改 Bundler 默认版本

[英]Rails: How to change Bundler default version

bundler (2.0.1, default: 1.17.2)捆绑器(2.0.1,默认值:1.17.2)

How could I change the default to 2.0.1我怎样才能将默认值更改为 2.0.1

Following https://bundler.io/guides/bundler_2_upgrade.html#upgrading-applications-from-bundler-1-to-bundler-2 , here's what worked for me:https://bundler.io/guides/bundler_2_upgrade.html#upgrading-applications-from-bundler-1-to-bundler-2之后,这对我有用:

gem install --default bundler
gem update --system
bundler update --bundler

What helped me is to delete the current default manually from the folder lib\ruby\gems\2.6.0\specifications\default\帮助我的是从文件夹lib\ruby\gems\2.6.0\specifications\default\中手动删除当前默认值
and then install fresh bundler as usually然后像往常一样安装新的捆绑器
gem install bundler
or as default或默认
gem install --default bundler

I had this same concern when trying to setup Bundler gem 2.2.11 as the default gem on my machine.在尝试将 Bundler gem 2.2.11 设置为我机器上的默认 gem 时,我也有同样的担忧。

Here's how I achieved it :这是我实现它的方法

First, I listed and uninstalled all other versions of the Bundler gem because I did not need them:首先,我列出并卸载了 Bundler gem 的所有其他版本,因为我不需要它们:

gem list bundler
gem uninstall bundler

If you encounter an error like this如果遇到这样的错误

Gem bundler-2.1.4 cannot be uninstalled because it is a default gem

Simply run the command below to get your ruby installation directory:只需运行以下命令即可获取您的 ruby​​ 安装目录:

gem environment | grep "INSTALLATION DIRECTORY"

This should display an output like this.这应该显示这样的输出。 In my case my ruby version was 2.7.2 :就我而言,我的 ruby​​ 版本是2.7.2

- INSTALLATION DIRECTORY: /home/mycomputer/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0

Next, navigate to the specifications/default directory of the INSTALLATION PATH :接下来,导航到INSTALLATION PATHspecifications/default目录:

cd /home/mycomputer/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/specifications/default

Remove/delete the bundler.gemspec file that you have there.移除/删除您在那里的bundler.gemspec文件。 In my case it was bundler-2.1.4.gemspec , so I ran the command:就我而言,它是bundler-2.1.4.gemspec ,所以我运行了命令:

rm bundler-2.1.4.gemspec

Next, I installed the Bundler gem 2.2.11 and made it the default gem:接下来,我安装了 Bundler gem 2.2.11 并将其设为默认 gem:

gem install --default bundler -v 2.2.11

Next, I listed my Bundler versions:接下来,我列出了我的 Bundler 版本:

gem list bundler

Finally, I updated my gems to use the newly installed Bundler:最后,我更新了我的 gem 以使用新安装的 Bundler:

gem update --system

That's all.就这样。

I hope this helps我希望这有帮助

You need to remove .spec file to remove the gem.您需要删除.spec文件才能删除 gem。

Steps:脚步:

  1. gem env – try to search in provided list under GEM PATHS , in specifications/default gem env – 尝试在GEM PATHS下提供的列表中搜索,在specifications/default
  2. remove there bundler-VERSION.gemspec删除那里bundler-VERSION.gemspec
  3. install bundler, if you don't have specific: gem install bundler:VERSION --default安装捆绑器,如果您没有特定的: gem install bundler:VERSION --default
gem install --default bundler:<version>
bundler config default 2.0.1

这应该做到这一点。

You need to know where the default specs are, so use gem environment to find out.您需要知道默认规格在哪里,因此请使用gem environment查找。

the steps I used were:我使用的步骤是:

gem environment
# note INSTALLATION DIRECTORY
cd <installation_dir>
cd specifications/default
rm bundler-2.1.4.gemspec
gem install --default bundler -v 2.2.11

Remove all default bundler versions.删除所有默认捆绑程序版本。 Commands:命令:

  1. $ gem environment $ 宝石环境
  2. $ cd INSTALLATION DIRECTORY $ cd 安装目录
  3. $ cd specifications $ cd 规格
  4. $ cd default $ cd 默认
  5. $ rm bundler version $ rm 捆绑器版本
  6. $ gem install bundler $ gem 安装捆绑器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM