Reputation: 2771
It's alright when I download the cookbook.
PS> knife cookbook site download java_se
Downloading java_se from Supermarket at version 8.121.0 to D:/tools/chef-setupDevEnv/java_se-8.121.0.tar.gz
Cookbook saved: D:/tools/chef-setupDevEnv/java_se-8.121.0.tar.gz
However,when I want to install the cookbook the trouble came out.
PS>knife cookbook site install java_se
Installing java_se to D:/tools/chef-setupDevEnv/chef-java_se
ERROR: The cookbook repo path D:/tools/chef-setupDevEnv/chef-java_se does not exist or is not a directory
I found on the chef blog,
NOTE: If you receive the error “ERROR: IOError: Cannot open or read /Users/nshamrell/chef-repo/cookbooks/mysql/metadata.rb”, check which version of knife you are using with:
$ knife -v
If it is lower than Chef: 12.0.2, you will need to update your version of Knife. However, if you are using Chef DK and rvm, try running this command:$ rvm use system
As my situation.
PS> knife -v
Chef: 12.19.36
PS>rvm use system
+ rvm use system
+ ~~~
+ CategoryInfo : ObjectNotFound: (rvm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
When I run this on git bash
$ rvm use system
bash: rvm: command not found
Does that mean I need to install rvm?However,I'm working on an windows workstation that's also the reason I chose chef. What could the better solution now?
My knife.rb is in D:\tools\chef-setupDevEnv\.chef
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "bro****ane"
client_key "#{current_dir}/bro****ane.pem"
chef_server_url "https://api.chef.io/organizations/tm****gy"
cookbook_path ["#{current_dir}/../chef-java_se"]
Upvotes: 1
Views: 889
Reputation: 1384
When you run a knife cookbook site download
you tell knife to download a .tar.gz
of the cookbook in the current directory where you are invoking it. In this case it works for you.
However a knife cookbook site install
works differently. It assumes you have your knife.rb
value cookbook_path
pointing out to a directory in your filesystem which is a chef (and git) repo with (at least) one commit done. Which is not your case as far as I can see in what you're writing here.
You are invoking knife
in D:/tools/chef-setupDevEnv/SomeDirectory
while your knife.rb
tells knife to go #{current_dir}/../chef-java_se
which is D:/tools/chef-setupDevEnv/chef-java_se
, which probably does not exist and if so, it is not a chef/git repo satisfying the condition I stated in the previous paragraph.
The main usage of install
versus download
is to have control with branches of changes in the cookbooks you use, you will find more information about its advantages here.
Upvotes: 3