Open anatawa12 opened 3 months ago
Thank you for flagging that. I added this to our notes on the .NET 8 upgrade.
We will most likely maintain the current $HOME/.local/share
behavior.
I will keep this thread updated with details as I have them
Confirming that the plan is to maintain $HOME/.local/share
on macOS
VCC and VCC CLI are moving to .NET 6 with VCC 2.4.0 (next major release) which will maintain the existing path.
The CLI pre-release using .NET 8 and pathing fix is available now
https://www.nuget.org/packages/VRChat.VPM.CLI#versions-body-tab
dotnet tool install -g VRChat.VPM.CLI --version 0.1.28-beta.1
If everything goes well - this should go live in the near future
It looks vpm cli 0.1.28-beta.1 is using './$HOME/.local/share/VRChatCreatorCompanion/settings.json'
relative to working directory of vpm cli instead of .local/share/VRChatCreatorCompanion/settings.json
relative to user home directory, which is stored in HOME
environment variable.
In general, *nix platform can use any character in file system entry name, so when you request OS to access directory named $HOME
, OS simply checks file system entry named $HOME
in the current working directory.
Expanding environment variable (or others) is our responsibility and we have to expand environment variable.
Also I found that VPM Cli is using $HOME/.local/share
directory, but we should try XDG_DATA_HOME
before trying XDG_DATA_HOME
.
Here's example code to get correct VRChatCreatorCompanion
for *nix platform including macOS and linux.
(This code is my own code and putting here with CC0 license)
#nullable enable
using System;
using System.IO;
using System.Runtime.InteropServices;
string GetVCCDirectory()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// For windows platform, we use the %LOCALAPPDATA%\VRChatCreatorCompanion directory
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "VRChatCreatorCompanion");
}
else
{
// For *nix platform, we use the $XDG_DATA_HOME/VRChatCreatorCompanion directory
var xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
if (string.IsNullOrEmpty(xdgDataHome))
{
// if XDG_DATA_HOME is not set, we use the default value
// Default value of XDG_DATA_HOME is $HOME/.local/share
// We should use default value even if XDG_DATA_HOME is defined with empty value.
// Please read https://specifications.freedesktop.org/basedir-spec/latest/#variables
// for more information.
var home = Environment.GetEnvironmentVariable("HOME");
if (string.IsNullOrEmpty(home)) throw new InvalidOperationException("HOME is not set");
xdgDataHome = Path.Combine(home, ".local", "share");
}
return Path.Combine(xdgDataHome, "VRChatCreatorCompanion");
}
}
This should be fixed in the 0.1.28-beta.2 Tested on macOS
it looks working well in 0.1.28-beta.2.
In current VPM CLI and vpm-resplver, it looks
System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
is used for base path ofsettings.json
and other VCC and VPM related files.However, .NET 6 is being dead and .NET 8 is here, and I think VPM CLI will need to move to .NET 8 soon. However, in .NET 8,
System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
will return other directory on macOS. This will cause compatibility problem in my tool and future VPM so I opened this issue.As a command-line tools, it's common to use
$XDG_DATA_HOME
or$HOME/.local/share
on macOS and Unity mono still returns them forEnvironment.GetFolderPath
, and, I think it's better to use$XDG_DATA_HOME
on macOS.For more information about breaking changes in .NET 8, please refer https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/8.0/getfolderpath-unix and dotnet/runtime#68610