Skip to content

Specify project path in license finder

What does this MR do?

Add opt to specify the project path when executing license_finder. Otherwise, it will use the wrong Gemfile when we use a customized Gemfile.

Recently in JiHu, the Omnibus builds of gitlab-rails fail at license check. The reason is that gitlab-license_finder loads the Gemfile under project root rather than the jh directory.

See error logs below:

Logs
The following shell command exited with status 1:
    $ CFLAGS=-I/opt/gitlab/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector CPPFLAGS=-I/opt/gitlab/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector CXXFLAGS=-I/opt/gitlab/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector LDFLAGS=-Wl,-rpath,/opt/gitlab/embedded/lib -L/opt/gitlab/embedded/lib LD_RUN_PATH=/opt/gitlab/embedded/lib OMNIBUS_INSTALL_DIR=/opt/gitlab PATH=/opt/gitlab/bin:/opt/gitlab/embedded/bin:/builds/gitlab/omnibus-gitlab/gems/ruby/2.7.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PKG_CONFIG_PATH=/opt/gitlab/embedded/lib/pkgconfig /opt/gitlab/embedded/bin/bundle exec license_finder report --decisions-file=config/dependency_decisions.yml --format=json --columns name version licenses texts notice --save=rails-license.json
Output:
    LicenseFinder::Bundler: is active
LicenseFinder::NPM: is active
LicenseFinder::Yarn: is active
LicenseFinder::Pipenv: is active
Error:
    Warning: the running version of Bundler (2.2.33) is older than the version that created the lockfile (2.3.6). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.3.6`.
bundler: failed to load command: license_finder (/opt/gitlab/embedded/bin/license_finder)
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/source/path.rb:209:in `load_spec_files': The path `/var/cache/omnibus/src/gitlab-rails/jh/vendor/gems/mail-smtp_pool` does not exist. (Bundler::PathError)
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/source/path.rb:107:in `local_specs'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/source/path.rb:115:in `specs'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/definition.rb:700:in `block in converge_specs'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/spec_set.rb:136:in `each'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/spec_set.rb:136:in `each'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/definition.rb:682:in `converge_specs'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/definition.rb:662:in `converge_locked_specs'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/definition.rb:253:in `resolve'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/definition.rb:467:in `materialize'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/definition.rb:235:in `specs_for'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/package_managers/bundler.rb:66:in `gem_details'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/package_managers/bundler.rb:51:in `details'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/package_managers/bundler.rb:16:in `current_packages'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/package_manager.rb:105:in `current_packages_with_relations'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/scanner.rb:42:in `each'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/scanner.rb:42:in `flat_map'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/scanner.rb:42:in `active_packages'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/core.rb:83:in `current_packages'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/core.rb:78:in `decision_applier'
	from /opt/gitlab/embedded/lib/ruby/2.7.0/forwardable.rb:229:in `acknowledged'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/license_aggregator.rb:51:in `block in aggregate_packages'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/license_aggregator.rb:49:in `each'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/license_aggregator.rb:49:in `flat_map'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/license_aggregator.rb:49:in `aggregate_packages'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/license_aggregator.rb:11:in `dependencies'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/lib/license_finder/cli/main.rb:153:in `report'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/gitlab-license_finder-6.14.2.1/bin/license_finder:6:in `<top (required)>'
	from /opt/gitlab/embedded/bin/license_finder:23:in `load'
	from /opt/gitlab/embedded/bin/license_finder:23:in `<top (required)>'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `load'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:23:in `run'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/cli.rb:479:in `exec'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/cli.rb:31:in `dispatch'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/cli.rb:25:in `start'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/exe/bundle:49:in `block in <top (required)>'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
	from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.33/exe/bundle:37:in `<top (required)>'
	from /opt/gitlab/embedded/bin/bundle:23:in `load'
	from /opt/gitlab/embedded/bin/bundle:23:in `<main>'

Related issues

The issue in JH: https://jihulab.com/gitlab-cn/omnibus-gitlab/-/issues/132

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion

Required

  • Merge Request Title, and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com
  • Pipeline is green on dev.gitlab.org if the change is touching anything besides documentation or internal cookbooks
  • trigger-package has a green pipeline running against latest commit

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Tests added
  • Integration tests added to GitLab QA
  • Equivalent MR/issue for the GitLab Chart opened
Edited by vincent stchu

Merge request reports