Error with Bundler Commands in Specific Directory on Windows: NoMethodError for 'untaint' Method in Ruby 3.3.0

132 views Asked by At

I've encountered an issue while trying to install ltx2any by following the instructions provided on its GitHub page. I am not very familiar with Ruby, and I installed it using Chocolatey on Windows. I then installed Bundler using the gem install bundler command.

When I run bundler -v in any directory other than the cloned ltx2any directory, I get the correct output showing Bundler version 2.5.5. However, when I try to run any bundler command in the cloned ltx2any directory, I receive the following error message:

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>'

This error seems to be related to the untaint method, which I understand has been removed in Ruby 3.2 and later. However, I'm not sure why it's attempting to use Bundler 1.16.1 in the ltx2any directory despite having Bundler 2.5.5 installed.

Here are the things I have tried so far:

  • updating Bundler using gem install bundler
  • the bundler update command, however, fails with the same error message as above
  • ran gem update --system multiple times
  • deleted and recloned the project folder

I'd greatly appreciate any insights or suggestions on how to resolve this issue. Specifically, I'm looking to understand:

  • Why Bundler reverts to an older version in the specific directory.
  • How do you ensure that Bundler 2.5.5 is used across all directories?
  • Any steps required to fix this issue and successfully install ltx2any.

P.S. I posted a follow-up question here.

1

There are 1 answers

3
Holger Just On

Newer versions of bundler remember the bundler version that was used to create the Gemfile.lock. It will then install and use this exact version for all future invocations with this Gemfile.lock.

You can refer to the announcement blog post for this feature at Bundler v2.3: Locking the version of Bundler itself for details how this works.

To use the latest bundler version with your Gemfile.lock, you likely want to run bundle update --bundler accordingly. Afterwards, you can run bundle install again to install the gems from your Gemfile / Gemfile.lock using the update Bundler version.