Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

knife list without any arguments throws relative path error #9052

Closed
tas50 opened this issue Nov 4, 2019 · 2 comments · Fixed by #9059

Comments

@tas50
Copy link
Member

@tas50 tas50 commented Nov 4, 2019

❰tsmith❙~❱✘≻ /opt/chef-workstation/embedded/bin/knife list -VVV
INFO: Using configuration from /Users/tsmith/.chef/config.rb
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
TRACE: Unable to access cache at /var/chef. Switching cache to /Users/tsmith/.chef
ERROR: Attempt to use relative path '' when current directory is outside the repository path.
ERROR: Current working directory is '/Users/tsmith'.
@vsingh-msys

This comment has been minimized.

Copy link
Contributor

@vsingh-msys vsingh-msys commented Nov 5, 2019

@tas50 as per the knife list signature knife list [-dfR1p] [PATTERN1 ... PATTERNn]

we required PATTERNs as an argument. but if we hit knife list seems currently we are passing empty string arguments. it validated in

def pattern_arg_from(arg)
inferred_path = nil
if Chef::ChefFS::PathUtils.is_absolute?(arg)
# We should be able to use this as-is - but the user might have incorrectly provided

Possible fixes:

  1. Mandatory first argument and raise an error if the user hit the knife list without arguments.
    Reference: knife download, knife upload etc.

OR

  1. Currently, we are manually setting the first argument an empty string if user no passing.
    In order to fix it this, we can change it to "/".

patterns = name_args.length == 0 ? [""] : name_args

@tas50

This comment has been minimized.

Copy link
Member Author

@tas50 tas50 commented Nov 5, 2019

Since we need args it's probably best to fail with a helpful message when the necessary args are missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.