Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spec for use of :base in Dir#glob and tag it #2377

Merged
merged 1 commit into from
Jun 16, 2021

Conversation

wildmaples
Copy link
Contributor

Issue

We found this exception because it broke the TruffleRuby CI on SFR.

puts RUBY_DESCRIPTION
puts Dir.glob('**/*.rake', base: '.')
➜  storefront-renderer git:(master) ✗ ruby foo.rb
truffleruby 21.2.0-dev-d2532c21, like ruby 2.7.3, GraalVM CE JVM [x86_64-darwin]
<internal:core> core/dir_glob.rb:305:in `match?': undefined method `end_with?' for nil:NilClass (NoMethodError)
	from <internal:core> core/dir_glob.rb:286:in `process_entry'
	from <internal:core> core/dir_glob.rb:184:in `process_directory'
	from <internal:core> core/dir_glob.rb:413:in `run'
	from <internal:core> core/dir_glob.rb:466:in `glob'
	from <internal:core> core/dir.rb:250:in `block in glob'
	from <internal:core> core/dir.rb:247:in `each'
	from <internal:core> core/dir.rb:247:in `glob'
	from foo.rb:2:in `<main>'

TL;DR: If there are no path entries and the entry type is EndsWithEntryMatch, a nil class error will occur with the #end_with?(suffix) check.

I did some digging and it seems like there is no issue if Dir#glob is run without a base: Dir.glob('**/*.rake'). The code path diverges at this line when there is no glob_base_dir specified. In the problematic case, the @next is EndsWithEntryMatch, and when this Entry type is processed with no entry, there is a NilClass exception on #end_with?

Change

This change is just the test case that covers the issue. It passes on Ruby 2.7.3 and returns the exception (as seen above) on TrufleRuby.

Question

I don't have a lot of new context on the new Dir#glob changes, but this issue has something to do with the recent changes.

I have a branch here at gets rid of the exception but it does not pass the spec I added because the resulting array includes the file path of the mismatched directory.

Any idea to what the issue may be?

@eregon
Copy link
Member

eregon commented Jun 15, 2021

@aardvark179 has an upcoming fix for this, unfortunately it did not get merged yet due to some transient timeout:
master...eregon:gr-32025
We noticed the failure with https://github.com/eregon/truffleruby-gem-tracker, we should have told you about it since it would be likely you hit it too, sorry about that.

Thank you for the spec, more specs is always good :)

@eregon eregon added the in-ci The PR is being tested in CI. Do not push new commits. label Jun 15, 2021
graalvmbot pushed a commit that referenced this pull request Jun 16, 2021
@graalvmbot graalvmbot merged commit 2186b80 into oracle:master Jun 16, 2021
@chrisseaton chrisseaton deleted the dir-glob-test branch August 30, 2021 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-ci The PR is being tested in CI. Do not push new commits. oca-signed shopify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants