Hi there. It seems as though Pants isn't utilising...
# general
b
Hi there. It seems as though Pants isn't utilising my
~/.gitconfig
. I have a rule to add my repo as a safe directory (
git config --global --add safe.directory '/my/git/repo'
), but when I run Pants (
./pants --changed-since 1.2.3
) I'm receiving this error:
Copy code
[INFO] No git repository at /my/git/repo: GitBinaryException("fatal: detected dubious ownership in repository at '/my/git/repo'\nTo add an exception for this directory, call:\n\n\tgit config --global --add safe.directory /my/git/repo\n")
Does Pants use some other Git config?
e
Can you provide the full command line with full output? The
~
implies
HOME
and Pants runs processes in hermetic sandboxes with env vars scrubbed; so, depending where that message is being emitted from, that could be a cause.
b
Copy code
bash-4.2# whoami
root
bash-4.2# ./pants --print-stacktrace -ldebug --changed-since=$PREVIOUS_TAG package
12:18:23.31 [DEBUG] acquiring lock: <pants.pantsd.lock.OwnerPrintingInterProcessFileLock object at 0x7fc0fb817e20>
12:18:23.31 [DEBUG] terminating pantsd
12:18:23.31 [DEBUG] sending signal 15 to pid 882
12:18:23.61 [DEBUG] successfully terminated pid 882
12:18:23.61 [DEBUG] purging metadata directory: /codebuild/output/srcDownload/src/.pids/ea48444d5cc6/pantsd
12:18:23.61 [DEBUG] Launching pantsd
12:18:23.61 [DEBUG] purging metadata directory: /codebuild/output/srcDownload/src/.pids/ea48444d5cc6/pantsd
12:18:23.62 [DEBUG] pantsd command is: PANTS_DAEMON_ENTRYPOINT=pants.pantsd.pants_daemon:launch_new_pantsd_instance PYTHONPATH=/root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.qvoR5o/install/bin:/root/.pyenv/versions/3.9.16/lib/python39.zip:/root/.pyenv/versions/3.9.16/lib/python3.9:/root/.pyenv/versions/3.9.16/lib/python3.9/lib-dynload:/root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39/lib/python3.9/site-packages /root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39/bin/python /root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39/bin/pants --pants-bin-name=./pants --pants-version=2.14.1 --print-stacktrace -ldebug --changed-since=./codebuild/helpers/get_previous_tag.sh package
12:18:25.72 [DEBUG] pantsd is running at pid 2679, pailgun port is 37293
12:18:25.72 [DEBUG] releasing lock: <pants.pantsd.lock.OwnerPrintingInterProcessFileLock object at 0x7fc0fb817e20>
12:18:25.72 [DEBUG] Connecting to pantsd on port 37293
12:18:25.72 [DEBUG] Connecting to pantsd on port 37293 attempt 1/3
12:18:25.72 [DEBUG] Connected to pantsd
12:18:25.75 [DEBUG] Launching 1 roots (poll=false).
12:18:25.79 [DEBUG] computed 1 nodes in 0.034156 seconds. there are 7 total nodes.
12:18:26.01 [INFO] Initializing scheduler...
12:18:26.03 [DEBUG] File handle limit is: 1048576
12:18:26.05 [DEBUG] Using [cache::CommandRunner { inner: bounded::CommandRunner { inner: nailgun::CommandRunner { inner: local::CommandRunner { .. }, .. }, .. }, .. }, cache::CommandRunner { inner: bounded::CommandRunner { inner: nailgun::CommandRunner { inner: local::CommandRunner { .. }, .. }, .. }, .. }] for process execution.
12:18:26.19 [DEBUG] Changes to /root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.qvoR5o/install/bin, outside of the buildroot, will not be invalidated.
12:18:26.19 [DEBUG] Changes to /root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.qvoR5o/install/bin, outside of the buildroot, will not be invalidated.
12:18:26.19 [DEBUG] Changes to /root/.pyenv/versions/3.9.16/lib/python39.zip, outside of the buildroot, will not be invalidated.
12:18:26.19 [DEBUG] Changes to /root/.pyenv/versions/3.9.16/lib/python3.9, outside of the buildroot, will not be invalidated.
12:18:26.19 [DEBUG] Changes to /root/.pyenv/versions/3.9.16/lib/python3.9/lib-dynload, outside of the buildroot, will not be invalidated.
12:18:26.19 [DEBUG] Changes to /root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39/lib/python3.9/site-packages, outside of the buildroot, will not be invalidated.
12:18:26.19 [DEBUG] setting up service <pants.pantsd.service.scheduler_service.SchedulerService object at 0x7f71c2ce5e80>
12:18:26.19 [DEBUG] setting up service <pants.pantsd.service.store_gc_service.StoreGCService object at 0x7f71c3255370>
12:18:26.19 [DEBUG] starting service <pants.pantsd.service.scheduler_service.SchedulerService object at 0x7f71c2ce5e80>
12:18:26.19 [DEBUG] starting service <pants.pantsd.service.store_gc_service.StoreGCService object at 0x7f71c3255370>
12:18:26.20 [INFO] Scheduler initialized.
12:18:26.20 [DEBUG] Launching 1 roots (poll=false).
12:18:26.20 [DEBUG] computed 1 nodes in 0.000349 seconds. there are 7 total nodes.
12:18:26.26 [DEBUG] specs are: Specs(includes=RawSpecs(description_of_origin='CLI arguments', address_literals=(), file_literals=(), file_globs=(), dir_literals=(), dir_globs=(), recursive_globs=(), ancestor_globs=(), unmatched_glob_behavior=<GlobMatchErrorBehavior.error: 'error'>, filter_by_global_options=True, from_change_detection=False), ignores=RawSpecs(description_of_origin='CLI arguments', address_literals=(), file_literals=(), file_globs=(), dir_literals=(), dir_globs=(), recursive_globs=(), ancestor_globs=(), unmatched_glob_behavior=<GlobMatchErrorBehavior.error: 'error'>, filter_by_global_options=False, from_change_detection=False))
12:18:26.26 [DEBUG] changed_options are: ChangedOptions(since='./codebuild/helpers/get_previous_tag.sh', diffspec=None, dependees=<DependeesOption.NONE: 'none'>)
12:18:26.26 [DEBUG] Launching 1 roots (poll=false).
12:18:26.26 [DEBUG] Completed: acquire_command_runner_slot
12:18:26.26 [DEBUG] Running Searching for `bash` on PATH=/usr/bin:/bin:/usr/local/bin under semaphore with concurrency id: 1, and concurrency: 1
12:18:26.26 [DEBUG] Completed: setup_sandbox
12:18:26.26 [DEBUG] Obtaining exclusive spawn lock for process since we materialized its executable Some("./find_binary.sh").
12:18:26.27 [DEBUG] spawned local process as Some(2706) for Process { argv: ["./find_binary.sh", "bash"], env: {"PATH": "/usr/bin:/bin:/usr/local/bin"}, working_directory: None, input_digests: InputDigests { complete: DirectoryDigest { digest: Digest { hash: Fingerprint<fc33a6ab65993fa57d52edbff44d8a8a89faa2ec0669950d238b481da5caf15c>, size_bytes: 91 }, tree: "Some(..)" }, nailgun: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, input_files: DirectoryDigest { digest: Digest { hash: Fingerprint<fc33a6ab65993fa57d52edbff44d8a8a89faa2ec0669950d238b481da5caf15c>, size_bytes: 91 }, tree: "Some(..)" }, immutable_inputs: {}, use_nailgun: {} }, output_files: {}, output_directories: {}, timeout: None, execution_slot_variable: None, concurrency_available: 0, description: "Searching for `bash` on PATH=/usr/bin:/bin:/usr/local/bin", level: Debug, append_only_caches: {}, jdk_home: None, platform_constraint: None, cache_scope: PerRestartSuccessful, remote_cache_speculation_delay: 0ns }
12:18:26.27 [DEBUG] Completed: Searching for `bash` on PATH=/usr/bin:/bin:/usr/local/bin
12:18:26.27 [DEBUG] Completed: Scheduling: Searching for `bash` on PATH=/usr/bin:/bin:/usr/local/bin
12:18:26.27 [DEBUG] Completed: acquire_command_runner_slot
12:18:26.27 [DEBUG] Completed: acquire_command_runner_slot
12:18:26.27 [DEBUG] Running Test binary /usr/bin/bash. under semaphore with concurrency id: 2, and concurrency: 1
12:18:26.27 [DEBUG] Running Test binary /bin/bash. under semaphore with concurrency id: 3, and concurrency: 1
12:18:26.28 [DEBUG] Completed: setup_sandbox
12:18:26.28 [DEBUG] Completed: setup_sandbox
12:18:26.28 [DEBUG] spawned local process as Some(2707) for Process { argv: ["/usr/bin/bash", "--version"], env: {}, working_directory: None, input_digests: InputDigests { complete: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, nailgun: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, input_files: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, immutable_inputs: {}, use_nailgun: {} }, output_files: {}, output_directories: {}, timeout: None, execution_slot_variable: None, concurrency_available: 0, description: "Test binary /usr/bin/bash.", level: Debug, append_only_caches: {}, jdk_home: None, platform_constraint: None, cache_scope: PerRestartAlways, remote_cache_speculation_delay: 0ns }
12:18:26.29 [DEBUG] spawned local process as Some(2708) for Process { argv: ["/bin/bash", "--version"], env: {}, working_directory: None, input_digests: InputDigests { complete: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, nailgun: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, input_files: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, immutable_inputs: {}, use_nailgun: {} }, output_files: {}, output_directories: {}, timeout: None, execution_slot_variable: None, concurrency_available: 0, description: "Test binary /bin/bash.", level: Debug, append_only_caches: {}, jdk_home: None, platform_constraint: None, cache_scope: PerRestartAlways, remote_cache_speculation_delay: 0ns }
12:18:26.29 [DEBUG] Completed: Test binary /usr/bin/bash.
12:18:26.29 [DEBUG] Completed: Scheduling: Test binary /usr/bin/bash.
12:18:26.29 [DEBUG] Completed: Test binary /bin/bash.
12:18:26.29 [DEBUG] Completed: Scheduling: Test binary /bin/bash.
12:18:26.29 [DEBUG] Completed: Finding the `bash` binary
12:18:26.29 [DEBUG] Completed: acquire_command_runner_slot
12:18:26.29 [DEBUG] Running Searching for `git` on PATH=/usr/bin:/bin:/usr/local/bin under semaphore with concurrency id: 4, and concurrency: 1
12:18:26.29 [DEBUG] Completed: setup_sandbox
12:18:26.29 [DEBUG] Obtaining exclusive spawn lock for process since we materialized its executable Some("./find_binary.sh").
12:18:26.30 [DEBUG] spawned local process as Some(2709) for Process { argv: ["./find_binary.sh", "git"], env: {"PATH": "/usr/bin:/bin:/usr/local/bin"}, working_directory: None, input_digests: InputDigests { complete: DirectoryDigest { digest: Digest { hash: Fingerprint<74daa8164942a954dfa7b0e771e4a38e58b3dd98c3f2daffa9d54fcd98b6626a>, size_bytes: 91 }, tree: "Some(..)" }, nailgun: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, input_files: DirectoryDigest { digest: Digest { hash: Fingerprint<74daa8164942a954dfa7b0e771e4a38e58b3dd98c3f2daffa9d54fcd98b6626a>, size_bytes: 91 }, tree: "Some(..)" }, immutable_inputs: {}, use_nailgun: {} }, output_files: {}, output_directories: {}, timeout: None, execution_slot_variable: None, concurrency_available: 0, description: "Searching for `git` on PATH=/usr/bin:/bin:/usr/local/bin", level: Debug, append_only_caches: {}, jdk_home: None, platform_constraint: None, cache_scope: PerRestartSuccessful, remote_cache_speculation_delay: 0ns }
12:18:26.30 [DEBUG] Completed: Searching for `git` on PATH=/usr/bin:/bin:/usr/local/bin
12:18:26.30 [DEBUG] Completed: Scheduling: Searching for `git` on PATH=/usr/bin:/bin:/usr/local/bin
12:18:26.30 [DEBUG] Completed: Finding the `git` binary
12:18:26.30 [DEBUG] computed 1 nodes in 0.038032 seconds. there are 24 total nodes.
12:18:26.30 [DEBUG] Launching 1 roots (poll=false).
12:18:26.30 [DEBUG] Completed: Finding the `git` binary
12:18:26.30 [DEBUG] Executing: /usr/bin/git rev-parse --show-toplevel
Copy code
12:18:26.31 [INFO] No git repository at /codebuild/output/srcDownload/src: GitBinaryException("fatal: detected dubious ownership in repository at '/codebuild/output/srcDownload/src'\nTo add an exception for this directory, call:\n\n\tgit config --global --add safe.directory /codebuild/output/srcDownload/src\n")
12:18:26.31 [DEBUG] computed 1 nodes in 0.011003 seconds. there are 27 total nodes.
12:18:26.31 [ERROR] The `--changed-*` options are only available if Git is used for the repository.
Traceback (most recent call last):
  File "/root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39/lib/python3.9/site-packages/pants/bin/daemon_pants_runner.py", line 131, in single_daemonized_run
    runner = LocalPantsRunner.create(
  File "/root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 158, in create
    specs = calculate_specs(
  File "/root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39/lib/python3.9/site-packages/pants/init/specs_calculator.py", line 64, in calculate_specs
    raise InvalidSpecConstraint(
pants.init.specs_calculator.InvalidSpecConstraint: The `--changed-*` options are only available if Git is used for the repository.
I would normally not run Pants as root, but my build environment (AWS Codebuild) makes it really painful to use a non-root user.
The
/codebuild/output/srcDownload/src
directory is owner by
codebuild-user
, hence the
detected dubious ownership in repository
Git error.
h
And whose homedir is the relevant
~/.gitconfig
in?
b
In root at
/root
h
And does this work outside of Pants? e.g., if you SSH into that machine (if that is even possible) or create a similar setup some other way?
Do raw git commands work in such a case?
b
Yes they do, this is running in Docker. Please see:
Copy code
bash-4.2# whoami
root

bash-4.2# git status
fatal: detected dubious ownership in repository at '/codebuild/output/srcDownload/src'
To add an exception for this directory, call:

	git config --global --add safe.directory /codebuild/output/srcDownload/src

bash-4.2# git config --global --add safe.directory /codebuild/output/srcDownload/src

bash-4.2# git status
On branch feature/introduce_pants
Your branch is up to date with 'origin/feature/introduce_pants'.
...

bash-4.2# ./pants --changed-since=1.2.3 package
Bootstrapping Pants using /root/.pyenv/shims/python3.9
Creating the virtualenv PEX.
Downloading the Pex PEX.
SHA256 fingerprint of <https://github.com/pantsbuild/pex/releases/download/v2.1.103/pex> verified.
Installing pantsbuild.pants==2.14.1 into a virtual environment at /root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39
New virtual environment successfully created at /root/.cache/pants/setup/bootstrap-Linux-x86_64/2.14.1_py39.
12:30:54.93 [INFO] Initializing scheduler...
12:30:55.12 [INFO] Scheduler initialized.
12:30:55.22 [INFO] No git repository at /codebuild/output/srcDownload/src: GitBinaryException("fatal: detected dubious ownership in repository at '/codebuild/output/srcDownload/src'\nTo add an exception for this directory, call:\n\n\tgit config --global --add safe.directory /codebuild/output/srcDownload/src\n")
12:30:55.22 [ERROR] The `--changed-*` options are only available if Git is used for the repository.


Use --print-stacktrace for more error details and/or -ldebug for more logs. 
See <https://www.pantsbuild.org/v2.14/docs/troubleshooting> for common issues.
Consider reaching out for help: <https://www.pantsbuild.org/v2.14/docs/getting-help>
e
You also might try
--no-pantsd
we scrub some env vars from pantsd such that "unsandboxed" operation could still be tripped up.
Bad solution, good debug step though.
b
Okay, it works with
--no-pantsd
e
Yeah, so that's the problem.
Not sure on a real solution.
h
@big-agency-50572 Can you file a bug at https://github.com/pantsbuild/pants/issues? All this detail is great.
b
Will do, thank you for the quick help 🙂 In the meantime I think I'll try get the build to run as the non-root user.
h
How many
pants
commands is the build running in a single container?
If just one, then
--no-pantsd
might be fine
at least as a stopgap
b
I've only just started implementing Pants so for now it's simply the
package
,
test
and
publish
goals building 3 Docker containers.