Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with dotnet cli on MacOSX #33

Open
dusrdev opened this issue Dec 9, 2023 · 10 comments
Open

Issue with dotnet cli on MacOSX #33

dusrdev opened this issue Dec 9, 2023 · 10 comments

Comments

@dusrdev
Copy link

dusrdev commented Dec 9, 2023

I cloned the source code and build for MacOSX-Arm64 (using the m2 macbook pro).

The issue is as appears in the photo, every preview shows this error message, it is independent of the location of the executable of AvantGarde, and the project location.

There is also no way that I've found to configure location of the dotnet cli.

SCR-20231209-lukz
@kuiperzone
Copy link
Owner

It sounds like dotnet is not in the path.

I'm sorry but I can't build or test for Mac. All I can say is that there are earlier reports of it running fine on Mac, but perhaps someone else may be able to diagnose the problem.

@dusrdev
Copy link
Author

dusrdev commented Dec 16, 2023

It sounds like dotnet is not in the path.

I'm sorry but I can't build or test for Mac. All I can say is that there are earlier reports of it running fine on Mac, but perhaps someone else may be able to diagnose the problem.

I am also relatively new to mac, but there isn't a "path" variable, least not like windows, to add things to path permanently you need to add them to the configuration of the shell you are using, which I have done.

I am not sure how AvantGarde is trying to launch the dotnet cli, perhaps outside of the shell I use.
A simple fix would be perhaps to add an option to manually configure the path to the dotnet cli inside AvantGarde.

@kuiperzone
Copy link
Owner

Hi,

I am not sure how AvantGarde is trying to launch the dotnet cli,

It's simply launching dotnet with a load of arguments after it basically, which is standard assuming dotnet is your "path", which you seem not to have on a mac.

There is an earlier report of it working fine on Mac, which surprised me actually as I wrote Avant Garde for Linux with Windows as an after thought but one which I can test. Launching of the preview host has not changed since then, although .NET and Avalonia versions have changed which have the potential to break things in unexpected ways.

See: #16

I'm assuming, therefore, that there must be some way to add "dotnet" to the Mac shell or path or whatever you have instead.

I'm sorry I can't be of more help on this, but I'm at a loss on a mac* and don't feel I can personally support this. I would be reluctant to add mac only features, although I might if there's a simple and clear tweak that some one was willing to suggest and test.

For reference, the Process.Start() code in RemoteLoader.cs and looks like this:

    var info = new ProcessStartInfo
    {
        Arguments = args,
        CreateNoWindow = true,
        FileName = "dotnet",
        RedirectStandardOutput = true,
        RedirectStandardError = true,
        UseShellExecute = false,
        WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
    };

(*) I used to use an SE30 or similar, but things have changed a tad since then.

@kuiperzone
Copy link
Owner

I am also relatively new to mac, but there isn't a "path" variable, least not like windows, to add things to path permanently you need to add them to the configuration of the shell you are using, which I have done.

Just guessing here...

Can you add Avant Garde to your shell, and then launch Avant Garde from your shell?

@dusrdev
Copy link
Author

dusrdev commented Dec 16, 2023

Looking at the code you sent, the issue is exactly this, when a process is started with filename it looks for it in the path, and it doesn't use the shell so this is no fix.

I tried 2 solutions:

  1. Creating a symlink for the dotnet cli in the documents folder (Easy workaround for people who use a mac, but unfortunately did not work...)
  2. Hardcoded the default dotnet path since I am building the mac version myself:
var info = new ProcessStartInfo
{
    Arguments = args,
    CreateNoWindow = true,
    FileName = @"/usr/local/share/dotnet/dotnet",
    RedirectStandardOutput = true,
    RedirectStandardError = true,
    UseShellExecute = false,

    // IMPORTANT: Needed for Flatpak (found with trial and error)
    WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
};

And that absolutely worked and fixed the issue. By the way it appears that /usr/local/share/dotnet/dotnet is the default installation path for dotnet on a mac.

However, I think the best solution would be to add a textbox for the "path to dotnet cli" inside the AvantGarde application preferences in the UI, then modify the code so that the filename will be computed kind of like this:

var filenameFromPreferences = // Get path from preferences
var filename = string.IsNullOrWhiteSpace(filenameFromPreferences) ? "dotnet" : filenameFromPreferences;

// and then proceed to use it with:

var info = new ProcessStartInfo
{
    ...
    FileName = filename,
    ...
};

Then if it doesn't find the dotnet cli it has something to fall back to, and furthermore, it won't require have the dotnet in path in any os, since the user will be able to just point AvantGarde to the correct location. easy enough fix and won't be platform specific so it's not a hassle.

@kuiperzone
Copy link
Owner

Can you do

echo $DOTNET_HOST_PATH

and tell me what you get?

@kuiperzone
Copy link
Owner

It does indeed transpire that you have a $PATH variable on MacOS, and MS documents how to set it when installing dotnet for Mac:

https://learn.microsoft.com/en-us/dotnet/core/install/macos

You may need to learn where to set it permanently. On Linux, there will be in ~/.bash_profile or ~/.bashrc. There will be some equivalent on Mac. I cannot help you further than that, but best of luck with it.

In any case, in v1.4, Avant Garde will detect $DOTNET_HOST_PATH and use that if set.

@dusrdev
Copy link
Author

dusrdev commented Dec 17, 2023

Again, there isn't a $path variable in MacOS, there is a $path variable inside the shells you are using. But launching a new process in c# with ProcessStartInfo doesn't use the shell the launch the application, instead just straight through a path. Which is why it doesn't recognize it.

As for your question $DOTNET_HOST_PATH isn't set for me, and there doesn't seem to be a clear instruction on how to set, nor did I need to, every other application using dotnet, including vscode, visual studio for mac, jetbrains rider, all seem to work fine without it being set in my system. So, this isn't a general setup issue.

Regardless, crawling throught the docs will take more time than to implement the simple fix I posted above. Which I did for myself since I use my personal build. I no longer have an issue but any other potential MacOS users of AvantGarde probably will, and that defeats the whole description of AvantGarde:

Avant Garde is a cross-platform....

It isn't really cross-platform if it doesn't work on one of the platforms.

@kuiperzone
Copy link
Owner

Thank you for your input on this.

I never intended to support Mac, although I was pleased when I heard a report that it worked without issue. Which, BTW, makes me wonder how it worked for others but not in your case?

The problem is I do not understand why I would be making this change, or whether there is a better and accepted alternative in these scenarios.

It may be that there is a limitation with StartProcess on MacOS. It may be that, in certain scenarios, a full path to the binary is needed. When I understand this, I may consider adding such a feature if $DOTNET_HOST_PATH does not suffice.

Regardless, crawling throught the docs will take more time than to implement the simple fix I posted above.

More time for who? It sounds like you want me to implement a "fix" so you don't have to read the docs for your own system. I don't add features for these reasons.

Avant Garde is GPL. You are of course free to clone it and create a Mac centric version if you wish, and I would be happy to respond to questions concerning it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants