iterate-ch / cyberduck

Cyberduck is a libre FTP, SFTP, WebDAV, Amazon S3, Backblaze B2, Microsoft Azure & OneDrive and OpenStack Swift file transfer client for Mac and Windows.
https://cyberduck.io/
GNU General Public License v3.0
3.27k stars 290 forks source link

System.ArgumentException: Illegal characters in path when launched using Wine #15520

Open CodeShakingSheep opened 9 months ago

CodeShakingSheep commented 9 months ago

Describe the bug Cyberduck crashes at launch. It doesn't even start. There is no UI to be seen.

To Reproduce Steps to reproduce the behavior:

  1. Run Cyberduck with Wine (double-click on Cyberduck.exe or run commmand wine Cyberduck.exe on Ubuntu.
  2. Watch it do nothing.

Expected behavior Cyberduck should launch successfully.

Screenshots None as there is no UI to be seen.

Desktop (please complete the following information):

Log Files Log file generated with wine Cyberduck.exe &>log.txt. log.txt

I believe this part is relevant.

  at Ch.Cyberduck.Core.Preferences.Runtime.CreateDefault (System.Reflection.Assembly runtimeAssembly) [0x0008d] in <d9bdc6c4a751452e938cb121adaa7639>:0 
  at Ch.Cyberduck.Core.Preferences.Runtime.CreateDefault[T] () [0x0000f] in <d9bdc6c4a751452e938cb121adaa7639>:0 
  at Ch.Cyberduck.Ui.Core.AppRuntime..ctor () [0x00000] in <568bef9f34524aba8621d27ebccb040a>:0 
  at Ch.Cyberduck.Ui.StructureMapBootstrapper+<>c.<Bootstrap>b__0_2 () [0x00000] in <568bef9f34524aba8621d27ebccb040a>:0 
  at StructureMap.Pipeline.LambdaInstance`1+<>c__DisplayClass8[T].<.ctor>b__6 (StructureMap.IContext s) [0x00000] in <83a7d1b804604d09a8cf4b79b42db77f>:0 
  at StructureMap.Pipeline.LambdaInstance`1[T].build (System.Type pluginType, StructureMap.BuildSession session) [0x00000] in <83a7d1b804604d09a8cf4b79b42db77f>:0 
   --- End of inner exception stack trace ---

Additional context It seems to be the same error message as here https://github.com/iterate-ch/cyberduck/issues/11911. So, may be the same fix can be applied.

FYI: I'm running on Ubuntu derivative with Wine.

dkocher commented 9 months ago

Please test with the current snapshot build which has #12590 applied.

AliveDevil commented 9 months ago

This is duplicate of #15376, fixed in #15377 to be included in next release.

I don't know how Wine has implemented folder redirection/well-known folders, but basically make sure that the Downloads-folder exists in your Wine user profile directory.

CodeShakingSheep commented 9 months ago

Thank you for the support. Today, I just updated Cyberduck to 8.7.3 as I assumed that the fix will be contained. However, I still have the same error:

Unhandled Exception:
StructureMap.StructureMapException: StructureMap Exception Code:  207
Internal exception while creating Instance '8451cf86-d10e-41fd-b1d7-212bb3e91a61' of PluginType ch.cyberduck.core.preferences.Preferences, Cyberduck.Core, Version=8.7.3.40979, Culture=neutral, PublicKeyToken=null.  Check the inner exception for more details. ---> StructureMap.StructureMapException: StructureMap Exception Code:  207

Here's the full log: logd.txt

I checked my Wine user profile directory. It's ~/.wine/drive_c/users/{USER_NAME}/Downloads while Downloads seems to link to my Linux user's real download directory. This should be good, right? I also have a public user and I created its download folder too ~/.wine/drive_c/users/Public/Downloads

What else can I do to make it run? Still worth testing the snapshot build @dkocher mentioned? Thank you for support.

AliveDevil commented 9 months ago

We are getting into the weeds with IKVM and Wine. It is crashing in this part FastCharsetProvider.java#121, which is failing at the boundary of IKVM to .NET for emitting dynamic code^1 (at ab.DefineDynamicModule).

To resolve this, you may check whether removing the "~"-character and specifying an absolute path in all paths (tmp, userprofile, appdata, localappdata, etc.) resolves the issues you are seeing - though I'm not entirely sure this'll help you.

Either way, this will require extensive amounts of work to be compatible with Wine, especially as this looks like an issue within IKVM, not Cyberduck.

CodeShakingSheep commented 9 months ago

Thanks for getting back to this @AliveDevil . The absolute path of my Wine user profile directory is /home/{USER_NAME}/.wine/drive_c/users/{USER_NAME}/Downloads . Where can I modify all paths (tmps, userprofile, appdata, localappdata) for Cyberduck?

In /home/{USER_NAME}/.wine/drive_c/Program Files/Cyberduck I can see Cyberduck.exe.config but there are no paths specified in this file. Can you point me in the right direction?

AliveDevil commented 9 months ago

After a chat with people over at https://github.com/ikvmnet/ikvm it turns out that the stack trace you posted is actually from Mono, which has a bug in the linked method DefineDynamicModule. Also mono/mono#21601

Can you please verify that you have at least winetricks dotnet472 installed?

The paths were just a guess, which don't need changes.

CodeShakingSheep commented 9 months ago

Thanks for the investigation. I don't have winetricks installed yet. I have installed Wine Mono. Using latest version 8.1.0 . These are the installed packages.

image

I will take time later today and install winetricks.

CodeShakingSheep commented 9 months ago

Reporting back from installing winetricks as described on https://wiki.winehq.org/Winetricks . Unfortunately, it doesn't seem to work as expected. This is the warning message warning: wine cmd.exe /c echo '%AppData%' returned empty string, error message "" . I researched it and it led me to

So apparently, this seems to be a bug in winetricks.

Nevertheless, I think winetricks isn't needed necessarily as I have Wine Mono already installed. When I tried to run Cyberduck with wine for the first time I had this error CLRRuntimeInfo_GetRuntimeHost Wine Mono is not installed. I could solve this with the accepted answer from https://askubuntu.com/questions/841847/mono-package-for-wine-is-not-installed . Afterwards the error message changed to the one, I reported here. So, I believe Wine Mono installation should be good.

So, I can only wait for the bugfix in Wine Mono / ikvm or are there any other possible solutions / workarounds?

AliveDevil commented 9 months ago

So, I created a fresh OpenSuse 15.5 Leap VM, installed wine, winetricks and with that both dotnet40 and dotnet48, set the Wine-emulated version to Windows 10, and installed Cyberduck. This worked fine, until it tried loading types through WinRT:

0128:err:eventlog:ReportEventW L"Application: Cyberduck.exe\nFramework Version: v4.0.30319\nDescription: The process was terminated due to an unhandled exception.\nException Info: System.TypeLoadException\n   at Ch.Cyberduck.Core.Preferences.LocalSharedFileSettingsProvider..ctor()\n\nException Info: System.Reflection.Tar"...
0128:fixme:advapi:DeregisterEventSource (00000000CAFE4242) stub

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not find Windows Runtime type 'Windows.Storage.ApplicationData'.
   at Ch.Cyberduck.Core.Preferences.LocalSharedFileSettingsProvider..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
   at System.SecurityUtils.SecureCreateInstance(Type type, Object[] args, Boolean allowNonPublic)
   at System.Configuration.ApplicationSettingsBase.get_Initializer()
   at System.Configuration.ApplicationSettingsBase.CreateSetting(PropertyInfo propInfo)
   at System.Configuration.ApplicationSettingsBase.EnsureInitialized()
   at System.Configuration.ApplicationSettingsBase.get_Properties()
   at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
   at System.Configuration.SettingsBase.get_Item(String propertyName)
   at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
   at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
   at Ch.Cyberduck.Properties.SharedSettings.get_CdSettings()
   at Ch.Cyberduck.Core.Preferences.ApplicationPreferences.get_Shared()
   at Ch.Cyberduck.Core.Preferences.ApplicationPreferences.load()
   at ch.cyberduck.core.preferences.PreferencesFactory.set(Preferences p)
   at Ch.Cyberduck.Ui.Program.Main(String[] args)

e.g. need not to inline this method-call, as all types are preloaded at entry of method, thus it tries to load Windows Runtime-Types that aren't available in Wine.

This particular issue could be fixed, but highlights several issues you'll run into when trying to emulate Cyberduck through Wine - there are several assumptions made in the Cyberduck Windows sources, that may crash or are not implemented, to the point, where it is impossible to use Cyberduck at all.

dkocher commented 8 months ago

Relates to #6061.

CodeShakingSheep commented 8 months ago

@AliveDevil Thank you for your efforts to install and run Cyberduck with Wine. I could successfully fix my Winetricks installation applying this manual fix https://github.com/Winetricks/winetricks/issues/2119#issuecomment-1793812033 . Afterwards I installed dotnet40 and dotnet48 with Winetricks as you suggested.

Still, when launching Cyberduck I still have the same error. Did you use a Wine 64 bit prefix or Wine 32 bit prefix? I'm using a 64 bit prefix. Might give it a shot with a 32 bit prefix again.

However, if Cyberduck still won't be usable with Wine due to the Windows sources assumptions that's definitely a blocker. I just need Cyberduck on Linux to view the contents of my remote Cryptomator vaults (on WebDav). Don't even need to download or upload files. Just viewing them would be enough in the first place. Do you think this is possible with Wine launched Cyberduck?

If not, I'd also strongly vouch for a native Linux version of Cyberduck, as in #6061. Would also be willing to donate for that. How realistic is it that you guys could put that to the roadmap for this year? Thanks for an estimation.

dkocher commented 8 months ago

I just need Cyberduck on Linux to view the contents of my remote Cryptomator vaults (on WebDav). Don't even need to download or upload files.

I suggest to use Cryptomator for Linux.

If not, I'd also strongly vouch for a native Linux version of Cyberduck, as in #6061. Would also be willing to donate for that. How realistic is it that you guys could put that to the roadmap for this year? Thanks for an estimation.

It is not realistic. It would require someone to step up and wanting to implement the user interface in Linux. This might be more straight forward when we rewrite the current user interface implementation for Windows using XAML/WinUI frameworks ^2 that might be reusable on Linux.

CodeShakingSheep commented 8 months ago

I just need Cyberduck on Linux to view the contents of my remote Cryptomator vaults (on WebDav). Don't even need to download or upload files.

I suggest to use Cryptomator for Linux.

I already use Cryptomator for Linux. The issue is that I have really big vaults with several 100 GB stored in my cloud. I can't download all of them locally because of limited space on my notebook. However, I started to restructure my remote vaults and make them smaller using Cyberduck on Windows. I wanted to continue to do that on Linux but then apparently for now I need to switch back to Windows to accomplish that task.

If not, I'd also strongly vouch for a native Linux version of Cyberduck, as in #6061. Would also be willing to donate for that. How realistic is it that you guys could put that to the roadmap for this year? Thanks for an estimation.

It is not realistic. It would require someone to step up and wanting to implement the user interface in Linux. This might be more straight forward when we rewrite the current user interface implementation for Windows using XAML/WinUI frameworks 1 that might be reusable on Linux.

That's sad to read. If ever it gets put on the roadmap I would be willing to contribute financially and code-wise.

CodeShakingSheep commented 7 months ago

I just gave this issue another try and tried to run Cyberduck using Bottles on Ubuntu 22.04 LTS which looks more promising than my last attempt. At least I don't run into the error I initially posted here. However, I run into another one and Cyberduck still doesn't launch.

00fc:err:ole:CoGetContextToken apartment not initialised
00f4:err:combase:RoGetActivationFactory Failed to find library for L"Windows.ApplicationModel.DesignMode"
00f4:err:eventlog:ReportEventW L"Application: Cyberduck.exe\nFramework Version: v4.0.30319\nDescription: The process was terminated due to an unhandled exception.\nException Info: System.TypeLoadException\n   at Ch.Cyberduck.Core.Preferences.LocalSharedFileSettingsProvider..ctor()\n\nException Info: System.Reflection.Tar"...

My bottle runs with Win64 and soda-8.0-2 having dotnet40 and dotnet48 and mono installed. I'm glad for any hint about the new error.

AliveDevil commented 7 months ago

Should be the same issue as mentioned here.

Cyberduck isn't "just" using Win32 APIs, that are available in Wine, but makes extensive use of several Windows Runtime-types (introduced between Windows 8 and Windows 11), that may not be available in Wine at the moment. Some other parts, that I'm not sure are implemented completely: