conda / menuinst

Cross platform menu item installation
https://conda.github.io/menuinst/
BSD 3-Clause "New" or "Revised" License
33 stars 41 forks source link

%HOMEPATH% does not contain the drive name #211

Closed dokempf closed 1 month ago

dokempf commented 1 month ago

Checklist

What happened?

In the absence of the working_dir key, on Windows, menuinst uses %HOMEPATH% as the default. However, I have stumbled over this on a system, where the home was not on the C: drive. In order to also get the drive, one would need to use %HOMEDRIVE%. When googling to find a solution, I also stumbled over a number of reports that these two variables may not be set in some circumstances.

I would therefore suggest to maybe use %USERPROFILE% for that purpose. Apparently, it is always set to a full path.

Conda Info

No response

Conda Config

No response

Conda list

No response

Additional Context

No response

marcoesters commented 1 month ago

There are two (not mutually exclusive) ways to go about this:

I think the latter should definitely be done. Whether %USERPROFILE%, which I think is %SYSTEMDRIVE%\Users\%USERNAME%, or %HOMEDRIVE%%HOMEPATH% is the better default, I'm not quite sure yet.

I do think we should definitely implement the second point though. In that case, you could set working_dir to %USERPROFILE% in your recipe and it would work.

dokempf commented 1 month ago

I do think we should definitely implement the second point though. In that case, you could set working_dir to %USERPROFILE% in your recipe and it would work.

Wouldn't that work anyway? The rendering is delayed until execution, but Windows then does it. At least, that is what I manually tested by manipulating the shortcut.

If you want me to contribute a PR here, please let me know.

marcoesters commented 1 month ago

For the execution, yes, but looking at this issue, I found a small bug that creates and unwanted directory : https://github.com/conda/menuinst/blob/main/menuinst/platforms/win.py#L161-L162

I think from what I'm reading %HOMEDRIVE%%HOMEPATH% is what's the "canonical" home directory and I am currently thinking that this should stay the default. You are right though that %HOMEDRIVE% needs to be added.

If you want me to contribute a PR here, please let me know.

You are welcome to do so if you have the time. I just assigned the issue to myself to fix it, but I'm happy to have you take over. Just let me know so we don't interfere with each other.

dokempf commented 1 month ago

If you're on it already, it sure is more efficient for you to do it. I just wanted to express my willingness to contribute.