You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用dbt run报错:无效配置版本1,预期为2

问题:dbt run 报错 "Invalid config version: 1, expected 2"

操作步骤

  1. 通过dbt init在.dbt文件夹生成profiles.yml,内容如下:
spring_project:
  outputs:
    dev:
      account: xxx.snowflakecomputing.com
      database: PROD_DWH
      password: password
      role: SYSADMIN
      schema: STG
      threads: 1
      type: snowflake
      user: MYUSERNAME
      warehouse: DEV_XS_WH
  target: dev
  1. 在桌面新建项目文件夹,仅包含dbt_project.yml,内容为:
profile: 'spring_project'
  1. 运行dbt debug --config-dir显示正常:
21:48:59  Running with dbt=1.2.1
21:48:59  To view your profiles.yml file, run:

open /Users/myusername/.dbt
  1. 运行dbt run --profiles-dir /Users/myusername/.dbt时出现报错:
21:43:39  Encountered an error while reading the project:
21:43:39    ERROR: Runtime Error
  Invalid config version: 1, expected 2

Error encountered in /Users/myusername/Desktop/spring_project/dbt_project.yml
21:43:39  Encountered an error:
Runtime Error
  Could not run dbt
21:43:39  Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/task/base.py", line 108, in from_args
    config = cls.ConfigType.from_args(args)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/config/runtime.py", line 226, in from_args
    project, profile = cls.collect_parts(args)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/config/runtime.py", line 194, in collect_parts
    partial = Project.partial_load(project_root, verify_version=version_check)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/config/project.py", line 639, in partial_load
    return PartialProject.from_project_root(
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/config/project.py", line 485, in from_project_root
    raise DbtProjectError(
dbt.exceptions.DbtProjectError: Runtime Error
  Invalid config version: 1, expected 2

Error encountered in /Users/myusername/Desktop/spring_project/dbt_project.yml

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

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/main.py", line 129, in main
    results, succeeded = handle_and_check(args)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/main.py", line 191, in handle_and_check
    task, res = run_from_args(parsed)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/main.py", line 218, in run_from_args
    task = parsed.cls.from_args(args=parsed)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/task/base.py", line 185, in from_args
    return super().from_args(args)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/task/base.py", line 114, in from_args
    raise dbt.exceptions.RuntimeException("Could not run dbt") from exc
dbt.exceptions.RuntimeException: Runtime Error
  Could not run dbt

问题原因与解决方法

报错核心是dbt_project.yml缺少必填的config-version字段,dbt 1.2.1要求该字段值为2。

修改dbt_project.yml,补充必要配置项,至少包含以下内容:

name: 'spring_project'
version: '1.0.0'
config-version: 2
profile: 'spring_project'

关键字段说明

  • config-version:dbt识别项目配置格式的版本号,dbt 0.18及以上版本必须设为2
  • name:自定义dbt项目名称
  • version:自定义项目版本号

修改后重新运行dbt run --profiles-dir /Users/myusername/.dbt即可解决报错。

内容的提问来源于stack exchange,提问作者x89

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 19:20:47