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

AUTOCOMPLETION. ng completion has no output #2253

Closed
MRokas opened this issue Sep 20, 2016 · 18 comments
Closed

AUTOCOMPLETION. ng completion has no output #2253

MRokas opened this issue Sep 20, 2016 · 18 comments
Labels
needs: investigation Requires some digging to determine if action is needed

Comments

@MRokas
Copy link

MRokas commented Sep 20, 2016

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    Ubuntu 16 64bit

  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.14
node: 6.6.0
os: linux x64
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
ng completion >> ~/.bashrc
source ~/.bashrc

there was no new text inside /.bashrc
trying to use it on any other .txt file, has same result

  1. The log given by the failure. Normally this include a stack trace and some
    more information.

  2. Mention any other details that might be useful.

----------------------------------ng completion-----------------------------
Thanks! We'll be in touch soon.

@filipesilva
Copy link
Contributor

Does this still happen? @catull has made some nice improvement to ng completion that might have fixed your issue. I'm on windows myself so cannot repro.

@filipesilva filipesilva reopened this Oct 3, 2016
@filipesilva filipesilva added the needs: more info Reporter must clarify the issue label Oct 3, 2016
@anisabboud
Copy link

~$ ng version
angular-cli: 1.0.0-beta.16
node: 6.7.0
os: linux x64

~$ ng completion
The specified command completion is invalid. For available options, see `ng help`.

@filipesilva
Copy link
Contributor

That's not right. I'll look into it.

@filipesilva filipesilva added needs: investigation Requires some digging to determine if action is needed and removed needs: more info Reporter must clarify the issue labels Oct 9, 2016
@catull
Copy link
Contributor

catull commented Oct 9, 2016

By the way, a recently installed angular-cli from npm repository,
ng version

angular-cli: 1.0.0-beta.17
node: 6.7.0
os: darwin x64

finally produces useful output, ng completion:

###-begin-ng-completion###
#
# ng command completion script
#
# Installation: ng completion >> ~/.bashrc (or ~/.zshrc)
#

ng_opts='b build completion doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test v version -h --help'

build_opts='--aot --base-href --environment --output-path --suppress-sizes --target --watch --watcher -bh -dev -e -o -prod -t -w'
generate_opts='class component directive enum module pipe route service c cl d e m p r s --help'
github_pages_deploy_opts='--base-href --environment --gh-token --gh-username --message --skip-build --target --user-page -bh -e -t'
help_opts='--json --verbose -v'
init_opts='--dry-run inline-style inline-template --link-cli --mobile --name --prefix --routing --skip-bower --skip-npm --source-dir --style --verbose -d -is -i

....

Good work!

@anisabboud
Copy link

Cool! Works for me too after updating the CLI. Thank you! This thread seems related to #1890.

Running ng completion >> ~/.bashrc as per the instructions didn't append anything to my ~/.bashrc, so I manually copied and pasted the output of ng completion to my ~/.bashrc.

When running source ~/.bashrc I got a syntax error, perhaps because the two lines that end with opts=$github_pages_deploy_opts in the output of ng completion are missing ;; in the end? Adding these solved it for me.

@catull
Copy link
Contributor

catull commented Oct 9, 2016

@anisabboud Good catch, the semi-colons are missing. Created a new PR for this, PR #2604.

@anisabboud
Copy link

Thanks @catull! That was quick.

Any idea why ng completion >> ~/.bashrc doesn't work? (mentioned in https://github.com/angular/angular-cli/#commands-autocompletion)

ng completion &>> ~/.bashrc (with &>>) works for me, so it seems like ng completion is printing to stderr instead of stdout..

@catull
Copy link
Contributor

catull commented Oct 9, 2016

Perhaps this should be the way to redirect standard output - not standand error diagnostic:

ng completion 1>> ~/.bashrc

I am not a bash user, but the statement would NOT append error output to ~/.bashrc.
Can you verify ?
This works in zsh:

ng completion 1>>~/.zshrc

The '|' is necessary to create it freshly.

The above statement would work in zsh, though.

@anisabboud
Copy link

anisabboud commented Oct 9, 2016

ng completion 1>> ~/.bashrc is not doing anything for me.

Looks like console.log(scriptOutput) is printing to stderr even though the nodejs documentation says it prints to stdout.

(I'm fairly new to the Angular world.)

@catull
Copy link
Contributor

catull commented Oct 9, 2016

Actually, if completion.sh printed to stderr, then the behaviour described initially is correct, because an error happened causing the script to be exited without useful output.

The original poster did not volunteer more information, so it is difficult to fix his/her situation.
It's all guess-work now.

@chpasha
Copy link

chpasha commented Oct 10, 2016

I have the same issue on ubuntu 14.04 - ng completion issues the script code, but >> does nothing

@catull
Copy link
Contributor

catull commented Oct 10, 2016

Can you provide more pieces of information, please ?

Which shell, and which version of it ?
Which version of node, npm and ng do you use ?

@chpasha
Copy link

chpasha commented Oct 10, 2016

GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Node v6.2.0
npm 3.8.9
angular-cli -1.0.0-beta.17

@anisabboud
Copy link

~$ lsb_release -a
Description:    Ubuntu 16.04.1 LTS

~$ bash --version
GNU bash, version 4.3.46(1)-release (x86_64-pc-linux-gnu)

~$ npm -v
3.10.3

~$ ng -v
angular-cli: 1.0.0-beta.17
node: 6.7.0
os: linux x64

To sum up my experience with ng completion:

  • ng completion works and prints the output to the terminal.
  • ng completion >> ~/.bashrc does nothing (which is the issue/bug).
  • ng completion &>> ~/.bashrc works and appends stuff to my ~/.bashrc.

@chpasha
Copy link

chpasha commented Oct 10, 2016

I have absolutely the same symptoms

@catull
Copy link
Contributor

catull commented Oct 10, 2016

Embarassingly my situation is much similar.

OS: macOS Sierra (10.12)
npm: 3.10.8
angular-cli: 1.0.0-beta.17
node: 6.7.0
os: darwin x64
shell: zsh 5.2

In zsh, executing ng completion displays the expected shell statements.
But, all these attempts

  • ng completion >>someFile
  • ng completion >>| someOtherFile
  • ng completion 1>>anotherFile
  • ng completion 2>>oneMoreFile

produce empty files.

The solution is to use this frankensteinian monstruction:

ng complete 1>> ~/.bashrc 2>>& or
ng complete 1>> ~/.zshrc 2>>&.

It is important to keep a gap between 1>> and the file name, at least for zsh.

Will produce a new PR.

@catull
Copy link
Contributor

catull commented Oct 10, 2016

Produced PR #2635 as a solution.
I'd say the "investigation" is done.

@hansl hansl closed this as completed Jan 9, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: investigation Requires some digging to determine if action is needed
Projects
None yet
Development

No branches or pull requests

6 participants