ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

No way to prevent update prompt

Open danielflippance opened this issue 9 years ago • 25 comments

Description: As part of our project scripts we check that the version of ionic installed is the one we expect. To do that we run this CLI command:

$ ionic --version --quiet

Which outputs

3.4.0

However, when there is a new update available to the CLI, the following prompt is shown and breaks all of our scripts. There appears to be no way to prevent this prompt from showing - the --quiet argument is ignored:

$ ionic --version --quiet
[INFO] The Ionic CLI has an update available (3.4.0 => 3.5.0)!

[WARN] No write permissions for global node_modules--automatic CLI updates are disabled.
       To fix, see https://docs.npmjs.com/getting-started/fixing-npm-permissions
       
       Or, install the CLI update manually (you will likely need sudo):
       
       npm install -g ionic@latest
       
? Local plugin @ionic/cli-plugin-cordova has an update available (1.4.0 => 1.4.1)! Would you like to install it? (Y/n) 

Steps to Reproduce: Run ionic --version --quiet after a CLI update

Output: See above

My ionic info:

$ ionic info

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1 
Ionic CLI        : 3.4.0
local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3 ios 4.4.0
Ionic Framework                 : ionic-angular 3.4.0
System:

Node       : v6.10.0
OS         : OS X El Capitan
Xcode      : Xcode 8.2.1 Build version 8C1002 
ios-deploy : 1.9.1 
ios-sim    : 5.0.13 
npm        : 3.10.10

danielflippance avatar Jul 12 '17 17:07 danielflippance

--quiet only changes the log level. The updates are something different. You can try --no-interactive, but an option to disable the update checks specifically is coming soon.

imhoffd avatar Jul 12 '17 21:07 imhoffd

Thanks but --no-interactive didn't change the outcome. Looking forward to the option to disable update checks specifically.

danielflippance avatar Jul 12 '17 23:07 danielflippance

@dwieeb +1 for disabling the update checks. The release of the Ionic CLI 3.5.0 broke all of our builds too

funkybaboon:operations-ionic $ node_modules/ionic/bin/ionic --no-interactive -v 
? The Ionic CLI has an update available (3.4.0 => 3.5.0)! Would you like to install it? (Y/n) 

funkybaboon avatar Jul 13 '17 10:07 funkybaboon

Has anyone successfully worked around this? Even if you run the latest version, the upgrade-available notification goes away, but there's still the prompt to query for updates in the background. As noted above, --no-interactive is powerless to suppress this one. Running ionic in CI/noninteractive appears to be impossible as a result?

bradjones1 avatar Aug 01 '17 22:08 bradjones1

@bradjones1 Are you using --no-interactive with every command?

imhoffd avatar Aug 02 '17 00:08 imhoffd

@dwieeb - yes. Evidence:

node@38196c580cb3:/src$ yarn ionic serve --no-interactive
yarn ionic v0.24.4
$ "/src/node_modules/.bin/ionic" serve
? The Ionic CLI can automatically check for CLI updates in the background. Would you like to enable this? No
[INFO] Starting app-scripts server: --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address
...
node@38196c580cb3:/src$ yarn ionic version
yarn ionic v0.24.4
$ "/src/node_modules/.bin/ionic" version
3.6.0

bradjones1 avatar Aug 02 '17 00:08 bradjones1

@bradjones1 The flag is not being passed to the Ionic CLI 👉 $ "/src/node_modules/.bin/ionic" serve

