[NPMCLI-206] mgnl jumpstart not working behind proxy Created: 08/Feb/19  Updated: 03/Jul/19  Resolved: 20/May/19

Status: Closed
Project: Magnolia CLI
Component/s: None
Affects Version/s: 3.0.5, 3.0.6, 3.0.7
Fix Version/s: 3.1.0

Type: Bug Priority: Major
Reporter: Tejas Assignee: Dai Ha
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 3d 6.5h
Original Estimate: Not Specified

Attachments: PNG File image-2019-02-08-20-25-00-044.png    
Issue Links:
Relates
relates to NPMCLI-207 jumpstart STILL fails when behind proxy Closed
supersession
supersedes NPMCLI-196 Replace axios-https-proxy-fix again w... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: Support
Sprint: Features 11
Story Points: 5

 Description   



 Comments   
Comment by Christopher Zimmermann [ 21/Feb/19 ]

tejaswasule Can you please upgrade to MGNL CLI v3.0.6 and let us know if this has solved your problem.

"npm update }}{{@magnolia/cli -g"

We fixed a similar issue which may solve your issue as well. (https://jira.magnolia-cms.com/browse/NPMCLI-207)

Comment by Tejas [ 18/Mar/19 ]

HI Christopher,

Updated magnolia-cli, still the sameĀ 

Comment by Christopher Zimmermann [ 18/Mar/19 ]

What version of windows?

Comment by Federico Grilli [ 18/Mar/19 ]

Hi tejaswasule the latest CLI version would be 3.0.7 (which was successfully tested under Windows 10), even though the latest changes shouldn't affect the download part which seems to be the problematic one. As far as I can gather from the screenshot above, error.response is undefined but that seems to come from the axios library we use, and checking for status there in case of error seems perfectly legit https://www.npmjs.com/package/axios-https-proxy-fix#handling-errors.

At any rate, can you please update to 3.0.7 and try again?

Comment by Jacob Raihle [ 19/Mar/19 ]

I am experiencing the same issue with version 3.0.7 on Ubuntu 18.04:

~/code/magnolia-cypress-demo/magnolia$ mgnl jumpstart
info Using configuration at /***/.nvm/versions/node/v10.14.2/lib/node_modules/@magnolia/cli/lib/config/mgnl-cli.json
info Using prototypes at /***/.nvm/versions/node/v10.14.2/lib/node_modules/@magnolia/cli/lib/config/mgnl-cli-prototypes
? What Magnolia would you like to install? magnolia-community-webapp
info No magnolia-version option provided. Will use the latest stable version.
info No path option provided. Will use the default light-modules in the current directory
ERR! Cannot read property 'status' of undefined
ERR! TypeError: Cannot read property 'status' of undefined
ERR!     at handleError (/***/.nvm/versions/node/v10.14.2/lib/node_modules/@magnolia/cli/lib/download.js:27:20)
ERR!     at axios.get.then.catch (/***/.nvm/versions/node/v10.14.2/lib/node_modules/@magnolia/cli/lib/download.js:77:5)
ERR!     at process._tickCallback (internal/process/next_tick.js:68:7)
ERR! 
ERR! 
ERR! mgnl: 3.0.7 node: v10.14.2 os: linux
ERR! please open an issue including this log on https://jira.magnolia-cms.com/browse/NPMCLI

I have set http_proxy and https_proxy environment variables, as well as proxy and https-proxy in ~/.npmrc.

Comment by Jacob Raihle [ 17/Apr/19 ]

I was able to work around this (which seems to be a problem with axios) with the following modification to magnolia cli (based on commit 855c13ff). I expect it would need fixes to work in non-proxy environments.

diff --git a/lib/download.js b/lib/download.js
index 35fe558..1fabf10 100644
--- a/lib/download.js
+++ b/lib/download.js
@@ -1,6 +1,7 @@
 const fs = require('fs-extra')
 const path = require('path')
-const axios = require('axios-https-proxy-fix')
+const axios = require('axios')
+const HttpsProxyAgent = require('https-proxy-agent')
 const ProgressBar = require('progress')
 
 const helper = require('./helper.js')
@@ -64,7 +65,9 @@ function getArtifactDetails (repository, groupId, artifactId, extension, version
     responseType: 'json',
     headers: {
       'Accept': 'application/json'
-    }
+    },
+    httpsAgent: new HttpsProxyAgent(process.env.https_proxy || process.env.HTTPS_PROXY),
+    proxy: false
   }
 
   if (credentials && credentials.username && credentials.password) {
@@ -150,7 +153,9 @@ function doDownload (repository, groupId, artifactId, extension, version, creden
   const opts = {
     method: 'get',
     responseType: 'stream',
-    auth: credentials.username && credentials.password ? credentials : null
+    auth: credentials.username && credentials.password ? credentials : null,
+    httpsAgent: new HttpsProxyAgent(process.env.https_proxy || process.env.HTTPS_PROXY),
+    proxy: false
   }
 
   const filename = `${artifactId}-${version}.${extension}`

Generated at Mon Feb 12 04:47:33 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.