Package: libruby2.7 Version: 2.7.1-3 Severity: important X-Debbugs-Cc: ant...@friki.cat
Dear Maintainer, Some ruby scripts fail to run from a removed directory. % cat /tmp/test.rb #!/usr/bin/ruby require 'unicode' % mkdir /tmp/foo % cd /tmp/foo % rmdir /tmp/foo % /tmp/test.rb Traceback (most recent call last): 5: from /tmp/test.rb:2:in `<main>' 4: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require' 3: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require' 2: from /usr/lib/ruby/vendor_ruby/unicode.rb:2:in `<top (required)>' 1: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require' /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- unicode/2.7/unicode_native (LoadError) 16: from /tmp/test.rb:2:in `<main>' 15: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require' 14: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require' 13: from /usr/lib/ruby/vendor_ruby/unicode.rb:2:in `<top (required)>' 12: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require' 11: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require' 10: from /usr/lib/ruby/2.7.0/rubygems.rb:204:in `try_activate' 9: from /usr/lib/ruby/2.7.0/rubygems/specification.rb:996:in `find_by_path' 8: from /usr/lib/ruby/2.7.0/rubygems/specification.rb:996:in `find' 7: from /usr/lib/ruby/2.7.0/rubygems/specification.rb:996:in `each' 6: from /usr/lib/ruby/2.7.0/rubygems/specification.rb:997:in `block in find_by_path' 5: from /usr/lib/ruby/2.7.0/rubygems/bundler_version_finder.rb:39:in `compatible?' 4: from /usr/lib/ruby/2.7.0/rubygems/bundler_version_finder.rb:7:in `bundler_version' 3: from /usr/lib/ruby/2.7.0/rubygems/bundler_version_finder.rb:22:in `bundler_version_with_reason' 2: from /usr/lib/ruby/2.7.0/rubygems/bundler_version_finder.rb:73:in `lockfile_version' 1: from /usr/lib/ruby/2.7.0/rubygems/bundler_version_finder.rb:85:in `lockfile_contents' /usr/lib/ruby/2.7.0/rubygems/bundler_version_finder.rb:85:in `pwd': No such file or directory - getcwd (Errno::ENOENT) If apt-listchanges package is installed apt crashes that way. That's why I've switched to "important". Following inline patch fixes the issue. ---- From: Antoni Villalonga <ant...@friki.cat> Date: Fri, 28 Aug 2020 02:09:42 +0200 Subject: Rescue getcwd ENOENT error Forwarded: not-needed Upstream-Author: David RodrÃguez Rescue ENOENT error allowing run ruby scripts when cwd does not exists. Cherry-pick from upstream 96064e6f1ce100a37680dc8f9509f06b3350e9c8 --- a/lib/rubygems/bundler_version_finder.rb +++ b/lib/rubygems/bundler_version_finder.rb @@ -82,12 +82,19 @@ def self.lockfile_contents gemfile = ENV["BUNDLE_GEMFILE"] gemfile = nil if gemfile && gemfile.empty? - Gem::Util.traverse_parents Dir.pwd do |directory| - next unless gemfile = Gem::GEM_DEP_FILES.find { |f| File.file?(f.tap(&Gem::UNTAINT)) } - gemfile = File.join directory, gemfile - break - end unless gemfile + unless gemfile + begin + Gem::Util.traverse_parents(Dir.pwd) do |directory| + next unless gemfile = Gem::GEM_DEP_FILES.find { |f| File.file?(f.tap(&Gem::UNTAINT)) } + + gemfile = File.join directory, gemfile + break + end + rescue Errno::ENOENT + return + end + end return unless gemfile ---- Regards,