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

"ng update" doesn't support private repos such as FontAwesome 5 Pro

Open bjornharvold opened this issue 8 years ago • 172 comments

Versions

Angular CLI: 6.0.0
Node: 9.11.1
OS: darwin x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

  • Add dependency on a private repo such as FontAwesome 5 Pro
  • Run ng update @angular/core

Observed behavior

Not found : @fortawesome/pro-regular-svg-icons

Mention any other details that might be useful (optional)

This works fine using npm directly because the private repo has already been registered with npm

bjornharvold avatar May 04 '18 02:05 bjornharvold

This is not only a problem with private repos but in my case also a problem with dependencies from git repos (so not npm based)

Update: after upgrading to 7.2.0-beta.1 message slightly changed but issue persist:

➜  ng update @angular/core
404 Not Found - GET https://registry.npmjs.org/my-private-package-here - Not found

alex88 avatar Dec 10 '18 05:12 alex88

With @next We get the message request to https://registry.npmjs.org/@types%2fjasmine failed, reason: connect ETIMEDOUT

It seems that ng update @angular/cli ignores the proxy since it should go to the proxy or https-proxy instead of npmjs.org.

Should the command be ng update @angular/cli@next? (Results in same error message)

daniel-seitz avatar Dec 10 '18 10:12 daniel-seitz

@alex88 @daniel-seitz You two are aware that we cannot help you if you do not describe your situation adequately enough.

For starters, post your .npmrc. Mention if you have an .npmrc in your home directory and/or in your project root folder.

Mask out the portions you DO NOT want us to know, like internal host names or credentials etc. Just give enough pieces of information.

catull avatar Dec 10 '18 15:12 catull

@catull thanks for clarifying. I thought we're on the same page already.

  1. we use yarn.
  2. local .npmrc: registry=[some url, masked out] always-auth=true
  3. yarn lock contains packages where I see some as resolved with [some url, masked out] also there are packages with https://registry.yarnpkg.com/some-package-and-so-on
  4. global .yarnrc (in C:\Users\MyUserName):
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lastUpdateCheck 1543945019859
  1. global .npmrc (in C:\Users\MyUserName):
//some_path_with_some_token
proxy= http://our_proxy_with_port/
https-proxy= http://our_proxy_with_port
  1. trying to follow commands from update.angular.io
  2. everything else works but not ng update @angular/cli, message comes up after a while (1 minute or so): request to https://registry.npmjs.org/@types%2fjasmine failed, reason: connect ETIMEDOUT seems to be on a random package, at another try I got: request to https://registry.npmjs.org/codelyzer failed, reason: connect ETIMEDOUT [some ip address and port]
  3. currently still running angular 5.1.1
  4. tried as described with @next option in yarn global add @angular/cli@next and yarn add @angular/cli@next
  5. ng --version:
     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.2.0-beta.1
Node: 8.12.0
OS: win32 x64
Angular: 5.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.12.0-beta.1
@angular-devkit/core         7.2.0-beta.1
@angular-devkit/schematics   7.2.0-beta.1
@angular/cli                 7.2.0-beta.1
@angular/language-service    4.4.6
@schematics/angular          7.2.0-beta.1
@schematics/update           0.12.0-beta.1
rxjs                         5.5.3
typescript                   2.4.2

daniel-seitz avatar Dec 10 '18 17:12 daniel-seitz

@catull well .npmrc isn't used when having a git dependency. it's just a line like this:

"my-package": "git+ssh://[email protected]:my-package.git#master"

in the package.json. No package repo is involved.

alex88 avatar Dec 10 '18 17:12 alex88

@alex88

I can reproduce your behaviour, I think.

I have no .npmrc in my home directory - I renamed it to .npmrc.old,

I have created a brand-new angular app "foo", there is no .npmrc in that project folder. In that folder, I can perform ng upgrade, no error is reported.

Then I added this dependency:

    "@streamlabs/obs-studio-node": "git+ssh://[email protected]:computerquip/obs-studio-node#staging",

Now, when I perform ng update, the result is ....

