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

Fabric路径配置困惑:执行peer命令提示找不到core.yaml

解决Hyperledger Fabric 2.2中peer命令找不到core.yaml的问题

你执行以下命令时:

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n ledger -c '{"Args":["CreateAsset","asset1","blue","5","tom","35"]}'

收到错误提示:

Fatal error when initializing core config : Could not find config file. Please make sure that FABRIC_CFG_PATH is set to a path which contains core.yaml

解决步骤

  • 确认core.yaml路径:根据你提供的截图,core.yaml位于指定目录,先记下该目录的绝对路径。
  • 设置环境变量:在终端中执行命令,将FABRIC_CFG_PATH指向包含core.yaml的目录,替换为你实际的路径:
    export FABRIC_CFG_PATH=/实际路径/包含core.yaml的目录
    
    例如如果当前在fabric-samples目录下,core.yaml在config子目录,可执行:
    export FABRIC_CFG_PATH=${PWD}/config
    
  • 临时生效执行命令:如果不想设置全局环境变量,可在peer命令前临时指定:
    FABRIC_CFG_PATH=/实际路径/包含core.yaml的目录 peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n ledger -c '{"Args":["CreateAsset","asset1","blue","5","tom","35"]}'
    
  • 永久生效配置:若要避免每次终端会话重复设置,可将环境变量添加到shell配置文件(如~/.bashrc或~/.zshrc):
    echo "export FABRIC_CFG_PATH=/实际路径/包含core.yaml的目录" >> ~/.bashrc
    source ~/.bashrc
    

说明

Hyperledger Fabric的peer命令默认从/etc/hyperledger/fabric查找core.yaml,但Fabric示例中的配置文件通常在自定义目录下,必须通过FABRIC_CFG_PATH明确指定其所在路径,才能让peer命令加载到正确的配置文件。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.23 12:36:32