[GH-ISSUE #62] Unhandled error: <class 'FileExistsError'>, [Errno 17] File exists #30

Closed
opened 2026-05-06 12:36:25 +02:00 by BreizhHardware · 6 comments

Originally created by @DavideExp on GitHub (Oct 6, 2023).
Original GitHub issue: https://github.com/patrickchugh/terravision/issues/62

Hello,
I'm new to Terravision.
From a RHEL8 container, I'm trying to run terravision draw on both a local repo and one in Bitbucket but I keep getting the following error:
Downloading External Module: git::https://xxx/scm/yyy/module Cloning from Terraform registry source: https://xxx/scm/yyy/module Skipping download of module git__https_//xxx/scm/yyy/module, found existing folder in module cache Unhandled error: <class 'FileExistsError'>, [Errno 17] File exists: '/tmp/tmpm0n6kthk/;module_name;git__https_//xxx/scm/yyy/module', <traceback object at 0x7fc1567b8900>

I can't see the folder in /tmp. I tried to delete the module from terravision cache but the same happened again.
That module is called by other modules in the code.

Any suggestions?

Thanks

Originally created by @DavideExp on GitHub (Oct 6, 2023). Original GitHub issue: https://github.com/patrickchugh/terravision/issues/62 Hello, I'm new to Terravision. From a RHEL8 container, I'm trying to run `terravision draw` on both a local repo and one in Bitbucket but I keep getting the following error: `Downloading External Module: git::https://xxx/scm/yyy/module Cloning from Terraform registry source: https://xxx/scm/yyy/module Skipping download of module git__https_//xxx/scm/yyy/module, found existing folder in module cache Unhandled error: <class 'FileExistsError'>, [Errno 17] File exists: '/tmp/tmpm0n6kthk/;module_name;git__https_//xxx/scm/yyy/module', <traceback object at 0x7fc1567b8900>` I can't see the folder in `/tmp`. I tried to delete the module from terravision cache but the same happened again. That module is called by other modules in the code. Any suggestions? Thanks
Author
Owner

@dhurdpepper commented on GitHub (Oct 6, 2023):

Just ran into this myself. Was able to hack together a solution by running with the --debug flag, finding the file that threw the FileExistsError exception, catching it, and setting the appropriate variable to the filename property on the exception.

e.g.

# modules/fileparser.py
try:
    modfolder = gitlibs.clone_files(sourceURL, temp_modules_dir, k)
except Exception as e:
    modfolder = e.filename
<!-- gh-comment-id:1751329834 --> @dhurdpepper commented on GitHub (Oct 6, 2023): Just ran into this myself. Was able to hack together a solution by running with the `--debug` flag, finding the file that threw the FileExistsError exception, catching it, and setting the appropriate variable to the `filename` property on the exception. e.g. ```py # modules/fileparser.py try: modfolder = gitlibs.clone_files(sourceURL, temp_modules_dir, k) except Exception as e: modfolder = e.filename ```
Author
Owner

@patrickchugh commented on GitHub (Oct 7, 2023):

I am presently rewriting the code to use terraform's own module cache instead of cloning the source separately so this issue should hopefully go away

<!-- gh-comment-id:1751637788 --> @patrickchugh commented on GitHub (Oct 7, 2023): I am presently rewriting the code to use terraform's own module cache instead of cloning the source separately so this issue should hopefully go away
Author
Owner

@patrickchugh commented on GitHub (Oct 7, 2023):

I will be releasing a new version that doesn't clone modules and uses the terraform cache so this problem will hopefully be resolved soonSent from Outlook for AndroidFrom: Devin Hurd @.>Sent: Friday, October 6, 2023 8:49:51 pmTo: patrickchugh/terravision @.>Cc: Subscribed @.***>Subject: Re: [patrickchugh/terravision] Unhandled error: <class 'FileExistsError'>, [Errno 17] File exists (Issue #62)
Just ran into this myself. Was able to hack together a solution by running with the --debug flag, finding the file that threw the FileExistsError exception, catching it, and setting the appropriate variable to the filename property on the exception.
e.g.
// modules/fileparser.py
try:
modfolder = gitlibs.clone_files(sourceURL, temp_modules_dir, k)
except Exception as e:
modfolder = e.filename

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

<!-- gh-comment-id:1751639414 --> @patrickchugh commented on GitHub (Oct 7, 2023): I will be releasing a new version that doesn't clone modules and uses the terraform cache so this problem will hopefully be resolved soonSent from Outlook for AndroidFrom: Devin Hurd ***@***.***>Sent: Friday, October 6, 2023 8:49:51 pmTo: patrickchugh/terravision ***@***.***>Cc: Subscribed ***@***.***>Subject: Re: [patrickchugh/terravision] Unhandled error: <class 'FileExistsError'>, [Errno 17] File exists (Issue #62) Just ran into this myself. Was able to hack together a solution by running with the --debug flag, finding the file that threw the FileExistsError exception, catching it, and setting the appropriate variable to the filename property on the exception. e.g. // modules/fileparser.py try: modfolder = gitlibs.clone_files(sourceURL, temp_modules_dir, k) except Exception as e: modfolder = e.filename —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
Author
Owner

@patrickchugh commented on GitHub (Nov 21, 2023):

@DavideExp @dhurdpepper Hello, thank you for your feedback and thanks for testing out Terravision and helping to make this a better product. I have recently completed a major revamp to the code which uses the terraform binary to download source files and generate initial relationships, before augmenting it with source code parsing as before. This is a significant departure from the previous approach and whilst slower, ensures a more accurate output and will handle all terraform in built functions now when encountered in the source. Please do a git pull and re-test again with the latest source code. If your problem is resolved, please close the the thread in github issues and mark it as completed. If not, please give as much detail as you can about the errors and include any source files if possible so I can reproduce your issue. Once again, thanks for helping and look forward to hearing from you soon.

P.

<!-- gh-comment-id:1820022168 --> @patrickchugh commented on GitHub (Nov 21, 2023): @DavideExp @dhurdpepper Hello, thank you for your feedback and thanks for testing out Terravision and helping to make this a better product. I have recently completed a major revamp to the code which uses the terraform binary to download source files and generate initial relationships, before augmenting it with source code parsing as before. This is a significant departure from the previous approach and whilst slower, ensures a more accurate output and will handle all terraform in built functions now when encountered in the source. Please do a git pull and re-test again with the latest source code. If your problem is resolved, please close the the thread in github issues and mark it as completed. If not, please give as much detail as you can about the errors and include any source files if possible so I can reproduce your issue. Once again, thanks for helping and look forward to hearing from you soon. P.
Author
Owner

@patrickchugh commented on GitHub (Nov 29, 2023):

can we close this issue now?

<!-- gh-comment-id:1831532961 --> @patrickchugh commented on GitHub (Nov 29, 2023): can we close this issue now?
Author
Owner

@dhurdpepper commented on GitHub (Nov 29, 2023):

@patrickchugh I'm not planning on retesting this any time soon, so fine by me.

<!-- gh-comment-id:1831985941 --> @dhurdpepper commented on GitHub (Nov 29, 2023): @patrickchugh I'm not planning on retesting this any time soon, so fine by me.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/terravision#30
No description provided.