Skip to content

FileNotFoundError for custom_nodes directory at startup (should be created instead of bailing) #8110

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

Open
polarathene opened this issue May 14, 2025 · 1 comment · May be fixed by #8115
Open
Labels
Potential Bug User is reporting a bug. This should be tested.

Comments

@polarathene
Copy link

polarathene commented May 14, 2025

Expected Behavior

ComfyUI should attempt to create the directory it wants skip checking the implicit custom_nodes/ dir when it is missing, rather than bail at startup.

Outdated

ComfyUI startup already handles creating other data directories when they're missing:

ComfyUI/folder_paths.py

Lines 49 to 52 in 98ff01e

output_directory = os.path.join(base_path, "output")
temp_directory = os.path.join(base_path, "temp")
input_directory = os.path.join(base_path, "input")
user_directory = os.path.join(base_path, "user")

input/ directory:

ComfyUI/folder_paths.py

Lines 96 to 100 in 98ff01e

if not os.path.exists(input_directory):
try:
os.makedirs(input_directory)
except:
logging.error("Failed to create input directory")

output/ directory: (created later on-demand)

ComfyUI/folder_paths.py

Lines 393 to 394 in 98ff01e

except FileNotFoundError:
os.makedirs(full_output_folder, exist_ok=True)

user/ directory:

class UserManager():
def __init__(self):
user_directory = folder_paths.get_user_directory()
self.settings = AppSettings(self)
if not os.path.exists(user_directory):
os.makedirs(user_directory, exist_ok=True)

temp/ directory:

ComfyUI/main.py

Line 286 in f3ff5c4

os.makedirs(folder_paths.get_temp_directory(), exist_ok=True)


Similar logic could be used to create a custom_nodes/ directory instead of failing?

folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes")], set())

ComfyUI/main.py

Lines 73 to 75 in 98ff01e

node_paths = folder_paths.get_folder_paths("custom_nodes")
for custom_node_path in node_paths:
possible_modules = os.listdir(custom_node_path)

Actual Behavior

When running ComfyUI with an empty data directory (such as when first using the --base-directory arg), during ComfyUI startup directories will be created as needed, all except for custom_nodes which raises an exception instead of also creating skipping that directory:

Traceback (most recent call last):
  File "/opt/comfyui/app/main.py", line 99, in <module>
    execute_prestartup_script()
  File "/opt/comfyui/app/main.py", line 75, in execute_prestartup_script
    possible_modules = os.listdir(custom_node_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/opt/comfyui/data/custom_nodes'

Steps to Reproduce

Run ComfyUI with --base-directory arg pointing to an empty directory.

Debug Logs

Traceback (most recent call last):
  File "/opt/comfyui/app/main.py", line 99, in <module>
    execute_prestartup_script()
  File "/opt/comfyui/app/main.py", line 75, in execute_prestartup_script
    possible_modules = os.listdir(custom_node_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/opt/comfyui/data/custom_nodes'
@polarathene polarathene added the Potential Bug User is reporting a bug. This should be tested. label May 14, 2025
@polarathene
Copy link
Author

After going over the source it doesn't seem like the custom_nodes/ dir needs to exist, just be skipped from listing it's contents.

I've raised a PR to resolve that along with co-locating some functionality for custom locations and directory creation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug User is reporting a bug. This should be tested.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant