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

ENOENT: no such file or directory, realpath '...' #2783

Closed
jhendrixMSFT opened this issue Jan 9, 2024 · 16 comments · Fixed by #2797
Closed

ENOENT: no such file or directory, realpath '...' #2783

jhendrixMSFT opened this issue Jan 9, 2024 · 16 comments · Fixed by #2797
Assignees

Comments

@jhendrixMSFT
Copy link
Member

jhendrixMSFT commented Jan 9, 2024

Note that this might be Windows-specific as the issue didn't repro on macOS (haven't tried Linux).

Execute the following command (fix up directories as required).

tsp compile C:/git/Azure/autorest.go/packages/typespec-go/node_modules/@azure-tools/cadl-ranch-specs/http/client/structure/default/main.tsp --emit=C:/git/Azure/autorest.go/packages/typespec-go/ --option="@azure-tools/typespec-go.module=defaultgroup" --option="@azure-tools/typespec-go.emitter-output-dir=C:/git/Azure/autorest.go/packages/typespec-go/test/cadlranch/client/structure/defaultgroup" --option="@azure-tools/typespec-go.file-prefix=zz_"

Produced error.

[Error: ENOENT: no such file or directory, realpath 'C:/git/Azure/autorest.go/common/temp/node_modules/.pnpm/@azure-tools+cadl-ranch-specs@0.26.2_@azure-tools+cadl-ranch-expect@0.9.0_@azure-tools+typesp_6mmb4jnmojqwtbe6z5fh4mcmqi/node_modules/@azure-tools/cadl-ranch-specs/http/client/structure/common/service.tsp'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'realpath',
  path: 'C:/git/Azure/autorest.go/common/temp/node_modules/.pnpm/@azure-tools+cadl-ranch-specs@0.26.2_@azure-tools+cadl-ranch-expect@0.9.0_@azure-tools+typesp_6mmb4jnmojqwtbe6z5fh4mcmqi/node_modules/@azure-tools/cadl-ranch-specs/http/client/structure/common/service.tsp'
}
@timotheeguerin
Copy link
Member

Not really reproducing this error, I get a different one if I run from the root because it the compiler loaded is different from the one used to compile the file which is kinda expected if you don't have a compiler there. If I run from the typespec-go directory it works fine.

@jhendrixMSFT
Copy link
Member Author

On Windows? I reran my repro steps using the compiler from node_modules and I still see this error.

C:\Users\jhendrix\autorest.go\packages\typespec-go\node_modules\@typespec\compiler\node_modules\.bin\tsp.cmd compile C:/Users/jhendrix/autorest.go/packages/typespec-go/node_modules/@azure-tools/cadl-ranch-specs/http/client/structure/default/main.tsp --emit=C:/Users/jhendrix/autorest.go/packages/typespec-go/ --option="@azure-tools/typespec-go.module=defaultgroup" --option="@azure-tools/typespec-go.emitter-output-dir=C:/Users/jhendrix/autorest.go/packages/typespec-go/test/cadlranch/client/structure/defaultgroup" --option="@azure-tools/typespec-go.file-prefix=zz_"
TypeSpec compiler v0.50.0

Internal compiler error!
File issue at https://github.com/microsoft/typespec

[Error: ENOENT: no such file or directory, realpath 'C:/Users/jhendrix/autorest.go/common/temp/node_modules/.pnpm/@azure-tools+cadl-ranch-specs@0.26.2_@azure-tools+cadl-ranch-expect@0.9.0_@azure-tools+typesp_6mmb4jnmojqwtbe6z5fh4mcmqi/node_modules/@azure-tools/cadl-ranch-specs/http/client/structure/common/service.tsp'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'realpath',
  path: 'C:/Users/jhendrix/autorest.go/common/temp/node_modules/.pnpm/@azure-tools+cadl-ranch-specs@0.26.2_@azure-tools+cadl-ranch-expect@0.9.0_@azure-tools+typesp_6mmb4jnmojqwtbe6z5fh4mcmqi/node_modules/@azure-tools/cadl-ranch-specs/http/client/structure/common/service.tsp'
}
PS C:\Users\jhendrix\autorest.go> dir C:/Users/jhendrix/autorest.go/common/temp/node_modules/.pnpm/@azure-tools+cadl-ranch-specs@0.26.2_@azure-tools+cadl-ranch-expect@0.9.0_@azure-tools+typesp_6mmb4jnmojqwtbe6z5fh4mcmqi/node_modules/@azure-tools/cadl-ranch-specs/http/client/structure/common/service.tsp

    Directory: C:\Users\jhendrix\autorest.go\common\temp\node_modules\.pnpm\@azure-tools+cadl-ranch-specs@0.26.2_@azure
-tools+cadl-ranch-expect@0.9.0_@azure-tools+typesp_6mmb4jnmojqwtbe6z5fh4mcmqi\node_modules\@azure-tools\cadl-ranch-spec
s\http\client\structure\common

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---            1/9/2024 10:57 AM           2293 service.tsp

@timotheeguerin
Copy link
Member

timotheeguerin commented Jan 9, 2024

ah no I am testing on OSX(missed your message :)) , is this happening for anything else or just that spec? What version of node are you using too?

@jhendrixMSFT
Copy link
Member Author

It's all the ones under client/structure. Likely due to import "../common/service.tsp";

@timotheeguerin
Copy link
Member

It is very weird because it does say it cannot find that path but you clearly have it.

Could it be related to this issue on node? nodejs/node#39721 could you try a different node version?

@jhendrixMSFT
Copy link
Member Author

I was on v18.17.1 which I believe has this fix. At any rate, migrated to v20.10.0 and the problem persists.

@daviwil
Copy link
Contributor

daviwil commented Jan 10, 2024

I'm also seeing this in a separate Rush repo I set up for the Liftr team. For some reason the realpath call chokes on a package path installed by pnpm:

Internal compiler error!
File issue at https://github.com/microsoft/typespec

[Error: ENOENT: no such file or directory, realpath 'C:/dev/LiftrBaseApiSpec/common/temp/node_modules/.pnpm/@azure-tools+typespec-azure-resource-manager@0.37.0_@azure-tools+typespec-autorest@0.37.2_@az_of5ylnj7zzloalyzod4joyjm7q/node_modules/@azure-tools/typespec-azure-resource-manager/lib/private.decorators.tsp'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'realpath',
  path: 'C:/dev/LiftrBaseApiSpec/common/temp/node_modules/.pnpm/@azure-tools+typespec-azure-resource-manager@0.37.0_@azure-tools+typespec-autorest@0.37.2_@az_of5ylnj7zzloalyzod4joyjm7q/node_modules/@azure-tools/typespec-azure-resource-manager/lib/private.decorators.tsp'
}

The weird thing is that the file definitely exists, but even PowerShell gets tripped up on it:

PS C:\dev> ls .\LiftrBaseApiSpec\common\temp\node_modules\.pnpm\@azure-tools+typespec-azure-resource-manager@0.37.0_@azure-tools+typespec-autorest@0.37.2_@az_of5ylnj7zzloalyzod4joyjm7q\node_modules\@azure-tools\typespec-azure-resource-manager\lib\


    Directory: C:\dev\LiftrBaseApiSpec\common\temp\node_modules\.pnpm\@azure-tools+typespec-azure-resource-manager@0.37
    .0_@azure-tools+typespec-autorest@0.37.2_@az_of5ylnj7zzloalyzod4joyjm7q\node_modules\@azure-tools\typespec-azure-re
    source-manager\lib


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         1/10/2024   4:30 PM          23869 arm.foundations.tsp
-a----         1/10/2024   4:30 PM           1054 arm.tsp
-a----         1/10/2024   4:30 PM            320 common-types.tsp
-a----         1/10/2024   4:30 PM           3130 customer-managed-keys.tsp
-a----         1/10/2024   4:30 PM           6222 decorators.tsp
-a----         1/10/2024   4:30 PM          16350 interfaces.tsp
-a----         1/10/2024   4:30 PM           9947 models.tsp
-a----         1/10/2024   4:30 PM          16853 operations.tsp
-a----         1/10/2024   4:30 PM           4730 parameters.tsp
-a----         1/10/2024   4:30 PM           5960 private-links.tsp
-a----         1/10/2024   4:30 PM           2440 private.decorators.tsp
-a----         1/10/2024   4:30 PM           3800 responses.tsp


