ci: check if file or directory already exists for ${HOME}/.bitcoin instead of failing #33486

pull kevkevinpal wants to merge 1 commits into bitcoin:master from kevkevinpal:checkIfDirExists changing 1 files +10 −3
  1. kevkevinpal commented at 6:03 pm on September 27, 2025: contributor

    Description

    I was trying to run this script, but then it was giving me this error

    0/ci_container_base/ci/test/03_test_script.sh: line 90: /root/.bitcoin: Is a directory
    1Command '['./ci/test/02_run_container.sh']' returned non-zero exit status 1.
    

    Since there is a directory there, we should skip this step.

    Solution

    I created a check to see if a directory or a file already exists, otherwise create one

    How to reproduce

    I’m on Fedora 27

    0mkdir $HOME/.bitcoin
    1./ci/test/03_test_script.sh
    

    This should be enough to run into the error, since the directory exists and the script thus cannot create a file

  2. DrahtBot added the label Tests on Sep 27, 2025
  3. DrahtBot commented at 6:03 pm on September 27, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33486.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  4. kevkevinpal renamed this:
    ci: check if file or directory already exists for /home/kevkevin/.bitcoin instead of failing
    ci: check if file or directory already exists for ${HOME}/.bitcoin instead of failing
    on Sep 27, 2025
  5. kevkevinpal force-pushed on Sep 27, 2025
  6. in ci/test/03_test_script.sh:94 in fde2dc41d1
    92@@ -93,9 +93,16 @@ fi
    93 
    94 # Make sure default datadir does not exist and is never read by creating a dummy file
    


    katesalazar commented at 8:42 am on September 28, 2025:
    You can’t leave this line unchanged.

    kevkevinpal commented at 4:27 pm on September 28, 2025:
    Updated now in 3f5596f
  7. in ci/test/03_test_script.sh:101 in fde2dc41d1 outdated
     98 else
     99-  echo > "${HOME}/.bitcoin"
    100+  DATADIR="${HOME}/.bitcoin"
    101+fi
    102+
    103+# Check if DATADIR exists (file or directory), skip if it does
    


    katesalazar commented at 8:43 am on September 28, 2025:
    The dummy file explanation is much early.

    kevkevinpal commented at 4:28 pm on September 28, 2025:
    I removed the explanation in 3f5596f now we can have this explanation here since it is more accurate
  8. katesalazar commented at 8:45 am on September 28, 2025: contributor
    I don’t like how dummy file is now explained much before created.
  9. ci: check if file or directory already exists for ${HOME}/.bitcoin instead of failing 3f5596fd13
  10. kevkevinpal force-pushed on Sep 28, 2025
  11. maflcko commented at 6:05 am on September 29, 2025: member
    I don’t think it is supported or even encouraged to run this internal CI script on an outside machine. Also, I fail to see how this could even work, as you did not include any steps how to reproduce.
  12. katesalazar commented at 10:27 am on September 29, 2025: contributor
    I think it’s best when as many CI scripts as possible can be run on any host. But I can agree on not cahnging this if there is no clear underlining issue being fixed.
  13. kevkevinpal commented at 2:59 pm on September 29, 2025: contributor

    I don’t think it is supported or even encouraged to run this internal CI script on an outside machine.

    Yea I understand this, I was just playing around with the scripts to understand better how the CI works

    Also, I fail to see how this could even work, as you did not include any steps how to reproduce.

    Yes, I updated the description. Basically, just create a directory in $HOME/.bitcoin and then try to run ./ci/test/03_test_script.sh and you should see the error.

    For me it is just weird to see the script failing here since creating a file or dir shouldn’t fail


    But I can understand that this isn’t causing any issues currently and is only for CI. So it is not needed I can close this PR

  14. kevkevinpal commented at 2:59 pm on September 29, 2025: contributor
    closing as it doesn’t fix any currently existing issue
  15. kevkevinpal closed this on Sep 29, 2025

  16. maflcko commented at 3:33 pm on September 29, 2025: member

    For me it is just weird to see the script failing here since creating a file or dir shouldn’t fail

    It actually should fail. The goal of the check is to verify no mainnet datadir access is happening from any of the tests. Maybe the comment could be clarified to mention this?

    (Disabling this check would be better by just removing it)

  17. kevkevinpal commented at 5:57 pm on September 29, 2025: contributor

    For me it is just weird to see the script failing here since creating a file or dir shouldn’t fail

    It actually should fail. The goal of the check is to verify no mainnet datadir access is happening from any of the tests. Maybe the comment could be clarified to mention this?

    (Disabling this check would be better by just removing it)

    gotcha that makes more sense to me now, I can open up PR modifying the comment to reflect that.

  18. kevkevinpal commented at 6:03 pm on September 29, 2025: contributor

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-10-10 12:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me