Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Cannot build WebGL in headless mode

Discussion in 'Linux' started by Krstn, Aug 16, 2018.

  1. Krstn

    Krstn

    Joined:
    Dec 30, 2012
    Posts:
    27
    Hi

    I've setup Unity and my project on a Linux server and I wanted to build the project using command line.

    In order to do so I have added a WebGLBuilder.cs into Assets/Editor:

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.Build.Reporting;
    3. using UnityEngine;
    4.  
    5. class WebGLBuilder {
    6.     static void build() {
    7.  
    8.         // Place all your scenes here
    9.         string[] scenes = {"Assets/Scenes/main.unity"};
    10.  
    11.         string pathToDeploy = "webglbuild/";
    12.  
    13.         BuildReport report = BuildPipeline.BuildPlayer(scenes, pathToDeploy, BuildTarget.WebGL, BuildOptions.None);
    14.         Debug.Log(report.summary.outputPath);
    15.     }
    16. }
    I run it like this:
    /opt/Unity-2018.2.3f1/Editor/Unity -quit -batchmode -nographics -logFile /root/stdout.log  -buildTarget WebGL -projectPath /root/projects/dw_bo_unity_positioning -executeMethod WebGLBuilder.build


    So the build is actually performed, but there's no output produced.
    I have checked the logs and there's an error somewhere along:

    Code (CSharp):
    1. [ERROR] FATAL UNHANDLED EXCEPTION: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: ApplicationName='python', CommandLine='"/opt/Unity-2018.2.3f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/em++" -Wno-unused-value -Wno-invalid-offsetof -nostdinc -fno-strict-overflow -std=c++11 -Oz -DIL2CPP_EXCEPTION_DISABLED=1  -DNET_4_0 -DUNITY_JIT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DNDEBUG -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/libil2cpp" -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/external/boehmgc/include" -I"/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput" "/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput/Il2CppAttributes.cpp" -o "/root/projects/dw_bo_unity_positioning/Library/il2cpp_cache/46E4D653C630EEF4F90516915E90D106.o"', CurrentDirectory='', Native error= Cannot find the specified file
    2.   at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    3.   at System.Diagnostics.Process.Start () [0x0003a] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    4.   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
    5.   at Unity.IL2CPP.Shell.Execute (Unity.IL2CPP.Shell+ExecuteArgs executeArgs, Unity.IL2CPP.Shell+IExecuteController controller) [0x000d6] in <76662c41e4424401aea4578e4a0792d8>:0
    6.   at Unity.IL2CPP.Building.BuildShell.Execute (Unity.IL2CPP.Shell+ExecuteArgs args) [0x00012] in <ba170547f5354457b166a91eeab2ddb8>:0
    7.   at Unity.IL2CPP.Building.CompilationInvocation.Execute () [0x00007] in <ba170547f5354457b166a91eeab2ddb8>:0
    8.   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile (Unity.IL2CPP.Building.IntermediateObjectFileCompilationData data) [0x00053] in <ba170547f5354457b166a91eeab2ddb8>:0
    9.   at Unity.IL2CPP.Building.ParallelFor+<RunWithResult>c__AnonStorey1`2[D,T].<>m__0 (System.Object o) [0x00032] in <ba170547f5354457b166a91eeab2ddb8>:0
    10.    --- End of inner exception stack trace ---
    11.   at Unity.IL2CPP.Building.ParallelFor.RunWithResult[D,T] (D[] data, System.Func`2[T,TResult] action) [0x00118] in <ba170547f5354457b166a91eeab2ddb8>:0
    12.   at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles (System.Collections.Generic.IEnumerable`1[T] sourceFilesToCompile, Unity.IL2CPP.Building.Statistics.IBuildStatisticsCollector statisticsCollector) [0x0015b] in <ba170547f5354457b166a91eeab2ddb8>:0
    13.   at Unity.IL2CPP.Building.CppProgramBuilder.Build (Unity.IL2CPP.Building.Statistics.IBuildStatistics& statistics) [0x001d0] in <ba170547f5354457b166a91eeab2ddb8>:0
    14.   at Unity.IL2CPP.Building.Statistics.BuildingTestRunnerHelper.BuildAndLogStatsForTestRunner (Unity.IL2CPP.Building.CppProgramBuilder builder, Unity.IL2CPP.Building.Statistics.IBuildStatistics& statistics) [0x00001] in <ba170547f5354457b166a91eeab2ddb8>:0
    15.   at il2cpp.Program.DoRun (System.String[] args) [0x00687] in <ed91f4cb3dfc4c70852d8b03a77d76e6>:0
    16.   at il2cpp.Program.Run (System.String[] args) [0x00020] in <ed91f4cb3dfc4c70852d8b03a77d76e6>:0
    17.   at il2cpp.Program.Main (System.String[] args) [0x00035] in <ed91f4cb3dfc4c70852d8b03a77d76e6>:0
    18. ---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): ApplicationName='python', CommandLine='"/opt/Unity-2018.2.3f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/em++" -Wno-unused-value -Wno-invalid-offsetof -nostdinc -fno-strict-overflow -std=c++11 -Oz -DIL2CPP_EXCEPTION_DISABLED=1  -DNET_4_0 -DUNITY_JIT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DNDEBUG -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/libil2cpp" -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/external/boehmgc/include" -I"/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput" "/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput/Il2CppAttributes.cpp" -o "/root/projects/dw_bo_unity_positioning/Library/il2cpp_cache/46E4D653C630EEF4F90516915E90D106.o"', CurrentDirectory='', Native error= Cannot find the specified file
    19.   at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    20.   at System.Diagnostics.Process.Start () [0x0003a] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    21.   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
    22.   at Unity.IL2CPP.Shell.Execute (Unity.IL2CPP.Shell+ExecuteArgs executeArgs, Unity.IL2CPP.Shell+IExecuteController controller) [0x000d6] in <76662c41e4424401aea4578e4a0792d8>:0
    23.   at Unity.IL2CPP.Building.BuildShell.Execute (Unity.IL2CPP.Shell+ExecuteArgs args) [0x00012] in <ba170547f5354457b166a91eeab2ddb8>:0
    24.   at Unity.IL2CPP.Building.CompilationInvocation.Execute () [0x00007] in <ba170547f5354457b166a91eeab2ddb8>:0
    25.   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile (Unity.IL2CPP.Building.IntermediateObjectFileCompilationData data) [0x00053] in <ba170547f5354457b166a91eeab2ddb8>:0
    26.   at Unity.IL2CPP.Building.ParallelFor+<RunWithResult>c__AnonStorey1`2[D,T].<>m__0 (System.Object o) [0x00032] in <ba170547f5354457b166a91eeab2ddb8>:0 <---
    27.  
    28. ---> (Inner Exception #1) System.ComponentModel.Win32Exception (0x80004005): ApplicationName='python', CommandLine='"/opt/Unity-2018.2.3f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/em++" -Wno-unused-value -Wno-invalid-offsetof -nostdinc -fno-strict-overflow -std=c++11 -Oz -DIL2CPP_EXCEPTION_DISABLED=1  -DNET_4_0 -DUNITY_JIT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DNDEBUG -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/libil2cpp" -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/external/boehmgc/include" -I"/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput" "/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput/Il2CppTypeDefinitions.cpp" -o "/root/projects/dw_bo_unity_positioning/Library/il2cpp_cache/86C31FECA229BC8DC4A0CE83B2DEF115.o"', CurrentDirectory='', Native error= Cannot find the specified file
    29.   at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    30.   at System.Diagnostics.Process.Start () [0x0003a] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    31.   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
    32.   at Unity.IL2CPP.Shell.Execute (Unity.IL2CPP.Shell+ExecuteArgs executeArgs, Unity.IL2CPP.Shell+IExecuteController controller) [0x000d6] in <76662c41e4424401aea4578e4a0792d8>:0
    33.   at Unity.IL2CPP.Building.BuildShell.Execute (Unity.IL2CPP.Shell+ExecuteArgs args) [0x00012] in <ba170547f5354457b166a91eeab2ddb8>:0
    34.   at Unity.IL2CPP.Building.CompilationInvocation.Execute () [0x00007] in <ba170547f5354457b166a91eeab2ddb8>:0
    35.   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile (Unity.IL2CPP.Building.IntermediateObjectFileCompilationData data) [0x00053] in <ba170547f5354457b166a91eeab2ddb8>:0
    36.   at Unity.IL2CPP.Building.ParallelFor+<RunWithResult>c__AnonStorey1`2[D,T].<>m__0 (System.Object o) [0x00032] in <ba170547f5354457b166a91eeab2ddb8>:0 <---
    37.  
    38. ---> (Inner Exception #2) System.ComponentModel.Win32Exception (0x80004005): ApplicationName='python', CommandLine='"/opt/Unity-2018.2.3f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/em++" -Wno-unused-value -Wno-invalid-offsetof -nostdinc -fno-strict-overflow -std=c++11 -Oz -DIL2CPP_EXCEPTION_DISABLED=1  -DNET_4_0 -DUNITY_JIT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DNDEBUG -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/libil2cpp" -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/external/boehmgc/include" -I"/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput" "/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput/Il2CppMetadataUsage.cpp" -o "/root/projects/dw_bo_unity_positioning/Library/il2cpp_cache/18E7178DB83E0248FBD3098AD3F3DD47.o"', CurrentDirectory='', Native error= Cannot find the specified file
    39.   at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    40.   at System.Diagnostics.Process.Start () [0x0003a] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    41.   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
    42.   at Unity.IL2CPP.Shell.Execute (Unity.IL2CPP.Shell+ExecuteArgs executeArgs, Unity.IL2CPP.Shell+IExecuteController controller) [0x000d6] in <76662c41e4424401aea4578e4a0792d8>:0
    43.   at Unity.IL2CPP.Building.BuildShell.Execute (Unity.IL2CPP.Shell+ExecuteArgs args) [0x00012] in <ba170547f5354457b166a91eeab2ddb8>:0
    44.   at Unity.IL2CPP.Building.CompilationInvocation.Execute () [0x00007] in <ba170547f5354457b166a91eeab2ddb8>:0
    45.   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile (Unity.IL2CPP.Building.IntermediateObjectFileCompilationData data) [0x00053] in <ba170547f5354457b166a91eeab2ddb8>:0
    46.   at Unity.IL2CPP.Building.ParallelFor+<RunWithResult>c__AnonStorey1`2[D,T].<>m__0 (System.Object o) [0x00032] in <ba170547f5354457b166a91eeab2ddb8>:0 <---
    47.  
    48. ---> (Inner Exception #3) System.ComponentModel.Win32Exception (0x80004005): ApplicationName='python', CommandLine='"/opt/Unity-2018.2.3f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/em++" -Wno-unused-value -Wno-invalid-offsetof -nostdinc -fno-strict-overflow -std=c++11 -Oz -DIL2CPP_EXCEPTION_DISABLED=1  -DNET_4_0 -DUNITY_JIT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DNDEBUG -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/libil2cpp" -I"/opt/Unity-2018.2.3f1/Editor/Data/il2cpp/external/boehmgc/include" -I"/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput" "/root/projects/dw_bo_unity_positioning/Temp/StagingArea/Data/il2cppOutput/Il2CppInvokerTable.cpp" -o "/root/projects/dw_bo_unity_positioning/Library/il2cpp_cache/B21A71BD9476906A2AA14ECA4D7F1D75.o"', CurrentDirectory='', Native error= Cannot find the specified file
    49.   at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    50.   at System.Diagnostics.Process.Start () [0x0003a] in <60233c34ef3e4e5f892759dbfc5ae27d>:0
    51.   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
    52.   at Unity.IL2CPP.Shell.Execute (Unity.IL2CPP.Shell+ExecuteArgs executeArgs, Unity.IL2CPP.Shell+IExecuteController controller) [0x000d6] in <76662c41e4424401aea4578e4a0792d8>:0
    53.   at Unity.IL2CPP.Building.BuildShell.Execute (Unity.IL2CPP.Shell+ExecuteArgs args) [0x00012] in <ba170547f5354457b166a91eeab2ddb8>:0
    54.   at Unity.IL2CPP.Building.CompilationInvocation.Execute () [0x00007] in <ba170547f5354457b166a91eeab2ddb8>:0
    55.   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile (Unity.IL2CPP.Building.IntermediateObjectFileCompilationData data) [0x00053] in <ba170547f5354457b166a91eeab2ddb8>:0
    56.   at Unity.IL2CPP.Building.ParallelFor+<RunWithResult>c__AnonStorey1`2[D,T].<>m__0 (System.Object o) [0x00032] in <ba170547f5354457b166a91eeab2ddb8>:0 <---
    57.  
    58.  
    And unfortunately this is beyond my knowledge :) The 'cannot find the specified file' is a bit cryptic, I have no clue which file it cannot find.

    Any help will be grately appreciated.

    The system is Ubuntu 18.04.
     
  2. Tak

    Tak

    Unity Technologies

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    Do you have the prerequisites for webgl deployment?
    • ffmpeg (if you're transcoding audio)
    • node
    • java 6+ runtime
    • gzip
    • python
     
  3. Krstn

    Krstn

    Joined:
    Dec 30, 2012
    Posts:
    27
    @Tak
    Tak! (which would be 'yes' in polish).

    There was an issue with python indeed. It was looking for 'python' but it was not there (I have had it on my user because of an alias...).
    So I have created symlink to python, another error surfaced, this time Unity was looking for python2. Did symlink to this one as well and presto... build complete!

    Thanks a lot!
     
  4. arunjose007

    arunjose007

    Joined:
    Apr 28, 2020
    Posts:
    5
    @Krstn Could you please more elaborate how you fixed this issue? I am facing the same, The python3 is already installed in my system. Where the unity checks for it? What do you mean by symlink to python?
     
  5. steinadogg

    steinadogg

    Joined:
    Oct 24, 2020
    Posts:
    1
    sudo apt install python-is-python3 worked for me.
     
  6. ThatStevenGuy

    ThatStevenGuy

    Joined:
    Jan 30, 2014
    Posts:
    5
    After installing Python 2.7 you'll have to create a symlink to /usr/bin/python for Unity to be able to find it:
    Code (csharp):
    1. sudo ln -s /usr/bin/python2.7 /usr/bin/python