PS C:\dev> ls .\LiftrBaseApiSpec\common\temp\node_modules\.pnpm\@azure-tools+typespec-azure-resource-manager@0.37.0_@azure-tools+typespec-autorest@0.37.2_@az_of5ylnj7zzloalyzod4joyjm7q\node_modules\@azure-tools\typespec-azure-resource-manager\lib\private*


    Directory: C:\dev\LiftrBaseApiSpec\common\temp\node_modules\.pnpm\@azure-tools+typespec-azure-resource-manager@0.37
    .0_@azure-tools+typespec-autorest@0.37.2_@az_of5ylnj7zzloalyzod4joyjm7q\node_modules\@azure-tools\typespec-azure-re
    source-manager\lib


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         1/10/2024   4:30 PM           5960 private-links.tsp
ls : Could not find item C:\dev\LiftrBaseApiSpec\common\temp\node_modules\.pnpm\@azure-tools+typespec-azure-resource-ma
nager@0.37.0_@azure-tools+typespec-autorest@0.37.2_@az_of5ylnj7zzloalyzod4joyjm7q\node_modules\@azure-tools\typespec-az
ure-resource-manager\lib\private.decorators.tsp.
At line:1 char:1
+ ls .\LiftrBaseApiSpec\common\temp\node_modules\.pnpm\@azure-tools+typ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\dev\LiftrBas....decorators.tsp:String) [Get-ChildItem], IOException
    + FullyQualifiedErrorId : ItemNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand



PS C:\dev>

Is pnpm somehow creating some files with weird attributes that cause this issue?

@timotheeguerin
Copy link
Member

Interesting, what version of Pnpm are you using and with rush do you use the workspace setting?

@jhendrixMSFT
Copy link
Member Author

Was on pnpm 8.11.0, upgraded to 8.14.1 but the issue persists. Am using workspace.

@jhendrixMSFT
Copy link
Member Author

This appears to be a MAX_PATH problem and is likely nodejs/node#50753

@daviwil
Copy link
Contributor

daviwil commented Jan 10, 2024

PS C:\dev\LiftrBaseApiSpec> rush update

Rush Multi-Project Build Tool 5.108.0 - https://rushjs.io
Node.js version is 20.10.0 (LTS)


Starting "rush update"

Trying to acquire lock for pnpm-8.6.12

Where would I check for the workspace setting?

@timotheeguerin
Copy link
Member

I think David the issue is just long path on windows there seems to be a recent fix in node that hasn’t been released

@daviwil
Copy link
Contributor

daviwil commented Jan 10, 2024

Weird that PowerShell hits the same issue outside of Node, though. Will the fix prevent pnpm from creating such a long path?

@timotheeguerin
Copy link
Member

timotheeguerin commented Jan 10, 2024

Well it seems like Pnpm is working fine, windows on the other hand still can’t get that working correctly so not surprised powershell neither

and this only happens with the promise version, works with the sync and the .native async (whatever that is) so maybe pnpm is just using one of those 2

@timotheeguerin
Copy link
Member

@daviwil
Copy link
Contributor

daviwil commented Jan 17, 2024

See also: pnpm/pnpm#7355

I also tried using the pnpm setting node-linker=hoisted to get pnpm to install to a flat node_modules folder like npm does but for some reason TypeSpec can no longer resolve module paths at all:

https://pnpm.io/npmrc#node-linker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants