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

[BUG] msbuild /t:GenerateCode fails when your username has a space in it. #11745

Closed
ellismg opened this issue May 1, 2020 · 1 comment
Closed
Labels
Client This issue points to a problem in the data-plane of the library. CodeGen Issues that relate to code generation

Comments

@ellismg
Copy link
Member

ellismg commented May 1, 2020

Running msbuild /t:GenerateCode to generate code for a client library using AutoRest fails on windows when your username has a space in it. This appears to be related to how npx interacts with NPM when the cache directory includes a space in it. By default, the cache directory is %AppData%\npm-cache on Windows, so I suspect this will hit anyone who has a space in their username.

When trying to run the target, npx will fail, with an EPERM error like this:

Task "Exec"
  npx autorest@https://github.com/Azure/autorest/releases/download/autorest-3.0.6221/autorest-3.0.6221.tgz --version=3.0.6280 C:\dd\azure\azure-sdk-for-net\sdk\template\Azure.Template\src/autorest.md  --use=https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200415.7/autorest-csharp-v3-3.0.0-dev.20200415.7.tgz --output-folder=C:\dd\azure\azure-sdk-for-net\sdk\template\Azure.Template\src --title=Azure.Template --namespace=Azure.Template --shared-source-folder=C:\dd\azure\azure-sdk-for-net\eng\../sdk/core/Azure.Core/src/Shared/ --verbose
EXEC : error : EPERM: operation not permitted, mkdir 'C:\Users\Matt' [C:\dd\azure\azure-sdk-for-net\sdk\template\Azure.Template\src\Azure.Template.csproj]
  command not found: autorest
C:\dd\azure\azure-sdk-for-net\eng\CodeGeneration.targets(24,5): error MSB3073: The command "npx autorest@https://github.com/Azure/autorest/releases/download/autorest-3.0.6221/autorest-3.0.6221.tgz --version=3.0.6280 C:\dd\azure\azure-sdk-for-net\sdk\template\Azure.Template\src/autorest.md  --use=https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200415.7/autorest-csharp-v3-3.0.0-dev.20200415.7.tgz --output-folder=C:\dd\azure\azure-sdk-for-net\sdk\template\Azure.Template\src --title=Azure.Template --namespace=Azure.Template --shared-source-folder=C:\dd\azure\azure-sdk-for-net\eng\../sdk/core/Azure.Core/src/Shared/ --verbose" exited with code 1. [C:\dd\azure\azure-sdk-for-net\sdk\template\Azure.Template\src\Azure.Template.csproj]
Done executing task "Exec" -- FAILED.

To work around this issue, you can explicitly set your cache location using npm, to include a path that uses the corresponding 8.3 short file name:

> npm config set cache "C:\Users\MATTG~1.ELL\AppData\Roaming\npm-cache" --global

Alternately, we could change our invocation of the npx to set the NPM_CONFIG_CACHE environment variable to something like $(TEMP)/npm-cache (perhaps scoped to the case where you're on windows and %AppData% contains a space?). It appears that when your username contains a space, %TEMP% uses the 8.3 version of your username.

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label May 1, 2020
@jsquire jsquire added the CodeGen Issues that relate to code generation label May 2, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label May 2, 2020
@jsquire jsquire added the Client This issue points to a problem in the data-plane of the library. label May 2, 2020
@pakrym
Copy link
Contributor

pakrym commented May 2, 2020

Original issue zkat/npx#100 / npm/npx#48

@MiYanni MiYanni removed their assignment Jun 26, 2020
@pakrym pakrym removed their assignment Jan 25, 2022
@pallavit pallavit closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. CodeGen Issues that relate to code generation
Projects
None yet
Development

No branches or pull requests

5 participants