CHEF - Attempt to use relative path 'foo when current directory is outside the repository path

spuder picture spuder · Jul 23, 2015 · Viewed 8.5k times · Source

When I try and run knife upload roles or knife upload /roles it gives the following error

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

My knife.rb file

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

Answer

spuder picture spuder · Jul 23, 2015

This can happen when the cookbook_path is not properly set in your knife.rb

Do the following:

Make sure you have a trailing slash in your knife.rb

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

Or pass in the repo path from the commandline

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