Skenvy/dependabot-linguist

`touch Gemfile` necessary step to let the `dependabot-linguist` bin work.

Closed this issue · 6 comments

Operating System

Linux

What version of dependabot-linguist did the issue happen on (either the tag, commit hash, or semver)?

0.212.0

What semver version of the Ruby runtime did the issue happen on?

ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]

What were you doing (steps to reproduce the bug)?

gem install dependabot-linguist
dependabot-linguist

What actually happened as a result?

It errored with Could not locate Gemfile (Bundler::GemfileNotFound) and then Could not locate Gemfile or .bundle/ directory (Bundler::GemfileNotFound)

What did you expect to happen?

It should be able to run without the presence of a Gemfile.

If you have a stack trace, please add it here.

Traceback (most recent call last):
24: from /usr/local/bin/dependabot-linguist:23:in <main>' 23: from /usr/local/bin/dependabot-linguist:23:in load'
22: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/exe/dependabot-linguist:145:in <top (required)>' 21: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/exe/dependabot-linguist:135:in dependabot_linguist'
20: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:208:in directories_per_ecosystem_validated_by_dependabot' 19: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:208:in each'
18: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:212:in block in directories_per_ecosystem_validated_by_dependabot' 17: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:212:in each'
16: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:215:in block (2 levels) in directories_per_ecosystem_validated_by_dependabot' 15: from /var/lib/gems/2.7.0/gems/dependabot-common-0.212.0/lib/dependabot/file_fetchers/base.rb:68:in files'
14: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:35:in fetch_files' 13: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:112:in path_gemspecs'
12: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:140:in path_gemspec_paths' 11: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:166:in fetch_path_gemspec_paths'
10: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:166:in new' 9: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/lockfile_parser.rb:71:in initialize'
8: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/lockfile_parser.rb:71:in each' 7: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/lockfile_parser.rb:86:in block in initialize'
6: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/lockfile_parser.rb:114:in parse_source' 5: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/source/path.rb:54:in from_lock'
4: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/source/path.rb:54:in new' 3: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/source/path.rb:23:in initialize'
2: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/source/path.rb:123:in root' 1: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler.rb:297:in root'
/var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/shared_helpers.rb:15:in root': Could not locate Gemfile (Bundler::GemfileNotFound) 24: from /usr/local/bin/dependabot-linguist:23:in

'
23: from /usr/local/bin/dependabot-linguist:23:in load' 22: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/exe/dependabot-linguist:145:in <top (required)>'
21: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/exe/dependabot-linguist:135:in dependabot_linguist' 20: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:208:in directories_per_ecosystem_validated_by_dependabot'
19: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:208:in each' 18: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:212:in block in directories_per_ecosystem_validated_by_dependabot'
17: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:212:in each' 16: from /var/lib/gems/2.7.0/gems/dependabot-linguist-0.212.0/lib/dependabot/linguist/repository.rb:215:in block (2 levels) in directories_per_ecosystem_validated_by_dependabot'
15: from /var/lib/gems/2.7.0/gems/dependabot-common-0.212.0/lib/dependabot/file_fetchers/base.rb:68:in files' 14: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:35:in fetch_files'
13: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:112:in path_gemspecs' 12: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:140:in path_gemspec_paths'
11: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:166:in fetch_path_gemspec_paths' 10: from /var/lib/gems/2.7.0/gems/dependabot-bundler-0.212.0/lib/dependabot/bundler/file_fetcher.rb:166:in new'
9: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/lockfile_parser.rb:71:in initialize' 8: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/lockfile_parser.rb:71:in each'
7: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/lockfile_parser.rb:86:in block in initialize' 6: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/lockfile_parser.rb:114:in parse_source'
5: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/source/path.rb:54:in from_lock' 4: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/source/path.rb:54:in new'
3: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/source/path.rb:23:in initialize' 2: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler/source/path.rb:123:in root'
1: from /var/lib/gems/2.7.0/gems/bundler-2.3.24/lib/bundler.rb:296:in `root'

Anything else you feel useful to add?

The problem could be remedied with a touch Gemfile (that did not need to be added or committed, just "present") in the location to run the cli from. Having the file present allowed it to run properly, but I'm not certain why the bundler file fetcher needs its files to be present, when none of the other ecosystems do.

This isn't present in every repository. It did crop up in a repository that happened to have a gemfile in a subdirectory. Subsequently running it on a gradle / maven repo did NOT require adding a gemfile. Running it on go, python, and actions repos all did also not require the gemfile to be added.

Notably, for other ecosystems, they all appear to be raising DependabotError errors, but the error surfaced here is Bundler::GemfileNotFound, raised from the bundler gem itself, that was not wrapped in a DependabotError by the bundler file fetcher class. Although the gemfile being added to the root of the repo quashed the error (and allowed it to update the existing bundler entry in the config at /ruby, the paths that it sought out to check for bundler where "bundler"=>["/ruby", "/ruby/bin", "/ruby/lib", "/ruby/lib/collatz", "/ruby/spec"] -- which doesn't include the repository root.

Having a Gemfile in the directory from where the command is run, regardless of if it's in the repo or not, fixes the issue.

Skenvy commented

Raised as tech-debt in dependabot/dependabot-core#7273 -- citing demonstration repo https://github.com/CloutKhan/dependabot-bundler

Skenvy commented

Raised as feature request in rubygems/rubygems#6671 -- citing demonstration repo https://github.com/CloutKhan/dependabot-bundler