fierce-keyboard-91032
12/12/2022, 7:52 AM--changed-since
for ./pants
to read changes at the root directory? (This was possible before with the --changed-parent
option, but it has been deprecated: https://www.pantsbuild.org/v2.0/docs/reference-changed#deprecated-options)
I am using ./pants 2.14.0
on a monorepo with multiple programming languages. pants is installed in the py/mono
directory. It seems that if the root directory contain some changes, then running ./pants --changed-since=master package
throws an error similar to this:
Exception caught: (builtins.ValueError)
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/bin/pants", line 8, in <module>
sys.exit(main())
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/bin/pants_loader.py", line 115, in main
PantsLoader.main()
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/bin/pants_loader.py", line 111, in main
cls.run_default_entrypoint()
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/bin/pants_loader.py", line 93, in run_default_entrypoint
exit_code = runner.run(start_time)
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/bin/pants_runner.py", line 99, in run
runner = LocalPantsRunner.create(
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 159, in create
specs = calculate_specs(
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/init/specs_calculator.py", line 90, in calculate_specs
changed_files = tuple(changed_options.changed_files(maybe_git_worktree.git_worktree))
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/vcs/changed.py", line 125, in changed_files
git_worktree.changed_files(
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/vcs/git.py", line 107, in changed_files
return {self._fix_git_relative_path(f, relative_to) for f in files}
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/vcs/git.py", line 107, in <setcomp>
return {self._fix_git_relative_path(f, relative_to) for f in files}
File "/home/circleci/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/vcs/git.py", line 70, in _fix_git_relative_path
return str((self.worktree / worktree_path).relative_to(relative_to))
File "/home/circleci/.pyenv/versions/3.9.15/lib/python3.9/pathlib.py", line 939, in relative_to
raise ValueError("{!r} is not in the subpath of {!r}"
Exception message: '/home/circleci/br-monorepo/dev.tmpl' is not in the subpath of '/home/circleci/br-monorepo/py/mono' OR one path is relative and the other is absolute.
NoneType: None
Looking at the pants source code, it seems ./pants
will use the git API to obtain all the changed files, and then compute the path relative to the build root:
git_worktree.changed_files(
from_commit=changes_since, include_untracked=True, relative_to=get_buildroot()
),
For example, if my build root is py/mono and a file is found at py/mono/a/b/c, then it will return a/b/c
So it seems that it will throw an error if the changed file is outside the pants directory. Is it possible to prevent this behavior, i.e., just ignore those files?