geluk / pass-winmenu

An easy-to-use password manager for Windows, compatible with pass.
MIT License
385 stars 25 forks source link

Error message "The path is not of a legal form" when launching nogpg version #42

Closed machetto closed 5 years ago

machetto commented 5 years ago

pass-winmenu failed to start (ArgumentException: The path is not of a legal form.)

geluk commented 5 years ago

It could be that the path you entered in the yaml file is not formed correctly, can you share it so I can take a look at it?

machetto commented 5 years ago

The path is as follows: location: 'C:\git\pass\.password-store'

A bit unrelated question.. Is it possible to configure the program to use the Git's GPG (located in "C:\Program Files\Git\usr\bin") instead of installing Gpg4Win? It would be handy for users on corporate machines where they are restricted what they can install.

geluk commented 5 years ago

That path looks fine. Can you add the following line at the bottom of your pass-winmenu.yaml and share the log file (created in the same directory)?

create-log-file: true

As for your second question, yes, you can use the GPG installed by Git by explicitly providing the path to the executable in gpg-path in pass-winmenu.yaml. In your case, like this:

gpg-path: 'C:\Program Files\Git\usr\bin\gpg.exe'

Alternatively, you can add the directory containing gpg.exe to your PATH, and in pass-winmenu.yaml simply specify:

gpg-path: 'gpg'

(This is the default setting for the nogpg release)

machetto commented 5 years ago
machetto commented 5 years ago

Explicitly setting a path to GPG fixed the problem:

gpg-path: 'C:\Program Files (x86)\GnuPG\bin\gpg.exe'

Not sure why as C:\Program Files (x86)\GnuPG\bin is in the PATH variable.

geluk commented 5 years ago

Which version of pass-winmenu are you using? Older versions don't have the logging feature implemented.

In any case, this looks like a bug in the GPG location detection code; I'll investigate it.

geluk commented 5 years ago

It looks like no error log is created if an error occurs too early, I've created a new build which should correctly generate the log file in that case.

Would you mind changing your configuration file back so it fails again, and testing it with this updated build? You can download it here: https://ci.appveyor.com/api/buildjobs/8hqyllqa1pao3swq/artifacts/pass-winmenu%2Fbin%2FRelease%2Fpass-winmenu.exe

Just rename it, place it next to your current pass-winmenu executable, and run it (after you've changed back your configuration file so it fails again, of course).

machetto commented 5 years ago

I used the latest version. Here is the log's content:

[07:33:02.310] [DBG] ------------------------------
[07:33:02.325] [DBG] Starting pass-winmenu v1.9-9-ge4eb079
[07:33:02.325] [DBG] ------------------------------
[07:33:02.528] [DBG] Config reloading enabled
[07:33:02.544] [DBG] Attempting to detect the GPG installation directory
[07:33:02.544] [ERR] Could not start pass-winmenu: An exception occurred.
[07:33:02.560] ArgumentException (The path is not of a legal form.) in :0:0
[07:33:02.560]   -> in System.IO.Path.NewNormalizePath -- :0:0
[07:33:02.560]   -> in System.IO.Path.NormalizePath -- :0:0
[07:33:02.560]   -> in System.IO.Path.GetFullPathInternal -- :0:0
[07:33:02.560]   -> in System.IO.Abstractions.PathWrapper.GetFullPath -- :0:0
[07:33:02.560]   -> in System.Linq.Enumerable+WhereSelectArrayIterator`2.MoveNext -- :0:0
[07:33:02.560]   -> in PassWinmenu.WinApi.ExecutablePathResolver.FindInPath -- :0:0
[07:33:02.560]   -> in PassWinmenu.ExternalPrograms.GPG.FindGpgInstallation -- :0:0
[07:33:02.560]   -> in PassWinmenu.Program.Initialise -- :0:0
[07:33:02.560]   -> in PassWinmenu.Program..ctor -- :0:0
[07:33:06.891] [DBG] Shutting down.
geluk commented 5 years ago

Thanks! I have found the issue, it looks like the code for parsing the PATH environment variable isn't very robust. Possibly your environment variable contains some spaces or double semicolons.

I've made a new build that's able to handle those cases as well as skipping any paths that don't look correct.

Could you download it and confirm if it's able to detect GPG's location from your PATH now?

machetto commented 5 years ago

Great! Where do I download it from? Cannot find it at https://github.com/Baggykiin/pass-winmenu/releases

geluk commented 5 years ago

I forgot to include the download link, here it is: https://ci.appveyor.com/api/buildjobs/09eon5fthabl4rjq/artifacts/pass-winmenu%2Fbin%2FRelease%2Fpass-winmenu.exe

machetto commented 5 years ago

Ok, ran the new file and now getting: "The git2 DLL could not be found. Git support will be disabled". Log's content:

[11:23:13.164] [DBG] ------------------------------
[11:23:13.164] [DBG] Starting pass-winmenu v1.9-12-g20a0a54
[11:23:13.164] [DBG] ------------------------------
[11:23:13.335] [DBG] Config reloading enabled
[11:23:13.335] [DBG] Attempting to detect the GPG installation directory
[11:23:13.351] [DBG] GPG executable found at the configured path. Assuming installation dir to be C:\Program Files (x86)\GnuPG\bin
C:\programs\pass-winmenu.nogpg>dir /S /B
C:\programs\pass-winmenu.nogpg\lib
C:\programs\pass-winmenu.nogpg\pass-winmenu.exe
C:\programs\pass-winmenu.nogpg\pass-winmenu.log
C:\programs\pass-winmenu.nogpg\pass-winmenu.yaml
C:\programs\pass-winmenu.nogpg\lib\win32
C:\programs\pass-winmenu.nogpg\lib\win32\x64
C:\programs\pass-winmenu.nogpg\lib\win32\x86
C:\programs\pass-winmenu.nogpg\lib\win32\x64\git2-15e1193.dll
C:\programs\pass-winmenu.nogpg\lib\win32\x86\git2-15e1193.dll
geluk commented 5 years ago

That's because in that version the Git library got updated, so it expects a different DLL. If you try downloading the full zip file and replacing the lib directory it will work, but the older version would stop working in that case.

If you'd like to continue using this build, you can get the zip file from here: https://ci.appveyor.com/api/buildjobs/09eon5fthabl4rjq/artifacts/pass-winmenu%2Fbin%2Fpass-winmenu-nogpg.zip

Otherwise, you can ignore the warning.

machetto commented 5 years ago

OK, everything works now! BTW, when I launch the program sometimes, I can see a message (intermittent) saying it is unable to register hot keys. Cannot reproduce it now.. just fyi.

geluk commented 5 years ago

Glad it works now! That hotkey error will happen if one of the hotkeys was already registered by a different application. Starting the application twice will trigger it, for instance. If that isn't the case, feel free to open a new issue.