# Buggy code
def from_credentials(
    cls, credentials, threads, profile_name, target_name, user_cfg=None
):
    """Create a profile from an existing set of Credentials and the
    remaining information.

    :param credentials Credentials: The credentials for this profile.
    :param threads int: The number of threads to use for connections.
    :param profile_name str: The profile name used for this profile.
    :param target_name str: The target name used for this profile.
    :param user_cfg Optional[dict]: The user-level config block from the
        raw profiles, if specified.
    :raises DbtProfileError: If the profile is invalid.
    :returns Profile: The new Profile object.
    """
    if user_cfg is None:
        user_cfg = {}
    send_anonymous_usage_stats = user_cfg.get(
        "send_anonymous_usage_stats", DEFAULT_SEND_ANONYMOUS_USAGE_STATS
    )
    use_colors = user_cfg.get("use_colors", DEFAULT_USE_COLORS)
    profile = cls(
        profile_name=profile_name,
        target_name=target_name,
        send_anonymous_usage_stats=send_anonymous_usage_stats,
        use_colors=use_colors,
        threads=threads,
        credentials=credentials,
    )
    profile.validate()
    return profile


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def from_credentials(
    cls, credentials, threads, profile_name, target_name, user_cfg=None
):
    """Create a profile from an existing set of Credentials and the
    remaining information.

    :param credentials Credentials: The credentials for this profile.
    :param threads int: The number of threads to use for connections.
    :param profile_name str: The profile name used for this profile.
    :param target_name str: The target name used for this profile.
    :param user_cfg Optional[dict]: The user-level config block from the
        raw profiles, if specified.
    :raises DbtProfileError: If the profile is invalid.
    :returns Profile: The new Profile object.
    """
    config = UserConfig.from_dict(user_cfg)
    profile = cls(
        profile_name=profile_name,
        target_name=target_name,
        config=config,
        threads=threads,
        credentials=credentials,
    )
    profile.validate()
    return profile