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.

Resolved (Case 1412113)[BuildError] OSX 12.3 and Unity 2020.3 - constant build errors

Discussion in 'WebGL' started by matt_cauldron, Mar 20, 2022.

  1. matt_cauldron

    matt_cauldron

    Joined:
    Dec 17, 2021
    Posts:
    48
    After upgrading MacOS from 12.1 to 12.3, and trying to build any WebGL project (including just a blank 3d project) - the build constantly errors with an il2cpp win32 exception.

    This is 100% reproducible on 2020.3.31f1

    Made a bug
    https://issuetracker.unity3d.com/is...il2cpp-build-error-after-osx-12-dot-3-upgrade

    Code (CSharp):
    1. System.ComponentModel.Win32Exception (2): No such file or directory
    2.    at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
    3.    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
    4.    at System.Diagnostics.Process.Start()
    5.    at Unity.IL2CPP.Shell.SetupAndStart(ExecuteContext context, Boolean asyncMode) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.Shell/Shell.cs:line 423
    6.    at Unity.IL2CPP.Shell.ExecuteAsync(ExecuteArgs executeArgs, IExecuteController controller, Boolean asyncMode) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.Shell/Shell.cs:line 299
    7.    at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.Shell/Shell.cs:line 355
    8.    at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.Building/CppProgramBuilder.cs:line 334
    9.    at Unity.IL2CPP.Building.ParallelFor.<>c__DisplayClass1_0`2.<RunWithResult>b__0(Object o) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.Building/ParallelFor.cs:line 78
    10.  
    Screenshot 2022-03-20 at 08.01.35.png
     
    Last edited: Mar 25, 2022
    M_R_Antonio likes this.
  2. matt_cauldron

    matt_cauldron

    Joined:
    Dec 17, 2021
    Posts:
    48
  3. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    124
    Have the same issue here, on an M1 Pro Mac Book, after upgrading to 12.3
     
  4. M_R_Antonio

    M_R_Antonio

    Joined:
    Nov 19, 2017
    Posts:
    2
  5. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    124
    It might be because of python2 was removed in that update? But that is just a wild guess..
     
    questmill and anthony_b_ like this.
  6. M_R_Antonio

    M_R_Antonio

    Joined:
    Nov 19, 2017
    Posts:
    2
    Looking for information about the problem, I found other similar problems based on the same error that we are getting, but in other libraries.
    From what I saw in a Github thread (I saw it the other day so I don't have the link anymore) the problem came from python2.

    I didn't know that this update had removed python2, but seeing this, it's likely that the problem is coming from there.
     
    anthony_b_ likes this.
  7. matt_cauldron

    matt_cauldron

    Joined:
    Dec 17, 2021
    Posts:
    48
    I put in a support ticket, the team are aware of the issue now, however no current fix timelines. I've asked for a public tracker bug so will hopefully have one up that we can stay aware of the status of:

    We directly notified the issue to the WebGL team because of the severity of the problem. After some additional tests, they confirmed that the issue is only related to WebGL and not IL2CPP.
     
    Last edited: Mar 24, 2022
    M_R_Antonio likes this.
  8. matt_cauldron

    matt_cauldron

    Joined:
    Dec 17, 2021
    Posts:
    48
  9. anthony_b_

    anthony_b_

    Unity Technologies

    Joined:
    Oct 27, 2020
    Posts:
    23
    The build error is a result of Python no longer being included with macOS 12.3. When you upgrade to macOS 12.3, python is removed from your computer.

    The Emscripten build toolchain for WebGL builds on Unity 2020.3 depends on Python 2.7. [WebGL builds on Unity 2021.2 and later require Python 3].

    The workaround is to install Python2.7 (from https://www.python.org/) on your computer.
     
  10. tryge

    tryge

    Joined:
    Sep 24, 2021
    Posts:
    2
    @anthony_b_

    Using the official package for Python 2.7.18 from www.python.org didn't resolve the problem for me, I am still getting the same errors like in the description above.

    After installation of the official version, python is available in `/usr/local/bin/python` which is a symlink to the framework that was installed.

    Is there anything else I have to do after the installation of Python to make it work?
     
  11. anthony_b_

    anthony_b_

    Unity Technologies

    Joined:
    Oct 27, 2020
    Posts:
    23
    The next piece of the workaround, is that, after installing Python 2.7 (from https://www.python.org/) the symlink at /usr/bin/python is missing. It's not straightforward to re-create the symlink due to macOS System Integrity Protection. So, instead create the environment variable EMSDK_PYTHON to refer to the installed python. i.e.
    1. Install Python 2.7 from https://www.python.org/
    2. Set the environment variable EMSDK_PYTHON to /usr/local/bin/python2
      • A good way of doing this is to create (or append to) your ~/.zprofile file the following line:
    export EMSDK_PYTHON=/usr/local/bin/python2

    And then reload the Unity Editor.
     
    EvgeniyKonyshock likes this.
  12. tryge

    tryge

    Joined:
    Sep 24, 2021
    Posts:
    2
    After this follow up suggestion didn't work I tried the following (none of which worked):

    launchctl setenv EMSDK_PYTHON /usr/local/bin/python2​

    which is the correct way of setting the environment variable for all applications (if you want to persist it you have to edit /etc/launchd.conf

    I grepped for EMSDK_PYTHON inside the unity editor files and it's not used - I believe it's usage has been introduced after they switched to python3, so it's not useful as a workaround.

    I grepped inside the unity editor files for `/usr/bin/python` and rewrote all occurences in scripts as `/usr/bin/env python`. However, there's one reference in the node binary that I couldn't replace.

    I tried using /etc/synthetic.conf to create symlinks, but this only works for symlinks directly under `/`.

    Finally I tried to create the symlinks in `/usr/bin/` by disabling system integrity protection and authenticated-root, but I wasn't able to remount the filesystem as writable (Error 66) or mount it as writable into a new folder (Error 75).

    I am writing this so anyone trying to fix this can save time trying these options.
     
    EvgeniyKonyshock and dimitroff like this.
  13. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    124

    I found a way to get this working. Just create a pre-build script that will set the EMSDK_PYTHON enviorment variable, because I have no idea where Unity is getting it's Enviorment variables, but they are not the same as the system ones.

    Code (CSharp):
    1.  
    2. public class PreBuildProcessing : IPreprocessBuildWithReport
    3. {
    4.     public int callbackOrder => 1;
    5.  
    6.     public void OnPreprocessBuild(BuildReport report)
    7.     {
    8.         System.Environment.SetEnvironmentVariable("EMSDK_PYTHON", "/Library/Frameworks/Python.framework/Versions/2.7/bin/python");
    9.     }
    10. }
     
  14. nanohazard

    nanohazard

    Joined:
    Jun 4, 2015
    Posts:
    3
    Thanks It works. this what I do exactly

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEditor;
    3. using UnityEditor.Build;
    4. using UnityEditor.Build.Reporting;
    5. using UnityEngine;
    6.  
    7. public class PreBuildProcessing : IPreprocessBuildWithReport
    8. {
    9.     public int callbackOrder => 1;
    10.     public void OnPreprocessBuild(BuildReport report)
    11.     {
    12.         System.Environment.SetEnvironmentVariable("EMSDK_PYTHON", "/Library/Frameworks/Python.framework/Versions/2.7/bin/python");
    13.     }
    14. }
    15. #endif
    16.  
     
  15. Lizby

    Lizby

    Joined:
    Dec 21, 2020
    Posts:
    3
    thank you so much for this omg <3
     
  16. simon_zappar

    simon_zappar

    Joined:
    Mar 23, 2018
    Posts:
    15
    The emscripten in 2020.3 is pretty old, (1.38.11 from August 2018) but it does look like it still supports either python 2 or 3 (since this change in Apr 2018).

    So it should actually be sufficient to just use the system python3 now, by setting EMSDK_PYTHON to "/usr/bin/python3" (which is actually part of Xcode command line tools - so run it in a terminal first to check it's all installed and hooked up properly).

    To avoid needing to change the env var, in the end I just updated the first line of emcc to reference python3 rather than python. Looks to have done the trick, I got a working build of a minimal demo scene at least.
    Find it in /Applications/Unity/Hub/Editor/2020.3.31f1/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/emcc

    One thought on picking up system environment - I think the Unity Hub passes on the environment to the editor, and likes to keep itself running at all times. So you might need to fully quit Unity Hub from the Mac menu bar to pick up any system-level changes. Not tested this myself, as I preferred the more targeted emcc intervention anyway.
     
  17. matt_cauldron

    matt_cauldron

    Joined:
    Dec 17, 2021
    Posts:
    48
    With @dimitroff 's editor env var setting the build works, unless britoli compression is enabled - which results in the following error

    Screenshot 2022-04-02 at 04.57.30.png

    Going to try your suggestion @simon_zappar and see if anything is improved for britoli compressed build under emscripten pointing to py3
     
  18. matt_cauldron

    matt_cauldron

    Joined:
    Dec 17, 2021
    Posts:
    48
    Hey, sorry took me ages to get round to actually trying it, is it enough to just change the bash line at the top?

    I've tried making this change in emcc.- reloading unity, but get the same build error, is it the only change necessary?

    Screenshot 2022-04-05 at 09.06.33.png
     
  19. afurioso

    afurioso

    Joined:
    Jan 12, 2022
    Posts:
    88
    Hello,

    I had the same issue but after trying a different option like installing python and putting a pre-build snippet of code, I upgrade my unity version 2021.2.18f1 (the ARM version) and now he build my WEBGL app with my MacBook M1.

    I hope this was helpful.
     
  20. simon_zappar

    simon_zappar

    Joined:
    Mar 23, 2018
    Posts:
    15
    I'm pretty sure that was all I did. You'll need to have Xcode + command line tools installed - check running /usr/bin/python3 in a terminal works as expected.
     
  21. simon_zappar

    simon_zappar

    Joined:
    Mar 23, 2018
    Posts:
    15
    I probably didn't try with compression enabled, so if brotli uses a second python instantiation, an env var might be needed.

    I had tried symlinking the python3 executable (actually at
    /Applications/Xcode.app/Contents/Developer/usr/bin/python3) to /usr/local/bin/python which then allowed `python` to work in a terminal, but I guess I'd need to add /usr/local/bin to PATH to get it picked up in GUI apps
     
  22. Zakini

    Zakini

    Joined:
    Apr 10, 2020
    Posts:
    1
    I found that @nanohazard's prebuild script was the only thing that worked for me. Setting EMSDK_PYTHON in ~/.zprofile didn't work for me, neither did changing the hashbang of emcc.

    Everything seems to work fine in 2021.2.19f1 so I'll use that for any actual projects. It's a shame that the tutorials still use 2020 though
     
  23. afurioso

    afurioso

    Joined:
    Jan 12, 2022
    Posts:
    88
    Hi, unfortunately, I didn't resolve anything. I tried to put the code that was suggested but nothing. I can use WebGL if I worked with unity 2021.2.18 but then I have issues with other integration. Please, how I can solve this?
     
  24. AhmedMansyPR

    AhmedMansyPR

    Joined:
    Dec 28, 2021
    Posts:
    8
    this one worked for on Unity 2020.3.32f
    Note that: the path should change for current python version
    Versions/3.10/bin/python3.10
    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEditor.Build;
    3. using UnityEditor.Build.Reporting;
    4.  
    5. public class WebglPreBuildProcessing : IPreprocessBuildWithReport
    6. {
    7.     public int callbackOrder => 1;
    8.     public void OnPreprocessBuild(BuildReport report)
    9.     {
    10.         System.Environment.SetEnvironmentVariable("EMSDK_PYTHON", "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10");
    11.     }
    12. }
    13. #endif
     
    vuplex and raining_day0513 like this.
  25. cloudyah

    cloudyah

    Joined:
    Mar 30, 2022
    Posts:
    1
    I'm also having this issue.

    I'm totally new to game dev, so my knowledge is basically zilch. I'd just started down the beginner pathway via Unity Learn and can't complete the publish step in the first microgame tutorial. And like Zakini noted, switching to 2021 isn't an option for the tutorials.

    As for the pre-build script, it seems like it won't work in my situation. I tried to edit the PublisherBuildProcessor.cs (where the existing pre- and post-build scripts are), but it automatically reverted my changes since, by default, you can't edit Unity packages.

    Hoping for a fix soon, but not sure how realistic that is.
     
  26. afurioso

    afurioso

    Joined:
    Jan 12, 2022
    Posts:
    88
    I tried but I still have the same error:
    UnityEditor.BuildPlayerWindow+BuildMethodException: 9 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002be] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:190
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)​
     
  27. AhmedMansyPR

    AhmedMansyPR

    Joined:
    Dec 28, 2021
    Posts:
    8
    try to go to the the directory under /Library/Frameworks/Python.framework/Versions and find your current version and make sure that it is the same as in the code.
    solving it this way worked for me on my Macbook m1 pro
     
  28. afurioso

    afurioso

    Joined:
    Jan 12, 2022
    Posts:
    88
    I did it and Unity gives me now only 2 errors, not 9 as before. I installed Python 3.9 and put that version on the directory, I don't know how to solve this.
     
  29. AhmedMansyPR

    AhmedMansyPR

    Joined:
    Dec 28, 2021
    Posts:
    8
    Then i don't know how to fix this, hope someone can help you
     
  30. CengageJermAker

    CengageJermAker

    Joined:
    Nov 29, 2017
    Posts:
    8
    For Python 3.10.2 installed from Homebrew this is my fix:
    Code (csharp):
    1. public void OnPreprocessBuild(BuildReport report)
    2. {
    3.     Environment.SetEnvironmentVariable("EMSDK_PYTHON", "/usr/local/Cellar/python@3.10/3.10.2/Frameworks/Python.framework/Versions/3.10/bin/python3.10");
    4. }
    5.  
     
    Last edited: Apr 12, 2022
  31. afurioso

    afurioso

    Joined:
    Jan 12, 2022
    Posts:
    88

    Nothing. I don't understand. Where should I put this script?
     
  32. CengageJermAker

    CengageJermAker

    Joined:
    Nov 29, 2017
    Posts:
    8
    Last edited: Apr 12, 2022
  33. afurioso

    afurioso

    Joined:
    Jan 12, 2022
    Posts:
    88
  34. RightfulYeti

    RightfulYeti

    Joined:
    Nov 22, 2017
    Posts:
    3
    This might help someone:

    I initially tried installing Python via Homebrew, and while it worked, "/Library/Frameworks/" didn't have any Python subfolder. So, I tried specifically installing Python 2.7 (as suggested above by anthony_b_) via Python directly.

    Complete walkthrough from answers.unity here
     
    boss225 likes this.
  35. izotrone

    izotrone

    Joined:
    Mar 15, 2022
    Posts:
    1

    I'm a newby to unity and coding can you explain more about creating a pre-build script. Because I created an empty c# script and pasted your code but did not solve my problem. :((
     
  36. Oscar-Tsang

    Oscar-Tsang

    Joined:
    Nov 7, 2012
    Posts:
    78
    Even install python3 unity 2021.3, cannot build webgl. 2020.3 can use this method to solve building webgl problem, while 2021 cannot. Still error
     
    stephanovallejom likes this.
  37. AhmedMansyPR

    AhmedMansyPR

    Joined:
    Dec 28, 2021
    Posts:
    8
    I just need to mention that this fix will not work on ci, so you have to exclude this and let the ci handles the environment
     
  38. Oscar-Tsang

    Oscar-Tsang

    Joined:
    Nov 7, 2012
    Posts:
    78
    Unity 2020.3.x requires Python2.7, simply change to "/Library/Frameworks/Python.framework/Versions/2.7/bin/python" can wrok. But, 2021.3.x is no use.
     
  39. dmakDD

    dmakDD

    Joined:
    Jun 8, 2017
    Posts:
    4
    I'm trying to build a legacy project out of Unity 2018.3.14 on MacOS Monterey and I can't figure out how to get Unity to find Python. I've installed python 2.7 and set the python alias to point to it. It runs fine through terminal. I also can run the xcodebuild -sdk command to find python in terminal which results in a correct path to python. During the build process Unity fails trying to find the path.

    I've tried the webglprebuildprocessing script referenced above which doesn't seem to do anything. I've uninstalled Unity and python and xcode and re-installed it all. Sometimes Unity prompts me to re-install command line tools which I've accepted quite a few times with no success.

    heres the error Unity outputs:

    Code (C#):
    1. Failed running python
    2. Failed running python "/Applications/Unity/Hub/Editor/2018.4.36f1/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/emcc" @"/Users/dmakfinsky/Projects/G300/Archive/Assets/../Temp/emcc_arguments.resp"
    3. stdout:
    4. stderr:python: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find python 2> /dev/null' failed with exit code 17664: (null) (errno=Invalid argument)xcode-select: Failed to locate 'python', requesting installation of command line developer tools.
    5. UnityEngine.GUIUtility:processEvent(Int32, IntPtr) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
    6.  
    7.  
    Anyone have any idea how to solve this?
     
    Last edited: May 24, 2022
  40. Felix_Delattre

    Felix_Delattre

    Joined:
    Apr 6, 2022
    Posts:
    1
  41. dmakDD

    dmakDD

    Joined:
    Jun 8, 2017
    Posts:
    4
    I believe this script should be in the Assets/Editor folder.
     
  42. stephanovallejom

    stephanovallejom

    Joined:
    May 19, 2022
    Posts:
    4
    Same with me I got more errors after I installed python2.7
     
  43. stephanovallejom

    stephanovallejom

    Joined:
    May 19, 2022
    Posts:
    4
    Lots of love I finally solved the whole issue <3
     
    RightfulYeti likes this.
  44. alior

    alior

    Joined:
    Sep 6, 2014
    Posts:
    18
    For those who face the issue on the Linux. I fixed it by modifying the code with environment variable but with some slight changes.

    First install the python2 package if it doesn't exits:
    Code (CSharp):
    1. sudo apt install python2
    Then you have to find your phyton2 location:
    Code (CSharp):
    1. name@machine:~$ whereis python2
    2. python2: /usr/bin/python2
    After you change environment line to:
    Code (CSharp):
    1. System.Environment.SetEnvironmentVariable("EMSDK_PYTHON", "/usr/bin/python2");
    Surely your path can be different but most likely it's gonna be the same.

    After that I've encountered another lib dependency issue:
    Code (CSharp):
    1. error while loading shared libraries: libtinfo.so.5
    but I was able to fix it by installing libncurses5:
    Code (CSharp):
    1. sudo apt install libncurses5
    Hope that's gonna help someone.
     
  45. jakemaier

    jakemaier

    Joined:
    Jul 7, 2022
    Posts:
    1
    If anyone still needs help with this issue, I just updated to Unity 2021 LTS and that solved the problem for me.
     
    azevedco likes this.
  46. azevedco

    azevedco

    Joined:
    Mar 2, 2014
    Posts:
    34
    This worked for me. Turned out, there are versions of Unity that work for Intel or Silicon, so when I downloaded 2021.3.6 LTS, I made sure to get the Silicon version as i'm on a M1 Macbook Pro.
    If it's worth noting, this no longer required the scripting/environment variable changes mentioned earlier on in this post.
     
  47. KaPow1

    KaPow1

    Joined:
    Jan 27, 2013
    Posts:
    9
    Has anyone seen this on Windows? I'm facing the issue on Win 10 (Unity 2020.3) and the linux and mac fixes aren't working out. Haven't been able to find other Windows users who've experienced this.
     
  48. atomikm

    atomikm

    Joined:
    Feb 8, 2020
    Posts:
    13

    Hey there!

    We also use brotli compression in our WebGL builds and are running into the same error.

    Did you happen to find a solution that fixed it?
     
  49. morningmoming

    morningmoming

    Joined:
    Apr 23, 2018
    Posts:
    1
    Thank you ,It's work for me
     
  50. anthony_b_

    anthony_b_

    Unity Technologies

    Joined:
    Oct 27, 2020
    Posts:
    23
    The fix for building for WebGL with Unity 2020.3 and macOS 12.3+ has now landed in Unity 2020.3.40f1, which should be available for download shortly.
    (with Unity 2020.3.40f1 we bundle and use the appropriate version of Python 2.7 with the Emscripten toolchain used for making the WebGL builds).

    https://issuetracker.unity3d.com/is...il2cpp-build-error-after-osx-12-dot-3-upgrade

    This issue does not affect Unity 2021 and later. Nor does it affect users building with the Windows or Linux versions of the Unity 2020 Editor.

    I'm sorry for how long we needed to land the fix here.

    For any other build issues, please start separate threads.