➜  foo git:(master) ✗ ng update
404 Not Found - GET https://registry.npmjs.org/@streamlabs%2fobs-studio-node - Not found

This is pretty much what you experience, with a different dependency.

ng fails in calculating the dependency graph for the newly introduced "@streamlabs/obs-studio-node".

I also tried with ng update --registry=https://registry.npmjs.org or ng update --registry https://registry.npmjs.org.

The result is the same as with ng update.

It is true that you have already fetched it once via npm install / yarn install.

However, ng is detecting whether your/my extra dependency out of date. Let's just assume you have version x.N.y in your workspace.

ng sees that; but there could be version x.(N+1).0 or x.N.(y+1) available on a remote registry. ng must find out if this is the case.

Your statement that "No package repo is involved." does not hold. It very much is involved, the repository. Just not the correct one ...

ng update blindly looks for the package on npmjs.org, rather than on gitlab.com.

It finds all the other packages - I proved it with a fresh app having all dependent packages on registry.npmjs.org.

catull avatar Dec 10 '18 21:12 catull

@daniel-seitz

Your situation is that you do not get a proxy'd connection, it times out. Are you certain you have the correct port configuration, that it is not blocked by a firewall ?

Perhaps that proxy may only be used for "normal" HTTP ("browser") requests ...

To address your point 7, each package is equally affected, there is no guarantee that the packages are processed top to bottom.

Imagine ng fires off 20 requests asynchronously, the first one that times out is reported and ng errors out. Once it is the 7th, next time is is the 13th, and then it is the 4th alphabetically. Which one of those 20 it is, is entirely "random".

My best guess is: the proxy configuration is not correct.

Are you sure you need a proxy configuration ?

Unless it is a typo, I find it suspicious that you use a "http" proxy value for "https" for starters.

Can you exclude the fact that neither HTTP_PROXY, HTTPS_PROXY, http_proxy nor https_proxy environment variables are set. Neither http_proxy / https_proxy shell variables are set, either.

catull avatar Dec 10 '18 22:12 catull

I think this ticket can be closed.

Why ?

The original issue is that ng update does not support private repositories such as FontAwesome PRO.

That issue is resolved. Now even environment variables (say for TOKENs to be used in build servers) are supported.

Other issues reported are

  • @alex88 - ng does not honour gitlab specific URI
  • @daniel-seitz's timeout is a different issue. I am not sure there is a private repo involved here.

These two issues must be dealt with separately, IMHO.

@Albyzai has not stated where the private repo is at.

catull avatar Dec 10 '18 22:12 catull

@catull probably it won't handle any other git repository right? Like gitlab/github/bitbucket/aws codecommit and many others...

alex88 avatar Dec 10 '18 22:12 alex88

@alex88 Your repo URL ...

"my-package": "git+ssh://[email protected]:my-package.git#master"

should it not be

"my-package": "git+ssh://[email protected]:>>>>USERNAME/<<<<<<my-package.git#master"

Compare this to my example:

"@streamlabs/obs-studio-node": "git+ssh://[email protected]:>>>>>>computerquip/<<<<<<obs-studio-node#staging",

catull avatar Dec 10 '18 22:12 catull

@catull yes it's actually username/repo, I just wanted to remove also that part, sorry for the confusion

alex88 avatar Dec 10 '18 22:12 alex88

No worries, just wanted to exclude another explanation ....

catull avatar Dec 10 '18 22:12 catull

@alex88 Have you considered using scoped package naming [1] ?

See, this is a snippet of my .npmrc:

@XXXXXXXXXX:registry=https://artifactory.YYYYYYYYYY:443/artifactory/api/npm/npm-virtual/

@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=${NPM_TOKEN_FONTAWESOME}

You could have

    "my-package": "git+ssh://[email protected]:@YOUR_SCOPE/my-package.git#master"

As long as the package is published with @YOUR_SCOPE - could be @YOUR_ORGANISATION.

It works for FontAwesome. They use the scope name @fortawesome - yeah, "FORT awesome", not "FONT awesome".

Side note: You and I both know that "forte" in colloquial Italian means "awesome" in colloquial American English; my eye reads it as "awesome awesome" -> Super-awesome!

