Unable to use dbt init command

The problem I’m having

Unable to use the dbt init command.

Anytime I run this command, I get the error shown below.
I’m on a brand new machine and using a cloned repository.

The context of why I’m trying to do this

  • Trying to set up dbt on a new machine

What I’ve already tried

  • Uninstalling and reinstalling dbt-core

Some example code or error messages

00:23:03  Running with dbt=1.7.0
00:23:03  Encountered an error:
[ConfigFolderDirectory]: Unable to parse dict {'dir': PosixPath('/Users/cs/.dbt')}
00:23:03  Traceback (most recent call last):
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/google/protobuf/json_format.py", line 608, in _ConvertFieldValuePair
    _ConvertScalarFieldValue(value, field,
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/google/protobuf/json_format.py", line 779, in _ConvertScalarFieldValue
    if _UNPAIRED_SURROGATE_PATTERN.search(value):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'PosixPath'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/dbt/events/base_types.py", line 72, in __init__
    self.pb_msg = ParseDict(kwargs, msg_cls())
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/google/protobuf/json_format.py", line 446, in ParseDict
    parser.ConvertMessage(js_dict, message, '')
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/google/protobuf/json_format.py", line 487, in ConvertMessage
    self._ConvertFieldValuePair(value, message, path)
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/google/protobuf/json_format.py", line 622, in _ConvertFieldValuePair
    raise ParseError(
google.protobuf.json_format.ParseError: Failed to parse dir field: expected string or bytes-like object, got 'PosixPath'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/dbt/cli/requires.py", line 90, in wrapper
    result, success = func(*args, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/dbt/cli/requires.py", line 75, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/dbt/cli/main.py", line 515, in init
    results = task.run()
              ^^^^^^^^^^
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/dbt/task/init.py", line 298, in run
    self.create_profiles_dir(profiles_dir)
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/dbt/task/init.py", line 70, in create_profiles_dir
    fire_event(ConfigFolderDirectory(dir=profiles_dir))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cs/premier-league/venv/lib/python3.12/site-packages/dbt/events/base_types.py", line 81, in __init__
    raise Exception(error_msg)
Exception: [ConfigFolderDirectory]: Unable to parse dict {'dir': PosixPath('/Users/cs/.dbt')}
1 Like

You can manually create the folder as a workaround, in your case, for example, mkdir /Users/cs/.dbt. More info here [Regression] TypeError: expected string or bytes-like object, got 'PosixPath' · Issue #9768 · dbt-labs/dbt-core · GitHub