Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何使用特定版本的bundler捆绑安装gemfile_Ruby On Rails_Ruby_Dependencies_Bundler - Fatal编程技术网

Ruby on rails 如何使用特定版本的bundler捆绑安装gemfile

Ruby on rails 如何使用特定版本的bundler捆绑安装gemfile,ruby-on-rails,ruby,dependencies,bundler,Ruby On Rails,Ruby,Dependencies,Bundler,我正在尝试捆绑安装一个运行gem'rails',4.2.0'的项目。 运行Bundle install,我得到: Bundler could not find compatible versions for gem "bundler": In Gemfile: rails (= 4.2.0) was resolved to 4.2.0, which depends on bundler (>= 1.3.0, < 2.0) Current Bundler

我正在尝试捆绑安装一个运行
gem'rails',4.2.0'
的项目。 运行
Bundle install
,我得到:

Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    rails (= 4.2.0) was resolved to 4.2.0, which depends on
      bundler (>= 1.3.0, < 2.0)

  Current Bundler version:
    bundler (2.1.4)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?

Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 'rails (= 4.2.0)', in any of the sources.
Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated
然后,当尝试像这样用v1.3.0捆绑安装
bundle\u1.3.0\uinstall
时,我发现
找不到命令“\u1.3.0”。

Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated
如何使用特定版本的bundler成功运行bundle安装?

您可以通过以下方式安装bundler 1.3版:

gem install bundler -v 1.3
Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated
然后使用该特定版本安装gems:

bundle _1.3.0_ [install]
Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated

希望有帮助

您可以尝试将其添加到您的文件中

Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated
gem'bundler',1.17.1'

Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated
然后尝试以下命令:

gem install bundler -v 1.3.0
gem uninstall bundler -v 2.1.4
bundle update --bundler
bundle install
Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated

如果您使用的是错误版本的ruby gems,那么bundler之前有一个bug。试一试

gem update --system
Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated
基本上,您需要:

Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
    Name: bundler
    Version: 2.1.4
    File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
    /home/lqt/.rbenv/versions/2.7.1/bin/gem
    /home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated
  • 捆绑程序(>=1.3.0,<2.0)安装在本地计算机上
  • 能够运行该捆绑程序版本
  • 运行该Bundler版本以安装应用程序所需的其他gems(bundle安装)
  • 首先,检查您是否已在本地计算机上成功安装Bundler(>=1.3.0,<2.0):

    $ gem list bundler 
    
    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    你应该看到:

    *** LOCAL GEMS ***
    bundler (2.1.4, 1.17.3, 1.3.0)
    
    Bundler version 1.17.3
    
    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    如果没有,请安装:

    $ gem install bundler -v "<2" -N
    # Install lasted bundler below version 2
    # -N: No document
    
    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    你应该看到:

    *** LOCAL GEMS ***
    bundler (2.1.4, 1.17.3, 1.3.0)
    
    Bundler version 1.17.3
    
    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    如果您安装了Bundler 1.17.3,但无法运行“bundle 1.17.3-v”,那么您的RubyGem gem可能有问题。检查是否安装了更新版本(最新版本为3.1.3):

    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    尝试更新RubyGem gem,因为它可以帮助您运行特定的gem版本:

    $ gem update --system
    
    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    你应该看到:

    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    再次检查是否可以运行特定的捆绑程序版本:

    $ bundle _1.17.3_ -v
    
    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    $ bundle _1.17.3_ -v
    
    如果你看到:

    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    Bundler version 1.17.3
    
    然后,在步骤3中,只需运行Bundler 1.17.3即可安装其他GEM:

    Updating rubygems-update
    ...
    Installing RubyGems 3.1.3
    Successfully built RubyGem
        Name: bundler
        Version: 2.1.4
        File: bundler-2.1.4.gem
    Bundler 2.1.4 installed
    RubyGems 3.1.3 installed
    Regenerating binstubs
    ...
    ------------------------------------------------------------------------------
    RubyGems installed the following executables:
        /home/lqt/.rbenv/versions/2.7.1/bin/gem
        /home/lqt/.rbenv/versions/2.7.1/bin/bundle
    ...
    RubyGems system software updated
    
    $ bundle _1.17.3_ install
    

    请再次尝试运行
    捆绑包安装
    。不,这不起作用,因为它与我最新版本的捆绑包一起运行。是否使用rvm?如果是这样,请确保选择安装了1.3.0版本的正确gemset。不,我使用rbenv…您是否考虑过为该项目使用单独的环境,例如Docker?正如我在帖子中解释的,不幸的是,这不起作用,spits找不到命令“1.3.0”