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

General Question/Azure-cli #21

Closed
idkjs opened this issue Apr 22, 2017 · 4 comments
Closed

General Question/Azure-cli #21

idkjs opened this issue Apr 22, 2017 · 4 comments

Comments

@idkjs
Copy link

idkjs commented Apr 22, 2017

So @atomantic, I very much appreciate you sharing this. Clearly you have a helpful soul. I'm trying to dig into this and understand how to get control of my mac for dev. I have installed azure-cli with this script. I then get this error /Users/devworx/lib/azure-cli/az.completion:10: command not found: complete, screenshot:
screen shot 2017-04-22 at 11 23 23

This azure-cli issue suggests a method to correct this error however, I am trying understand how you would do it. My first thought is to add it to ~./shellpaths. More generally, is there a built in script for adding new items installed via curl to the path? If not how would you do it. Thank you.

@atomantic
Copy link
Owner

usually, cli tools will add something to your shell rc file as part of the install process--and it looks like it did do something of that sort since your shell is trying to load /Users/devworx/lib/azure-cli/az.completion when you open a new tab.

It looks like this may be a bug in the azure-cli with support for the version of zsh that you have installed: Azure/azure-cli#1722

berndverst commented on Feb 5
I just noticed that zsh version 5.2 is not the latest. For some reason I wasn't managing it via homebrew, so I updated my install with brew install zsh. Now running zsh 5.3.1 (x86_64-apple-darwin16.3.0) I no longer get this error.

@niemyjski perhaps upgrading your zsh will fix this for you too? 🤷‍♂️

@idkjs
Copy link
Author

idkjs commented Apr 24, 2017

I checked the version and its correct. So from your answer, you would expect that a new npm install would get you access to an executable without having to do anything else. It doesnt seem to be working so smoothly for me.

@atomantic
Copy link
Owner

I wouldn't expect this to be an npm issue--the azure cli is outside of npm. The problem points to this line: https://github.com/Azure/azure-cli/blob/1271aa0cad486b8c61cc788c912f3e87092bb104/packaged_releases/az.completion#L21

The complete command/function doesn't exist.

Did you try adding: autoload bashcompinit && bashcompinit to .zshrc before the line sourcing azure-cli/az.completion?

@idkjs
Copy link
Author

idkjs commented Apr 25, 2017

:tldr @atomantic is a generous genius.
:whole story:
I guess we are getting to the heart of it. I didnt source azure-cli/az.completion in .zshrc. Im not clear on the steps for adding a new package to this set up. So from the sounds of it, the steps generally to 1. Run the install 2. Add a script sourcing the new executable to your .rc file. In this case, its .zshrc because we are using the .zsh shell. 3. Reset terminal (exec $SHELL or open new terminal).

In this specific case it looks like this. This worked successfully.

  1. $ curl -L https://aka.ms/InstallAzureCli | bash.
    //output of Getting Error: No available Cask for lastpass-universal #1
azure-cli directory: '/Users/devworx/lib/azure-cli'
===> In what directory would you like to place the 'az' executable? (leave blank to use '/Users/devworx/bin'): //left blank

===> Enter a path to an rc file to update (leave blank to use '/Users/devworx/.bash_profile'):
//entered path to .zshrc
 /Users/devworx/.zshrc
//output
-- Backed up '/Users/devworx/.dotfiles/homedir/.zshrc' to '/Users/devworx/.dotfiles/homedir/.zshrc.backup'
-- Tab completion set up complete.
-- If tab completion is not activated, verify that '/Users/devworx/.dotfiles/homedir/.zshrc' is sourced by your shell.
--
-- ** Run `exec -l $SHELL` to restart your shell. **
--
-- Installation successful.
-- Run the CLI with /Users/devworx/bin/az --help

This is the newly generated .zshrc

 ~  cat ~/.zshrc                                         ✓  1095  10:04:56
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.dotfiles/oh-my-zsh
# if you want to use this, change your non-ascii font to Droid Sans Mono for Awesome
# POWERLEVEL9K_MODE='awesome-patched'
export ZSH_THEME="powerlevel9k/powerlevel9k"
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
# https://github.com/bhilburn/powerlevel9k#customizing-prompt-segments
# https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir nvm vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time)
# colorcode test
# for code ({000..255}) print -P -- "$code: %F{$code}This is how your text would look like%f"
POWERLEVEL9K_NVM_FOREGROUND='000'
POWERLEVEL9K_NVM_BACKGROUND='072'
POWERLEVEL9K_SHOW_CHANGESET=true
#export ZSH_THEME="random"

# Set to this to use case-sensitive completion
export CASE_SENSITIVE="true"

# disable weekly auto-update checks
# export DISABLE_AUTO_UPDATE="true"

# disable colors in ls
# export DISABLE_LS_COLORS="true"

# disable autosetting terminal title.
export DISABLE_AUTO_TITLE="true"

# Which plugins would you like to load? (plugins can be found in ~/.dotfiles/oh-my-zsh/plugins/*)
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(colorize compleat dirpersist autojump git gulp history cp)

source $ZSH/oh-my-zsh.sh

test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

source /usr/local/opt/nvm/nvm.sh

autoload -U add-zsh-hook
load-nvmrc() {
  if [[ -f .nvmrc && -r .nvmrc ]]; then
    nvm use &> /dev/null
  elif [[ $(nvm version) != $(nvm version default)  ]]; then
    nvm use default &> /dev/null
  fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc

# Customize to your needs...
unsetopt correct

# run fortune on new terminal :)
fortune

export PATH=$PATH:/Users/devworx/bin

source '/Users/devworx/lib/azure-cli/az.completion'

Running exec -l $SHELL gets the command not found error.

Use the Force, Luke.
/Users/devworx/lib/azure-cli/az.completion:10: command not found: complete

Then followed your instruction adding 'autoload bashcompinit && bashcompinit '(even though i have no idea what that is, will research)

 ~  nvim ~/.zshrc                                    127 ↵  1096  10:06:18
...
autoload bashcompinit && bashcompinit
source '/Users/devworx/lib/azure-cli/az.completion'
....
 ~exec -l $SHELL

Then run az:

az                                                   ✓  1099  10:08:29

     /\
    /  \    _____   _ _ __ ___
   / /\ \  |_  / | | | \'__/ _ \
  / ____ \  / /| |_| | | |  __/
 /_/    \_\/___|\__,_|_|  \___|


Welcome to the cool new Azure CLI!

Here are the base commands:

    account   : Manage subscriptions.
....

I figured I would leave this here in case it helps anyone else. Thus the details...

@idkjs idkjs closed this as completed Apr 25, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants