Chef infra 厨师-尝试使用相对路径';当前目录位于存储库路径之外时的foo

Chef infra 厨师-尝试使用相对路径';当前目录位于存储库路径之外时的foo,chef-infra,knife,Chef Infra,Knife,当我尝试运行刀上传角色或刀上传/角色时,会出现以下错误 cd ~/my-chef-repo knife upload roles -n -V INFO: Using configuration from /Users/sowen/.chef/knife.rb ERROR: Attempt to use relative path 'roles' when current directory is outside the repository path 我的刀.rb文件 cookbook_pat

当我尝试运行
刀上传角色
刀上传/角色
时,会出现以下错误

cd ~/my-chef-repo
knife upload roles -n -V
INFO: Using configuration from /Users/sowen/.chef/knife.rb
ERROR: Attempt to use relative path 'roles' when current directory is outside the repository path
我的刀.rb文件

cookbook_path            "/Users/me/my-chef-repo"

如果菜谱路径未正确设置在刀中,则可能发生这种情况。rb

cookbook_path            "/Users/me/my-chef-repo/"
请执行以下操作:

确保刀子上有一条拖尾斜线。rb

cookbook_path            "/Users/me/my-chef-repo/"
或者从命令行传入repo路径

knife upload roles -n -VV --chef-repo-path /Users/me/my-chef-repo/

我发现,这把刀可以区分大小写:

或“斜杠”-敏感:


基本上,我的knife.rb中有一个斜杠(\),但我的Windows系统生成了另一个斜杠(/),它们不匹配。

对于我来说,我将cookbook文件夹放在~/.chef文件夹中,这是问题的根源。我通过将cookbook文件夹向上移动一个目录并更新~/.chef/knife.rb中的路径来解决这个问题

current_dir = File.dirname(__FILE__)
cookbook_path            ["#{current_dir}/../cookbook_dir"] 

与OP的问题无关,并且为false,windows使用反斜杠时不会生成“/”。Ruby解释器读取
knife.rb
文件时,会将反斜杠视为转义字符,弄乱路径,在配置中使用前斜杠,并根据操作系统清理路径。这看起来像repo路径吗?是否应该是与文档类似的
/Users/me/my chef repo/cookbooks
-