Windows 上特定目录中的 Bundler 命令出现错误:Ruby 3.3.0 中“untaint”方法出现 NoMethodError

问题描述 投票:0回答:1

我在尝试按照

GitHub 页面
上提供的说明安装 ltx2any 时遇到问题。我对Ruby不是很熟悉,我在Windows上使用Chocolatey安装了它。然后我使用
gem install bundler
命令安装了 Bundler。

当我在克隆的

bundler -v
目录以外的任何目录中运行
ltx2any
时,我会得到显示
Bundler version 2.5.5
的正确输出。但是,当我尝试在克隆的
ltx2any
目录中运行任何捆绑程序命令时,我收到以下错误消息:

C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:266:in `search_up': undefined method `untaint' for an instance of String (NoMethodError)

      current  = File.expand_path(SharedHelpers.pwd).untaint
                                                    ^^^^^^^^
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:253:in `find_file'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:245:in `find_gemfile'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:27:in `root'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler.rb:218:in `root'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler.rb:230:in `app_config_path'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler.rb:257:in `settings'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/env.rb:20:in `report'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:96:in `request_issue_report_for'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:46:in `log_error'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:126:in `rescue in with_friendly_errors'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/exe/bundle:22:in `<top (required)>'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/exe/bundler:4:in `load'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/exe/bundler:4:in `<top (required)>'
        from C:/tools/ruby33/bin/bundler:32:in `load'
        from C:/tools/ruby33/bin/bundler:32:in `<main>'
C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:266:in `search_up': undefined method `untaint' for an instance of String (NoMethodError)

      current  = File.expand_path(SharedHelpers.pwd).untaint
                                                    ^^^^^^^^
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:253:in `find_file'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:245:in `find_gemfile'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/shared_helpers.rb:27:in `root'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler.rb:218:in `root'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler.rb:230:in `app_config_path'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler.rb:257:in `settings'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/feature_flag.rb:21:in `block in settings_method'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/cli.rb:97:in `<class:CLI>'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/cli.rb:7:in `<module:Bundler>'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/cli.rb:6:in `<top (required)>'
        from <internal:C:/tools/ruby33/lib/ruby/site_ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from <internal:C:/tools/ruby33/lib/ruby/site_ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/exe/bundle:23:in `block in <top (required)>'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:122:in `with_friendly_errors'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/exe/bundle:22:in `<top (required)>'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/exe/bundler:4:in `load'
        from C:/Users/FooBar/.local/share/gem/ruby/3.3.0/gems/bundler-1.16.1/exe/bundler:4:in `<top (required)>'
        from C:/tools/ruby33/bin/bundler:32:in `load'
        from C:/tools/ruby33/bin/bundler:32:in `<main>'

这个错误似乎与

untaint
方法有关,据我所知,该方法已在 Ruby 3.2 及更高版本中删除。但是,我不确定为什么它尝试在
ltx2any
目录中使用 Bundler 1.16.1,尽管安装了 Bundler 2.5.5。

这是我迄今为止尝试过的事情:

  • 使用
    gem install bundler
  • 更新 Bundler
  • 但是,
    bundler update
    命令失败,并显示与上面相同的错误消息
  • gem update --system
    多次
  • 删除并重新克隆项目文件夹

我非常感谢有关如何解决此问题的任何见解或建议。具体来说,我想了解:

  • 为什么 Bundler 在特定目录中恢复到旧版本。
  • 如何确保在所有目录中使用 Bundler 2.5.5?
  • 修复此问题并成功安装 ltx2any 所需的任何步骤。
ruby windows rubygems bundler nomethoderror
1个回答
0
投票

较新版本的捆绑程序会记住用于创建

Gemfile.lock
的捆绑程序版本。然后,它将安装并使用这个确切的版本,以便通过这个 Gemfile.lock 进行所有未来的调用。

您可以参阅此功能的公告博客文章Bundler v2.3:锁定 Bundler 本身的版本,了解其工作原理的详细信息。

要将最新的捆绑程序版本与您的

Gemfile.lock
一起使用,您可能需要相应地运行
bundle update --bundler
。之后,您可以再次运行
bundle install
,使用更新的 Bundler 版本从
Gemfile
/
Gemfile.lock
安装 gem。

© www.soinside.com 2019 - 2024. All rights reserved.