FontAwesome's repository is not the canonical from npmjs.org Yet npm, yarn and most importantly ng all retrieve it from the right place.

Buona fortuna!

[1] https://docs.npmjs.com/misc/scope

catull avatar Dec 10 '18 22:12 catull

@daniel-seitz

Perhaps you are right.

Assuming the http proxy config works for, say, the initial npm install. If that is the case, your issue is that ng update ignores the proxy configuration. Then I apologise, my analysis above would be incorrect.

However, it is a different case from the original posting.

I suggest you open a new issue with exactly the the title "ng update ignores proxy config." I do not have a setup which requires a proxy configuration, so I cannot assist you, sorry.

catull avatar Dec 10 '18 23:12 catull

@catull haha for the side note 🤣 Sometimes I read it as awesome-awesome and sometimes if feels like a typo 😆

Anyway, that would involve having our own registry or paying for a private hosted on if I understand it correctly, I think that for now I'll just remove that dependency, upgrade to angular 7 and add it back 😄

Hate to do that but having our own means more maintenance/resources and the other option would be adding another cost. You probably also know how much Italian companies can be stingy 😄

Btw, thanks for the option, if it's something we need to support in long term that's definitely an option to look for!

alex88 avatar Dec 10 '18 23:12 alex88

@alex88

On the scoped naming, the cost you incur is operating an NPM registry.

See open source alternatives below, "verdaccio" [1] and "bitsrc.io" [2]. I believe there are docker images for both of them. At one point, "sinopia" was actively developed, but it has not been updated for more than 3 years.

Imagine this.

Let's just assume for a moment I like a certain library/package.

Let's say it is called banana; the original npm package would be available at https://www.npmjs.com/package/banana.

So, one day I decide to considerably change it, but the original maintainer is a) not around, the e-mail she is using is invalid by now b) the maintainer is not interested in your changes c) the package is not maintained any more, and maintainership cannot be transferred to you

Now in this case, banana was last updated 7 years ago. But that is beside the point.

Given the fact that I like banana, I can create a fork of it. I will NOT be able to publish it at https://www.npmjs.com/package/banana.

But I will be able to publish it say, as https://www.npmjs.com/package/@catull/banana. Then it would be public.

But let's also assume my company operates an internal NPM repository at registry.my-company.net:8080/npm/.

Now I can publish it at https://registry.my-company.net:8080/npm/@SOME_SCOPE/banana

You have to publish it with --scope @SOME_SCOPE. Otherwise you would publish it at https://registry.my-company.net:8080/npm/banana

But here is the beauty: the scope name can be specifically configured in .npmrc. It is recognised by all tools equally: npm, yarn and ng.

You can see a good example with bootstrap-vue:

[1] verdaccio [2] bitsrc.io

catull avatar Dec 10 '18 23:12 catull

@catull thanks a lot for the long explanation, I'll keep in mind, surely it's better than fetching from git directly 😄

alex88 avatar Dec 10 '18 23:12 alex88

@catull thank you, originally i had the same issue as the topic here and this is indeed now resolved. I'll open another issue as suggested, btw. yarn commands work, just the ng update doesnt. I tried migrate only - which works - and then update the packages via yarn, also works. I just think that I might miss something that ng update does as well, other than migrating to the angular.json file and lifting the packages to the recent version. ciao

daniel-seitz avatar Dec 11 '18 08:12 daniel-seitz

I really wonder why fontawesome pro works with 7.1.0 but fails with 7.1.1 and 7.1.2 It's a bit sad to see that newer version break again. I hope this can be finally fixed soon.

DaSchTour avatar Dec 11 '18 22:12 DaSchTour

I've same problem. "ng update --all" doesn't works with 7.1.2 (and 7.1.0 also) with private registry configured into local ".npmrc". @angular/cli while try to found package on registry.npmjs.org:

404 Not Found - GET https://registry.npmjs.org/mypackage - Not found

But into .npmrc i've : registry=https://privaterepo.mycompagnie.fr/npm/

Chklang avatar Dec 12 '18 15:12 Chklang