cool-easter-32542
04/24/2023, 6:49 AMdist/codegen fails with IntrinsicError: File exists (os error 17), potentially being unable to overwrite the symlink.
I'm guessing this applies to more than just export-codegen and shell_command, but that and shell_command are the easiest way I know to repeatedly attempt to write a symlink to a single path.
Reproducer:
cd $(mktemp -d)
cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.16.0rc1"
backend_packages = ["pants.backend.shell"]
[anonymous-telemetry]
enabled = false
EOF
cat > BUILD <<EOF
shell_command(
name="symlink",
command="ln -s whatever.txt link.txt",
tools=["ln"],
output_files=["link.txt"],
)
shell_command(
name="normal",
command="touch file.txt",
tools=["touch"],
output_files=["file.txt"],
)
EOF
pants export-codegen :symlink
# OK: ... Writing generated files to dist/codegen
pants export-codegen :symlink
# BUG: ... IntrinsicError: File exists (os error 17)
# delete the existing symlink, and try again:
rm dist/codegen/link.txt
pants export-codegen :symlink
# OK: ... Writing generated files to dist/codegen
# non-link works fine, for comparison:
pants export-codegen :normal
# OK: ... Writing generated files to dist/codegen
pants export-codegen :normal
# OK: ... Writing generated files to dist/codegen
All of the `export-codegen`s work, except for the BUG one:
16:42:31.28 [INFO] Writing generated files to dist/codegen
16:42:31.28 [ERROR] 1 Exception encountered:
Engine traceback:
in `export-codegen` goal
IntrinsicError: File exists (os error 17)
Pants version
2.16.0rc1
OS
macOS
Additional info
#17758 is mildly related, since both that and this are pants failing to correctly update the contents of dist/.
pantsbuild/pantscool-easter-32542
05/01/2023, 10:10 PM