Search Issue Tracker

Won't Fix

Votes

0

Found in [Package]

3.1-beta.2

Issue ID

HUBX-748

Regression

No

On macOS PATH environment variable differs when launching Project from the Terminal

Package: HUBX

-

Steps to reproduce:
1. Open SampleScene in the attached "Unity hub v3 PATH problem.zip" project
2. Enter Play Mode
3. Observe log message in the Console window and then close the project
4. Launch the user attached project from the macOS Terminal using the command line arguments following this structure: <unity_instalaltion_path> -projectPath <project_path>
5. Open SampleScene and Enter Play Mode
6. Observe log message in the Console window

Expected result: output of the PATH variable in the Editor's Console window is the same when the project is launched via the Hub and via the Terminal
Actual result: output of the PATH variable in the Editor's Console window is different when the project is launched via the Hub from when the project is launched via the Terminal

Reproducible with: 3.0.1, 3.1.0-beta.2

Notes:
- This issue is not reproducible on Windows and Linux
- The issue can also be observed when typing "echo $PATH" without the quotation marks in macOS Terminal
- In the repro project, the environment variable is gotten using "Environment.GetEnvironmentVariable("PATH")" method
- Project's Console window output when launching it via the Hub: "/usr/bin:/bin:/usr/sbin:/sbin"
- Project's Console window output when launching it via the Terminal: "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands"

*Additional notes from discussion between [~lara.rode] and myself ([~paul.jarrow]):*

In some cases, the PATH that the Hub is collecting includes junk from stdout that shouldn't be there. This muddies the PATH variable and creates a lot of undefined behaviour. This was effecting some Mac users of the Hub, preventing them from installing the Unity Editor with the error: ENAMETOOLONG. A small fix has been created for this problem, but there appears to be a larger issue that should be addressed here.

The fix for the above ENAMETOOLONG error was to provide the option *shell: true* to the spawn function in the Hub.

  1. Resolution Note:

    This is the default macOS behaviour for GUI apps.

  2. Resolution Note:

    Quoting previous comment with context for why this is not being fixed on Hub side for now:

    "Right now, from Hub side for the purpose of this bug ticket, we are deciding that we will not be supporting this by default, since this is default macOS behaviour for GUI apps.

    Users can launch the Hub via the Terminal (open /Applications/Unity\ Hub.app ) and editors will then have their expected PATH. Or, they can use [this workaround|https://support.unity.com/hc/en-us/articles/360044824951-I-need-to-start-Unity-with-an-environment-variable-s-set-how-can-I-do-that].

    A follow up ticket can be found here: https://jira.unity3d.com/browse/HUB-5242 , where we will evaluate a user preference that can be set to enable this behaviour from Hub launched from the GUI."

Comments (2)

  1. NibbleByte3

    May 02, 2024 20:33

    For anyone wondering where do initial PATH values come from in the terminal, check my findings here: https://forum.unity.com/threads/modifing-path-variable-in-macos-for-unity.500616/#post-9810975

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.