【发布时间】:2021-11-06 18:58:12
【问题描述】:
我正在尝试通过以下方式创建新的ruby on rails 项目:
rails new . --no-ri --no-rdoc
但是在这个命令执行结束时我得到了:
run bundle install
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 4.2.6) was resolved to 4.2.6, which depends on
bundler (< 2.0, >= 1.3.0)
Current Bundler version:
bundler (2.2.27)
Your bundle requires a different version of Bundler than the one you're running.
Install the necessary version with `gem install bundler:2.0.0.pre.3` and rerun bundler using `bundle _2.0.0.pre.3_ install`
Fetching gem metadata from https://rubygems.org/.............
Resolving dependencies...
run bundle exec spring binstub --all
Traceback (most recent call last):
13: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
12: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
11: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/setup.rb:20:in `<top (required)>'
10: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/ui/shell.rb:88:in `silence'
9: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/ui/shell.rb:136:in `with_level'
8: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/setup.rb:20:in `block in <top (required)>'
7: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler.rb:149:in `setup'
6: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/runtime.rb:18:in `setup'
5: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/definition.rb:234:in `specs_for'
4: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/definition.rb:483:in `materialize'
3: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/definition.rb:262:in `resolve'
2: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/resolver.rb:23:in `resolve'
1: from /var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/resolver.rb:46:in `start'
/var/lib/gems/2.5.0/gems/bundler-2.2.27/lib/bundler/resolver.rb:59:in `rescue in start': Bundler could not find compatible versions for gem "bundler": (Bundler::VersionConflict)
In Gemfile:
rails (= 4.2.6) was resolved to 4.2.6, which depends on
bundler (< 2.0, >= 1.3.0)
Current Bundler version:
bundler (2.2.27)
Your bundle requires a different version of Bundler than the one you're running.
Install the necessary version with `gem install bundler:1.11.2` and rerun bundler using `spring _1.11.2_ binstub --all`
之后我删除了 ruby,所以使用命令 ruby -v 我得到了:
bash: /home/iva/.rbenv/shims/ruby: No such file or directory
然后我再次安装了 ruby 并使用 gem install bundler:1.11.2 安装了 gem。但是在安装了检查 ruby 和 gem 的版本之后,我得到了:
ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
gem -v
2.7.6
当我使用版本1.11.2 发出命令时,我不知道这个2.7.6 版本的gem 怎么样?
所以它似乎是一个圈子,我不知道如何摆脱它。我正在安装 ruby,它需要旧版本的 gem,但是任何命令都会在我的计算机上安装最新版本的 gem。在这种情况下我该怎么办?
================================================ =============== 此命令的响应是:
rbenv versions
* 2.5.1 (set by /home/iva/.rbenv/version)
echo $PATH
/home/iva/.rbenv/shims:/home/iva/.rbenv/bin:/home/iva/.rbenv/shims:/home/iva/.rbenv/bin:/home/iva/.rbenv/shims:/home/iva/.rbenv/bin:/home/iva/.rbenv/shims:/home/iva/.rbenv/bin:/home/iva/.rbenv/shims:/home/iva/.rbenv/bin:/home/iva/.rbenv/shims:/home/iva/.rbenv/bin:/home/iva/bin:/home/iva/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/iva/.rvm/bin:/home/iva/.rvm/bin:/home/iva/.rvm/bin:/home/iva/.rvm/bin:/home/iva/.rvm/bin
【问题讨论】:
-
你是如何重新安装 Ruby 的?你能发布
rbenv versions和echo $PATH的输出吗? -
我在我的问题中添加了对
rbenv versions和echo $PATH命令的响应。我正在使用stackoverflow.com/questions/37720892/… 那里的教程重新安装 ruby(第三次回答 39 次:(2019 年 1 月)要使用 Rbenv 脚本安装 Ruby,请按照以下步骤操作:)
标签: ruby-on-rails ruby rubygems