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

Error: Extension Path is not in the subpath of WebUI Path #136

Closed
CriticalSteffen opened this issue Mar 9, 2023 · 2 comments
Closed

Error: Extension Path is not in the subpath of WebUI Path #136

CriticalSteffen opened this issue Mar 9, 2023 · 2 comments

Comments

@CriticalSteffen
Copy link

In the webui-user.sh script, I have configured the --data-dir option to store extensions, models, etc. on a separate drive. Unfortunately, when tag_autocomplete_helper.py attempts to locate necessary files, it does so via Path().absolute() on line 10 of the tagcomplete Python script. Instead of returning the path of the extension's script, this returns the path of the stable-diffusion-webui/launch.py script, which results in the script attempting to load tags from a folder that doesn't exist:

Error loading script: tag_autocomplete_helper.py
Traceback (most recent call last):
  File "/home/username/stable-diffusion-webui/modules/scripts.py", line 229, in load_
scripts
    script_module = script_loading.load_module(scriptfile.path)
  File "/home/username/stable-diffusion-webui/modules/script_loading.py", line 11, in
 load_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/path/to/sd/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 191, in <module>
    write_tag_base_path()
  File "/path/to/sd/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 166, in write_tag_base_path
    f.write(TAGS_PATH.relative_to(FILE_DIR).as_posix())
  File "/usr/lib/python3.10/pathlib.py", line 818, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: '/path/to/sd/extensions/a1111-sd-webui-tagcomplete/tags' is not in the subpath of '/home/username/stable-diffusion-webui' OR one path is relative and the other is absolute.

This breaks the extension.

I'm unaware of any current workaround.

@DominikDoom
Copy link
Owner

This is similar to the underlying issues in #78, #132 and #134.

TL;DR:
Gradio only allows fetching files in the root or subfolders of the app for security reasons. This script is 80% javascript and reliant on what the browser can access, so even if the python helper would take those paths into account, I can't access them in javascript. As far as I know there's no way to bypass that. Maybe there would be a way around it by temporarily copying files or doing some junction symlink shenanigans, but that is well outside what this script would be allowed to do on a normal system (and also very dodgy), so it would need to be done by the user themselves.

@DominikDoom DominikDoom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2023
@DominikDoom
Copy link
Owner

@CriticalSteffen Good news, if still needed:
With the most recent update, the extension can now work with data-dir.

You will need to add the --gradio-allowed-path argument to your webui start script to make this work, else the helper will not throw the error anymore, but the server will still return 403 Unauthorized for any extension javascript file or tags file the webui tries to load.

A word of caution if you share the webui on your local network or even as a public server:
The allowed path will be publicly exposed. A simple JavaScript fetch("file=path/to/file") can access any file contents in that directory and its subdirectories, as long as the filename is known. You need to be careful what you allow in there.
I suggest only allowing the install dir of tag autocomplete itself for base functionality, or if you use wildcard extensions and want to use the wildcard completion feature, the whole extensions dir at most.

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

2 participants