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] Docfx 2.78.x requires Nodejs even when not using PDF features #10426

Closed
glb-cblin opened this issue Nov 26, 2024 · 7 comments
Closed

[Bug] Docfx 2.78.x requires Nodejs even when not using PDF features #10426

glb-cblin opened this issue Nov 26, 2024 · 7 comments
Labels
bug A bug to fix

Comments

@glb-cblin
Copy link

glb-cblin commented Nov 26, 2024

Describe the bug
With 2.78.1, we have the following error

DocfxException: Node.js executable is not found. Try to install Node.js or set the `PLAYWRIGHT_NODEJS_PATH` environment variable.                    

The same error does not occur with 2.74.1

Reproduce the bug
To execute, we are doing this in our CI (which is using image: mcr.microsoft.com/dotnet/sdk:8.0 in gitlab)

        - dotnet tool install --global docfx  
        - export PATH="${PATH}:/root/.dotnet/tools" #see https://github.com/dotnet/docfx/issues/8542        
        - docfx docfx.json

Full relevant log

$ docfx docfx.json
[...]
Creating output...
Searching built-in plugins in directory /root/.dotnet/tools/.store/docfx/2.78.1/docfx/2.78.1/tools/net8.0/any/...
No files are found with glob pattern apidoc/**.md, excluding obj/**,_site/**, under directory "/builds/xxx"
7 plug-in(s) loaded.
Building 2 file(s) in TocDocumentProcessor(BuildTocDocument)...
Building 2 file(s) in ResourceDocumentProcessor(ValidateResourceMetadata)...
Building 3 file(s) in ConceptualDocumentProcessor(BuildConceptualDocument=>ValidateConceptualDocumentMetadata)...
Building 152 file(s) in ManagedReferenceDocumentProcessor(BuildManagedReferenceDocument=>SplitClassPageToMemberLevel=>ValidateManagedReferenceDocumentMetadata=>ApplyOverwriteDocumentForMref=>FillReferenceInformation)...
/builds/xxx/index.md(7,1): warning InvalidFileLink: Invalid file link:(~/api/index.html).
/builds/xxx/index.md(9,1): warning InvalidFileLink: Invalid file link:(~/../).
Applying templates to 159 model(s)...
XRef map exported.
TypeInitializationException: The type initializer for 'Docfx.Pdf.PdfBuilder' 
threw an exception.
     DocfxException: Node.js executable is not found. Try to install Node.js or 
     set the `PLAYWRIGHT_NODEJS_PATH` environment variable.                     
       at void EnsurePlaywrightNodeJsPath() in PlaywrightHelper.cs:25           
       at cctor() in PdfBuilder.cs:53                                           
  at Task CreatePdf(string outputFolder)                                        
  at void <Execute>b__0() in DefaultCommand.cs:53                               
  at int Run(LogOptions options, Action run) in CommandHelper.cs:48             
  at int Execute(CommandContext context, Options options) in DefaultCommand.cs: 
     31                                                                         
  at Task<int> Execute(CommandContext context, CommandSettings settings) in     
     CommandOfT.cs:40                                                           
  at async Task<int> Execute(CommandTree leaf, CommandTree tree, CommandContext 
     context, ITypeResolver resolver, IConfiguration configuration) in          
     CommandExecutor.cs:[166](https://gitlab.com/xxx/app-collab/apps/-/jobs/8470774002#L166)

The problem does not occur with 2.74.1

        - dotnet tool install --global docfx  --version 2.74.1
        - export PATH="${PATH}:/root/.dotnet/tools" #see https://github.com/dotnet/docfx/issues/8542        
        - docfx docfx.json
$ docfx docfx.json
Using .NET Core SDK 8.0.404
[...]
Creating output...
Searching custom plugins in directory /root/.dotnet/tools/.store/docfx/2.74.1/docfx/2.74.1/tools/net8.0/any/...
No files are found with glob pattern apidoc/**.md, excluding obj/**,_site/**, under directory "/builds/xxx"
7 plug-in(s) loaded.
Building 2 file(s) in ResourceDocumentProcessor(ValidateResourceMetadata)...
Building 152 file(s) in ManagedReferenceDocumentProcessor(BuildManagedReferenceDocument=>SplitClassPageToMemberLevel=>ValidateManagedReferenceDocumentMetadata=>ApplyOverwriteDocumentForMref=>FillReferenceInformation)...
Building 2 file(s) in TocDocumentProcessor(BuildTocDocument)...
Building 3 file(s) in ConceptualDocumentProcessor(BuildConceptualDocument=>ValidateConceptualDocumentMetadata)...
/builds/xxx/index.md(7,1): warning InvalidFileLink: Invalid file link:(~/api/index.html).
/builds/xxx/index.md(9,1): warning InvalidFileLink: Invalid file link:(~/../).
Applying templates to 159 model(s)...
XRef map exported.
Build succeeded with warning.
    2 warning(s)
    0 error(s)
@glb-cblin glb-cblin added the bug A bug to fix label Nov 26, 2024
@glb-cblin glb-cblin changed the title [Bug] Docfx 2.78.1 requires Nodejs even when not using PDF features [Bug] Docfx 2.78.x requires Nodejs even when not using PDF features Nov 26, 2024
@glb-cblin
Copy link
Author

Same bug with 2.78.0

@glb-cblin
Copy link
Author

It works with 2.77.0, so it's caused by something introduced in 2.78.0

@glb-cblin
Copy link
Author

Problem seems to come from #10066 by @filzrev

We'd like to avoid installing nodejs if not strictly necessary (i.e we are not using PDF)

@filzrev
Copy link
Contributor

filzrev commented Nov 27, 2024

Reported issue is fixed by #10406.
And expected to be fixed in the latest version (2.78.2).

@glb-cblin
Copy link
Author

Tested in 2.78.2, it works, thank you

@mayankbhatt1004
Copy link

I am still having an issue for the pdf features on 2.78.2 (framework net9.0), worked fine with 2.77.x

@filzrev
Copy link
Contributor

filzrev commented Dec 17, 2024

@mayankbhatt1004

This issue is expected to be fixed in v2.78.2.
If you don't need pdf file generation. Set pdf generate options to false

If PDF file generation feature is required.
It needs to separately install Node.js. Because Node.js runtime is not bundled docfx 2.78.0 or later version.

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

No branches or pull requests

3 participants