"An error occurred: SpeckleException: Failed to initialize user application data path."

Hey fellow specklers,
I am getting the following error โ€œAn error occurred: SpeckleException: Failed to initialize user application data path.โ€, when my lambda function is trying to connect to my Speckle server, when i test the lambda locally everything works like a charm, but when i push it to the cloud it gives me this error. I cant seem to understand why?
Here are the more detailed logs :


Thanks in advance :slight_smile:

Core is expecting a set of folders which probably do not exist in your environment.
You should be able to override the default path by setting this env variable: SPECKLE_USERDATA_PATH

See: https://github.com/specklesystems/speckle-sharp/blob/c4963812160adce78482936c7cda338fd79d6a02/Core/Core/Helpers/Path.cs#L26C49-L26C70

Sorry for the undocumented feature!

2 Likes

Hey @teocomi,
Thanks for the quick response, AWS lambda is using x86_64 serverless architecture, but i am not sure where APPDATA is located, it seems like it goes wrong when finding the platform specific folder path:

def user_application_data_path() -> Path:
    path_override = _path()
    if path_override:
        return path_override
    try:
        if sys.platform.startswith("win"):
            app_data_path = os.getenv("APPDATA")
            if not app_data_path:
                raise SpeckleException(
                    message="Cannot get appdata path from environment."
                )
            return Path(app_data_path)
        else:
            # try getting the standard XDG_DATA_HOME value
            # as that is used as an override
            app_data_path = os.getenv("XDG_DATA_HOME")
            if app_data_path:
                return Path(app_data_path)
            else:
                return _ensure_folder_exists(Path.home(), ".config")
    except Exception as ex:
        raise SpeckleException(
            message="Failed to initialize user application data path.", exception=ex
        )

I found a solution, that is to set the SPECKLE_USERDATA_PATH (like you suggested) to โ€œ/tmpโ€, which is a a writable directory during execution of the function.

2 Likes

Awesome!
Iโ€™ll take this as an opportunity to bring up our Automate project which might be relevant for what youโ€™re building: Automate with Speckle

Ohh cool!!! This looks indeed very interesting for my use case, thanks for bringing that to my attention!

1 Like