spuder
spuder

Reputation: 18467

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

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"

Upvotes: 5

Views: 10283

Answers (3)

LAXIT KUMAR
LAXIT KUMAR

Reputation: 469

For me I was placing the cookbook folder inside ~/.chef folder which was causing the issue. I solved it by moving the cookbook folder one directory up and updated the path in ~/.chef/knife.rb.

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

Upvotes: 0

Slavik
Slavik

Reputation: 1517

I found, that knife can be either case-sensitive:

https://tickets.opscode.com/browse/CHEF-4663

or "slash"-sensitive:

Basically, I had one slash (\) in my knife.rb, but my Windows system was producing other slash (/), and they were not matching.

Upvotes: 0

spuder
spuder

Reputation: 18467

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/

Upvotes: 5

Related Questions