Azure-pipelines-tasks: vsts-npm-auth Creates .npmrc in Wrong Location When $HOME is on a Network Drive

Created on 6 Aug 2018  路  10Comments  路  Source: microsoft/azure-pipelines-tasks

Environment

  • Server - VSTS

Issue Description

When running vsts-npm-auth from a user that has their profile home on a network drive (e.g. U:\), the program creates an .npmrc file in the user's home directory (i.e. U:\.npmrc). However, NPM does not recognise the network share, and uses C:\Users\username as the user's home directory (taken from npm config ls). This results in package installations failing as NPM does not use the authentication token from the incorrectly placed .npmrc file.

A possible solution would be to check the userconfig value from the output of npm config ls -l, and use this as the location of the config file.

ArtifactsPackages bug

Most helpful comment

@Waddlen
Our team has the same issue. We have worked around this by using the -TargetConfig parameter during our machine setup.

vsts-npm-auth -config .npmrc -TargetConfig "%USERPROFILE%\.npmrc"

All 10 comments

This happens because npm uses the USERPROFILE environment variable, while vsts-npm-auth uses %HOMEDRIVE% + %HOMEPATH%.

Not sure if this is a bug in npm or a bug in vsts-npm-auth, but either one will need to fix it.

Hello! I'm a PM over on the Azure Artifacts team. I wanted to drop in here and address some of these issues with the news that we're currently reevaluating the types of tasks we offer in Azure Pipelines, and looking to focus more on lighter-weight tasks that cover authentication and setup. In lieu of the task redesign, we're going to forego making changes to the current tasks (with a few exceptions). We hope the new tasks we spin up in the next quarter or so are easier and more helpful, be on the lookout!

@zjrunner adding you as an FYI to consider the comment from @Wazner when rethinking the auth tasks.

Had this issue on the machine of colleague. Changing the HOMEPATH to C: and running the command again worked.

Just ran into this bug. It鈥檚 not clear why it鈥檚 closed. I see there is a workaround to change HOMEPATH but for me that鈥檚 set by group policy

I have this bug too, I commented on the issue @orbita84 mentions.

This should not be closed. It is a very real bug and is very confusing to debug. The instructions on Azure Devops do not mention this either. Horrible workarounds like manually copying a file are not helpful and don't make the world a better place. Presumably npm is doing the correct thing because it is NPM so please can we fix this to behave the same way?

This caused a huge amount of confusion for a team member who got a new computer recently. Our IT has our Windows machines set up to use a network home drive (H:), and running vsts-npm-auth by following the steps outlined on Azure DevOps did not work. Hours of troubleshooting later and we found that we could just copy the .npmrc it generated to the c:\users\ and everything works as expected. It would be wonderful if this found the home folder the same way npm does.

@elbatk Please consider reopening this bug. It affects more than just the azure pipeline task for vsts-npm-auth.

@elbatk We just hit an issue where a team member's IT-issued computer was configured with a near-empty U:\ as the HOMEDRIVE, and when they tried to run vsts-npm-auth -config .npmrc in C:\Users\PERSON\source\repos\PROJECT\CLIENT\ he got:

vsts-npm-auth v0.41.0.0
-----------------------
Could not find a part of the path 'U:\'.

We ended up copying the .npmrc to his U:\ drive and running the command there, which completed successfully. However, after that, he still had to copy-paste the new .npmrc with the password to C:\Users\PERSON\ for it to work.

The Azure docs still suggest using vsts-npm-auth, are the new tools you mentioned available yet?

@Waddlen
Our team has the same issue. We have worked around this by using the -TargetConfig parameter during our machine setup.

vsts-npm-auth -config .npmrc -TargetConfig "%USERPROFILE%\.npmrc"
Was this page helpful?
0 / 5 - 0 ratings