Use yarn ionic serve -- --no-interactive, maybe (not that familiar with yarn, but generally when a command wraps another command, it's convention that arguments after the -- separator get passed along, not parsed).

imhoffd avatar Aug 02 '17 01:08 imhoffd

Indeed. Thank you.

bradjones1 avatar Aug 02 '17 02:08 bradjones1

@dwieeb The --no-interactive switch doesn't solve the problem that the command line behaves differently when there is a pending update.

With pending update:

$ ionic -v --no-interactive
[INFO] The Ionic CLI has an update available (3.4.0 => 3.6.0)!

[WARN] No write permissions for global node_modules--automatic CLI updates are disabled.
       To fix, see https://docs.npmjs.com/getting-started/fixing-npm-permissions
       
       Or, install the CLI update manually (you will likely need sudo):
       
       npm install -g ionic@latest
       
3.4.0 

Without pending update:

$ ionic -v --no-interactive
3.4.0

Is there another switch to prevent the pending update message from being shown?

danielflippance avatar Aug 02 '17 19:08 danielflippance

@danielflippance Yes, that behavior is in 3.6.0. You have to update.

imhoffd avatar Aug 02 '17 23:08 imhoffd

This is very frustrating! And this has already crashed my Ionic installation twice when I said "Y". Had to go through the pain of installing - removing-installing everything from scratch and lost 1.5 days in the process.

I keep getting prompts as below for each and every ionic command:

? The Ionic CLI (local version) has an update available (3.6.0 => 3.7.0)! Would
[INFO] Not automatically updating your CLI. You can update manually:

       npm install --save-dev --save-exact ionic@latest

? Local plugin @ionic/cli-plugin-cordova has an update available (1.5.0 => 1.6.
[INFO] Not automatically updating @ionic/cli-plugin-cordova. You can update manually:

       npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest

? Local plugin @ionic/cli-plugin-ionic-angular has an update available (1.4.0 =
[INFO] Not automatically updating @ionic/cli-plugin-ionic-angular. You can update manually:

       npm install --save-dev --save-exact @ionic/cli-plugin-ionic-angular@latest

[OK] Generated a page named about!

How do I disable it once and for all? I will update my installation as I need it, when I need it. :(

Thanks.

paragw09ckp avatar Aug 03 '17 19:08 paragw09ckp

@paragw09ckp ionic config set -g daemon.updates false

Perhaps you can expand upon "crashed my Ionic installation" so I can assist you?

imhoffd avatar Aug 03 '17 23:08 imhoffd

Thanks @dwieeb for the response and providing the command to disable this annoying thing, especially when I have my deadlines to meet. Very much appreciated! I will finish my current task's delivery before running the command. Not confident of taking a chance to run a command and again spend time on fixing things.

I had created a post on Ionic Forum to get some help. Here is the link to it. I would request you to please go through my posts in it to get the exact information and the reason of my frustration. I can certainly type it all here, and please do let me know if you prefer that, but I thought it would help you go through what people think. And why one of the reason they go for tools like "nvm". I am no expert but I took their comments, among other things, as they want to avoid this prompt as well.

In a nutshell, it messes up my Ionic installation in such a way that the "ionic" command itself is not recognized. Then when I reinstall Ionic it starts complaining about my project dependencies. So I reinstall the dependencies. And in that process the "npm" starts giving problems for one or the other library. So I install "npm", delete package-lock.json, delete that library from "node_modules", install the library again and so on.

I would think that not everybody wants to update their Ionic and other things in the middle of their project. If that's the case by any chance then why force it all the time an Ionic command is executed? It would have been great if along with Y/n, a third option to "ignore for XX number of days" was given.

paragw09ckp avatar Aug 04 '17 06:08 paragw09ckp

+1 this is the worst. I can't conceive of anyone actually wanting to update while in the middle of a build. The default behavior should be to give us a notification that an update exists, not prompt us to install and not force us to add yet another thing to the build command.

KindTech avatar Aug 04 '17 07:08 KindTech

@paragw09ckp Please understand that Ionic is built on top of a great number of technologies. None of the errors in that forum topic are a result of a problem with the Ionic CLI. You mentioned you are new to Node and npm. The issues you expressed are common and well-known, and all due to the Node and npm environment. These tools are mostly new and now have massive adoption. nvm is just a tool to manage multiple node installations while not requiring any administrative privileges, which is not the default for node on windows or linux. Node environments can get messed up by simply installing a package. (npm install now reads package.json and package-lock.json and tries to reconcile the node_modules folder structure, sometimes making mistakes.) Since these update prompts simply install packages, people who are new to Node/npm blame them for messing up their project. The exact same thing would happen if you ran npm install without the prompt that generates the command for you. I saw no evidence that @janpio or @rapropos wanted to avoid the prompts in that forum topic. Even if they did, there's an easy way to disable them.

With how volatile and fast-paced the Node/npm community is right now, we decided to add the prompts to ensure devs keep their toolkit up to date. This is essentially our only choice right now. Countless issues are opened in this repo because people have packages that are out of date.

The behavior will be this soon: if you respond N to the prompt, it will skip the rest of the prompts and not ask again for a week.

@KindTech When we started CLI v3 we weren't sure how many plugins there would end up being. As of now, for an Ionic1/Cordova project, there are four (five if using a proxy) packages that would need to be updated individually. If this wasn't automated, people wouldn't type out all the stupid update commands and we'd get issues all the time. I am working on a branch that removes the need for plugins, thus making this update process simpler inherently. Please trust me that how it works right now is purposeful, was done for good intentions, and will be made better in the future. You can disable the functionality completely with the config command I supplied above.

imhoffd avatar Aug 04 '17 18:08 imhoffd

I just want to second that nvm-windows was indeed suggested here as the error messages showed a deeper misconfiguration/problem with npm (which is quite common and hard to avoid when it is installed with the defaults). As our goal is to get people to be able to work again, we offer the nvm-windows solutions as one that takes a bit of work, but then really fixes the underlying issue for people. (Alternatively we could try to start debugging file permissions on Windows which never ends well).

janpio avatar Aug 04 '17 18:08 janpio

I'm even doing proper file permission checks: https://github.com/ionic-team/ionic-cli/blob/master/packages/cli-utils/src/lib/plugins.ts#L334 Windows just isn't having any of it for some systems, apparently.

imhoffd avatar Aug 04 '17 21:08 imhoffd

Yeah, the problem is npmnot being able to access some stuff randomly and then imploding. Having the npm internal dirs in a non-priviledged directory (not "Program Files") via nvm seems to help. I stopped trying to understand.

janpio avatar Aug 04 '17 22:08 janpio

The behavior will be this soon: if you respond N to the prompt, it will skip the rest of the prompts and not ask again for a week.

That's all I needed! Thank you @dwieeb ! However, I liked @KindTech 's idea better.

I did understand your explanation about the errors I got and lost 1.5 days. Having said that, to me, I was in the middle of my Ionic development and project completion and a prompt in it caused me to loose important and critical time. Hope you get my point of view.

paragw09ckp avatar Aug 07 '17 23:08 paragw09ckp

Looks like this behaviour breaks CI pipes - I can no longer automate Docker image builds because --no-interactive doesn't do anything.

# ionic --version --quiet --no-interactive
[ANNOUNCE] Hi! Welcome to CLI 3.9.

           We decided to merge core plugins back into the main ionic CLI package. The @ionic/cli-plugin-ionic-angular,
           @ionic/cli-plugin-ionic1, @ionic/cli-plugin-cordova, and @ionic/cli-plugin-gulp plugins have all been
           deprecated and won't be loaded by the CLI anymore. We listened to devs and determined they added unnecessary
           complexity. You can uninstall them from your project(s).

           No functionality was removed and all commands will continue working normally. You may wish to review the
           CHANGELOG: https://github.com/ionic-team/ionic-cli/blob/master/CHANGELOG.md#changelog

           Thanks,
           The Ionic Team



? The Ionic CLI can automatically check for CLI updates in the background. Would you like to enable this? (Y/n)

Am I executing this command incorrectly?

I see the stuff about the CI env vars, and sadly setting export CI=TRAVIS doesn't prevent this either.

Edit: spoke too soon! Adding the CI environment variable totally does work. It spits out the welcome message still, but there are no prompts.

emcniece avatar Aug 18 '17 04:08 emcniece