Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when command creates ignored files but fails #460

Open
wizeman opened this issue Apr 28, 2022 · 0 comments
Open

Errors when command creates ignored files but fails #460

wizeman opened this issue Apr 28, 2022 · 0 comments

Comments

@wizeman
Copy link
Contributor

wizeman commented Apr 28, 2022

This script works as expected:

$ cat good.sh
#!/usr/bin/env bash

set -euo pipefail

rm -rf .tup cache

cat > Tupfile.lua <<EOF
tup.rule({}, 'mkdir -p cache && echo hi > cache/cache.txt', { '^cache' })
EOF

tup init
tup
$ ./good.sh
tup repository initialized: .tup/db
[ tup ] [0.004s] Scanning filesystem...
[ tup ] [0.007s] Reading in new environment variables...
[ tup ] [0.011s] Parsing Tupfiles...
 0) [0.003s] .
 [ ] 100%
[ tup ] [0.020s] No files to delete.
[ tup ] [0.023s] Executing Commands...
 0) [0.006s] mkdir -p cache && echo hi > cache/cache.txt
 [ ] 100%
[ tup ] [0.033s] Updated.

However, this very similar one doesn't (the only difference between them is the command ends in && false in the one below):

$ cat bad.sh
#!/usr/bin/env bash

set -euo pipefail

rm -rf .tup cache

cat > Tupfile.lua <<EOF
tup.rule({}, 'mkdir -p cache && echo hi > cache/cache.txt && false', { '^cache' })
EOF

tup init
tup
$ ./bad.sh
.tup repository initialized: .tup/db
[ tup ] [0.005s] Scanning filesystem...
[ tup ] [0.010s] Reading in new environment variables...
[ tup ] [0.014s] Parsing Tupfiles...
 0) [0.004s] .
 [ ] 100%
[ tup ] [0.023s] No files to delete.
[ tup ] [0.028s] Executing Commands...
 [ ]   0%/home/username/tmp/tup/cache/cache.txt: No such file or directory
* 0) mkdir -p cache && echo hi > cache/cache.txt && false
 *** tup messages ***
 *** Command ID=13 failed with return value 1
tup error: Unable to rename temporary file '.tup/tmp/0' to destination '/home/username/tmp/tup/cache/cache.txt'
 [ ] 100%
 *** tup: 1 job failed.

Apart from the tup error: Unable to rename temporary file ... and No such file or directory errors, there is also a major problem in that the cache/cache.txt file doesn't get generated as I expected (even though the command failed).

This prevents the cache file from being reused when the command runs the next time (and, in my real-world case, means that the command runs very slowly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant