vrchat-community / creator-companion

The Entry Point for Making Things in VRChat
https://vrchat.com/home/download
53 stars 357 forks source link

[BUG] VPM cannot find supported editor for 2022.3.6f1 on Linux #408

Open Foxcapades opened 6 months ago

Foxcapades commented 6 months ago

Describe the bug

NOTE This is a new behavior as of 0.1.21 and persists in 0.1.22.

When executing VPM it does not use the editor as configured in the settings.json file. Instead, when executed it throws this error:

[14:27:43 INF] Found No Supported Editors
[14:27:43 INF] Unity is not installed.
[14:27:43 ERR] No Unity Editor found, you need to set this before you can make new projects.

Additionally, during execution it modifies the settings.json file and removes the value set to the pathToUnityExe key.

To Reproduce

  1. Install VPM

    $ dotnet tool install --global vrchat.vpm.cli
    Tool 'vrchat.vpm.cli' was installed with the latest stable version (version '0.1.22').
  2. Configure ~/.local/share/VRChatCreatorCompanion/settings.json

    1 {
    2   "pathToUnityExe": "/home/ellie/Unity/Hub/Editor/2022.3.6f1/Editor/Unity",
    3   "pathToUnityHub": "/opt/unityhub/unityhub",
  3. Execute vpm new.

    $ vpm new Zoe.1 Avatar -p $PWD 
    [14:27:43 INF] Found No Supported Editors
    [14:27:43 INF] Unity is not installed.
    [14:27:43 ERR] No Unity Editor found, you need to set this before you can make new projects.

Expected behavior

$ vpm new Zoe.1 Avatar -p $PWD
[14:36:31 INF] VPM Doesn't know how to look at Linux executables for version yet, so just returning true for PathIsValidUnityVersion(/home/ellie/Unity/Hub/Editor/2022.3.6f1/Editor/Unity)
[14:36:31 INF] VPM Doesn't know how to look at Linux executables for version yet, so just returning true for PathIsValidUnityVersion(/home/ellie/Unity/Hub/Editor/2022.3.6f1/Editor/Unity)
[14:36:31 INF] Unity is installed.
[14:36:31 INF] Let's create a project named Zoe.1 from the template /home/ellie/.local/share/VRChatCreatorCompanion/VRCTemplates/Avatar at the path /media/ellie/Ashley/3D/Projects/Unity/Zoe.1
[14:36:31 INF] Looking for Legacy Packages to Upgrade by Scanning Folders within com.vrchat.avatars
[14:36:31 INF] Looking for Legacy Packages to Upgrade by Scanning Folders within com.vrchat.avatars
[14:36:31 INF] Looking for Legacy Packages to Upgrade by Scanning Folders within com.vrchat.base
[14:36:31 INF] Resolved package com.vrchat.avatars ^3.5.x
[14:36:31 INF] Resolved all VPM Packages in /media/ellie/Ashley/3D/Projects/Unity/Zoe.1
[14:36:32 INF] Looking for Legacy Packages to Upgrade by Scanning Folders within com.vrchat.core.vpm-resolver
[14:36:32 INF] Looking for Legacy Packages to Upgrade by Scanning Folders within com.vrchat.core.vpm-resolver
[14:36:32 INF] Successfully resolved packages for new Project.
[14:36:32 INF] Project created!

(This output is tweaked from the 0.1.20 output to say ^3.5.x instead of ^3.4.x)

Screenshots

Before execution before

After execution after

Related Product

VPM CLI

Product Version

0.1.21, 0.1.22

OS

macOS / Linux

Additional context

The workaround I have for now is:

  1. stick with version 0.1.20
  2. create a project with vpm
  3. delete the ./Packages/com.vrchat.* directories from the project folder (as the older vpm installs outdated packages by default for some reason?)
  4. cd into the project root directory
  5. run vpm resolve project to install the correct versions of the packages
  6. manually add the new project to Unity Hub
  7. open the project in the 2022.3.6f1 version of Unity, hitting "Continue" when it warns about opening the project in a different version of Unity than it was created for.
valentinegb commented 6 months ago

Having this same issue on Mac. How do you rollback versions? I already updated to 0.1.22 .-.

anatawa12 commented 6 months ago

Might be related to #28

In #28, Setting pathToUnityExe was the workaround so I think Setting preferredUnityEditors might work as workaround.

valentinegb commented 6 months ago

Setting pathToUnityExe isn't working since it gets cleared again every time VPM is run, with preferredUnityEditors I'm not really sure what I would set it to since it looks like it's supposed to be an object.

Foxcapades commented 6 months ago

Having this same issue on Mac. How do you rollback versions? I already updated to 0.1.22 .-.

What I did was:

dotnet tool uninstall --global vrchat.vpm.cli
dotnet tool install --global vrchat.vpm.cli --version 0.1.20
anatawa12 commented 6 months ago

For preferredUnityEditors, You should set like this I think.

  "preferredUnityEditors": {
    "2019": "/Path/To/Unity2019",
    "2022": "/Path/To/Unity2022"
  },

I copied partially from settings.json on the windows.

valentinegb commented 6 months ago

Same issue :T (Here's what I have, just in case I'm putting a bad path:)

"preferredUnityEditors": {
  "2022": "/Applications/Unity/Hub/Editor/2022.3.6f1/Unity.app/Contents/MacOS/Unity"
},

(Unity at the end of that path is an executable binary.)

founta commented 6 months ago

I have the same issue for the 2019 unity editor, with it overwriting the pathToUnityExe when running vpm. The docs (https://vcc.docs.vrchat.com/vpm/cli/#check-hub) say that it runs this command for vpm check unity:

unityhub -- --headless editors -i

but the correct command for linux is this: unityhub --headless editors -i

(as per https://docs.unity3d.com/hub/manual/HubCLI.html)

when running vpm check unity, it appears as if it runs the first command there, as it causes the hub to start up if it is not already running (and that's what happens if you manually run it in a terminal). they must have changed things so that it overwrites the path to the unity executable in those two newer vpm versions

in the old 0.1.20 version, it also cannot find the unity editor due to the above issue, but it does not wipe out that variable in the settings JSON file

founta commented 6 months ago

welp, downgrading to 0.1.20 did not help for me and I was probably spouting nonsense in the post above. It still wipes out that path to unity exe when I try to make a new project :(

edit: oop 0.1.20 works fine. the path to the executable has to be an absolute path :+1:

valentinegb commented 6 months ago

The command on macOS is "./Unity Hub" -- --headless editors -i, for those wondering. On my Mac, the Unity Hub executable is located at /Applications/Unity Hub.app/Contents/MacOS.

anatawa12 commented 6 months ago

I found that there are unity configuration in litedb file. it might be work well to add unity version to litedb?

Livb-VRC commented 5 months ago

Tried downgrading to 1.20 and updating pathToUnityExe, same issue

"pathToUnityExe": "/Applications/Unity/Hub/Editor/2022.3.6f1/Unity.app/Contents/MacOS/Unity",

Robotex commented 5 months ago

Any solution yet?

anatawa12 commented 5 months ago

I found the solution for this problem but this is extremely tricky solution.

Adding your unity editor to ${XDG_DATA_HOME}/VRChatCreatorCompanion/vcc.liteDb(or${HOME}/.local/share/VRChatCreatorCompanion/vcc.liteDb) will fix this problem.

The following C# code is used with LiteDB 5.0.17 from nuget to fix in my vcc.litedb. If you're familiar with C#, you can fix with this code.


// Edit FOLLOWING TWO LINES
// IF you don't have installed the unity version, set null to the variable.
var unity2019 = "/Applications/Unity/Hub/Editor/2019.4.31f1/Unity.app/Contents/MacOS/Unity";
var unity2022 = "/Applications/Unity/Hub/Editor/2022.3.6f1/Unity.app/Contents/MacOS/Unity";
// END OF EDIT AREA

var dataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME")
    ?? Environment.GetEnvironmentVariable("HOME") + "/.local/share";

var connect = new ConnectionString(dataHome + "/VRChatCreatorCompanion/vcc.liteDb");

using (var db = new LiteDatabase(connect))
{
    if (unity2022 != null)
    {
        db.GetCollection("unityVersions").Insert(new BsonDocument()
        {
            { "Path", unity2022 },
            { "Version", "2022.3.6f1" },
            { "LoadedFromHub", false }
        });
    }

    if (unity2019 != null)
    {
        db.GetCollection("unityVersions").Insert(new BsonDocument()
        {
            { "Path", unity2019 },
            { "Version", "2019.4.31f1" },
            { "LoadedFromHub", false }
        });
    }
}
Robotex commented 5 months ago

I found the solution for this problem but this is extremely tricky solution.

Adding your unity editor to ${XDG_DATA_HOME}/VRChatCreatorCompanion/vcc.liteDb(or${HOME}/.local/share/VRChatCreatorCompanion/vcc.liteDb) will fix this problem.

The following C# code is used with LiteDB 5.0.17 from nuget to fix in my vcc.litedb. If you're familiar with C#, you can fix with this code.

// Edit FOLLOWING TWO LINES
// IF you don't have installed the unity version, set null to the variable.
var unity2019 = "/Applications/Unity/Hub/Editor/2019.4.31f1/Unity.app/Contents/MacOS/Unity";
var unity2022 = "/Applications/Unity/Hub/Editor/2022.3.6f1/Unity.app/Contents/MacOS/Unity";
// END OF EDIT AREA

var dataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME")
    ?? Environment.GetEnvironmentVariable("HOME") + "/.local/share";

var connect = new ConnectionString(dataHome + "/VRChatCreatorCompanion/vcc.liteDb");

using (var db = new LiteDatabase(connect))
{
    if (unity2022 != null)
    {
        db.GetCollection("unityVersions").Insert(new BsonDocument()
        {
            { "Path", unity2022 },
            { "Version", "2022.3.6f1" },
            { "LoadedFromHub", false }
        });
    }

    if (unity2019 != null)
    {
        db.GetCollection("unityVersions").Insert(new BsonDocument()
        {
            { "Path", unity2019 },
            { "Version", "2019.4.31f1" },
            { "LoadedFromHub", false }
        });
    }
}

I initially thought that .liteDb file was empty because OneBella couldn't read it but after running your script Unity was finally recognized in vpm check unity. Ty!