dependabot-script icon indicating copy to clipboard operation
dependabot-script copied to clipboard

Parser error

Open DeTodd opened this issue 3 years ago • 4 comments

I'm having issues setting up dependabot with my Azure DevOps hosted pipeline, this is the first time I've tried to use it. I believe I have the credentials configured correctly, but I'm not familiar with ruby and gems so I'm not sure how to diagnose this. #526 has a similar error message but I'm not using npm so it may be different. I followed the guide here, it seems like their setup at least gets dependabot to run even though it fails shortly after starting.

Script

#!/bin/bash
PROJECT_PATH="$SYSTEM_TEAMPROJECT/_git/$BUILD_REPOSITORY_NAME"
echo "org: $SYSTEM_COLLECTIONURI"
echo "project: $SYSTEM_TEAMPROJECT"
echo "repo: $BUILD_REPOSITORY_NAME"
echo "path: $PROJECT_PATH"
      
FILECOUNT="$(find . -name *.csproj | wc -l)"
echo "Found $FILECOUNT dependency file(s)."
      
find . -name *.csproj | while read path; do
PARENTNAME="$(basename "$(dirname "$path")")"
DIRECTORY_PATH="/"$PARENTNAME
echo "directory: $DIRECTORY_PATH"
echo "project: $PROJECT_PATH"
echo "---[ Starting dependabot run: $path ]---"
echo `docker run  -v "$(pwd)/dependabot-script:/home/dependabot/dependabot-script" -w '/home/dependabot/dependabot-script' -e AZURE_ACCESS_TOKEN='<PAT>' -e PACKAGE_MANAGER='nuget' -e PROJECT_PATH='$PROJECT_PATH' -e DIRECTORY_PATH='$DIRECTORY_PATH' -e AZURE_HOSTNAME='[myorg]' -e GITHUB_ACCESS_TOKEN='[mytoken]' dependabot/dependabot-core bundle exec ruby ./generic-update-script.rb`
echo "---[ Finished dependabot run ]---"
done

Resulting Error

org: [myorg]
project: [myproj]
repo: [myrepo]
path: [constructed path]
/usr/lib/ruby/gems/2.7.0/gems/bundler-1.17.3/lib/bundler/rubygems_integration.rb:200: warning: constant Gem::ConfigMap is deprecated
/usr/lib/ruby/gems/2.7.0/gems/bundler-1.17.3/lib/bundler/rubygems_integration.rb:200: warning: constant Gem::ConfigMap is deprecated
warning: parser/current is loading parser/ruby27, which recognizes
warning: 2.7.3-compliant syntax, but you are running 2.7.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
/usr/lib/ruby/2.7.0/json/common.rb:156:in `parse': 783: unexpected token at '' (JSON::ParserError)
	from /usr/lib/ruby/2.7.0/json/common.rb:156:in `parse'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-common-0.142.0/lib/dependabot/clients/azure.rb:61:in `fetch_default_branch'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-common-0.142.0/lib/dependabot/file_fetchers/base.rb:442:in `default_branch_for_repo'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-common-0.142.0/lib/dependabot/file_fetchers/base.rb:70:in `commit'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-common-0.142.0/lib/dependabot/file_fetchers/base.rb:359:in `_full_specification_for'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-common-0.142.0/lib/dependabot/file_fetchers/base.rb:174:in `_fetch_repo_contents'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-common-0.142.0/lib/dependabot/file_fetchers/base.rb:159:in `repo_contents'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-nuget-0.142.0/lib/dependabot/nuget/file_fetcher.rb:184:in `csproj_file'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-nuget-0.142.0/lib/dependabot/nuget/file_fetcher.rb:55:in `project_files'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-nuget-0.142.0/lib/dependabot/nuget/file_fetcher.rb:28:in `fetch_files'
	from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-common-0.142.0/lib/dependabot/file_fetchers/base.rb:64:in `files'
	from ./generic-update-script.rb:154:in `<main>'
Fetching nuget dependency files for $PROJECT_PATH
---[ Finished dependabot run ]---

It does this on every individual project, same error every time. Note that $PROJECT_PATH did not resolve at the end even though it did at the top where [myproj] is.

I read through the warning and attempted to change my pipeline's ruby version but it still complains, as I said I'm painfully new to ruby so I'm probably just changing the version in the wrong place or something. Not sure if that's the problem or not.

Any help on further diagnosis or solutions would be appreciated, I have a decent knowledge of Docker and DevOps pipelines so I should be able to provide some more information if need be.

DeTodd avatar Jun 18 '21 19:06 DeTodd

I have the exact same issue ... and the same preconditions, so I'm no help to you @DeTodd

do-nat avatar Jun 24 '21 13:06 do-nat

You need to fill in the PAT token with R/W access to the git repository. AZURE_ACCESS_TOKEN='<PAT>'

baptistepattyn avatar Sep 20 '21 05:09 baptistepattyn

Any news on this?

ahmed-babic avatar Mar 25 '22 08:03 ahmed-babic

@ahmed-babic I haven't spent any more time on this since posting, sorry. I never found a solution to the problem dependabot solves either, at the end of the day it was decided that it's more of a headache to automate the task than it is to do it manually.

I just noticed I never responded to the previous comment. If anyone is wondering I did use my PAT, I just scrubbed it to post here.

DeTodd avatar Mar 25 '22 16:03 DeTodd