[GH-ISSUE #394] [Bug] Problem when xdg-user-dirs in not installed #181

Closed
opened 2026-03-23 20:33:31 +00:00 by mirror · 1 comment
Owner

Originally created by @MikeWallaceDev on GitHub (Feb 27, 2022).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/394

I'm rebuilding this issue from a PR that was not accepted. ( #156 )

Describe the bug
AppFlowy throws an Unhandled Exception error when xdg-user-dirs isn't installed.

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: ProcessException: Failed to find "xdg-user-dir" in the search path.
  Command: xdg-user-dir 
#0      LocalProcessManager.runSync (package:process/src/interface/local_process_manager.dart:118)
#1      getUserDirectory (package:xdg_directories/xdg_directories.dart:154)
#2      PathProviderLinux.getApplicationDocumentsPath (package:path_provider_linux/path_provider_linux.dart:55)
#3      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:138)
#4      InitRustSDKTask.initialize (package:app_flowy/startup/tasks/init_sdk.dart:16)
#5      AppLauncher.launch (package:app_flowy/startup/launcher.dart:36)
#6      System.run (package:app_flowy/startup/startup.dart:54)
#7      main (package:app_flowy/main.dart:17)
<asynchronous suspension>

To Reproduce
Steps to reproduce the behavior:

  1. Try to run AF on a flavor of Linux that does not have xdg-user-dirs installed.

Expected behavior
App just runs...

Screenshots
None

Desktop (please complete the following information):

  • OS: Linux (any)
  • Browser: N/A
  • Version 0.0.2

Additional context
@appflowy I looked at the code and it is possible that the xdg_directories package (used by the path_provider package) throws an Exception if xdg-usr-dirs is not found. In fact, path_provider throws a different exception if a path isn't found. Neither of these exceptions are dealt with in AF.

I'm not sure how to proceed here.

I don't think that we should add a dependency to xdg-usr-dirs in the BUILD_ON_LINUX.md document because if xdg-usr-dirs isn't there it's probably because there is something weird going on (maybe the person is trying to install on a server version of Linux!). If xdg-usr-dirs isn't there, the user's Desktop Environment doesn't use it, I don't think we should install it.
I don't know what to do if we do trap that Exception, can we create a directory somewhere?? (It's a cross platform question, so difficult to answer)
I do think that our initialization process should catch errors so that the app quits gracefully. But I don't know where you want to place that code.
I do think that we should encapsulate path_provider so that we can easily switch it out if/WHEN something better comes along. But I don't know if you agree with that :)

Originally created by @MikeWallaceDev on GitHub (Feb 27, 2022). Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/394 I'm rebuilding this issue from a PR that was not accepted. ( #156 ) **Describe the bug** AppFlowy throws an Unhandled Exception error when xdg-user-dirs isn't installed. ``` [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: ProcessException: Failed to find "xdg-user-dir" in the search path. Command: xdg-user-dir #0 LocalProcessManager.runSync (package:process/src/interface/local_process_manager.dart:118) #1 getUserDirectory (package:xdg_directories/xdg_directories.dart:154) #2 PathProviderLinux.getApplicationDocumentsPath (package:path_provider_linux/path_provider_linux.dart:55) #3 getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:138) #4 InitRustSDKTask.initialize (package:app_flowy/startup/tasks/init_sdk.dart:16) #5 AppLauncher.launch (package:app_flowy/startup/launcher.dart:36) #6 System.run (package:app_flowy/startup/startup.dart:54) #7 main (package:app_flowy/main.dart:17) <asynchronous suspension> ``` **To Reproduce** Steps to reproduce the behavior: 1. Try to run AF on a flavor of Linux that does not have xdg-user-dirs installed. **Expected behavior** App just runs... **Screenshots** None **Desktop (please complete the following information):** - OS: Linux (any) - Browser: N/A - Version 0.0.2 **Additional context** @appflowy I looked at the code and it is possible that the xdg_directories package (used by the path_provider package) throws an Exception if xdg-usr-dirs is not found. In fact, path_provider throws a different exception if a path isn't found. Neither of these exceptions are dealt with in AF. I'm not sure how to proceed here. I don't think that we should add a dependency to xdg-usr-dirs in the BUILD_ON_LINUX.md document because if xdg-usr-dirs isn't there it's probably because there is something weird going on (maybe the person is trying to install on a server version of Linux!). If xdg-usr-dirs isn't there, the user's Desktop Environment doesn't use it, I don't think we should install it. I don't know what to do if we do trap that Exception, can we create a directory somewhere?? (It's a cross platform question, so difficult to answer) I do think that our initialization process should catch errors so that the app quits gracefully. But I don't know where you want to place that code. I do think that we should encapsulate path_provider so that we can easily switch it out if/WHEN something better comes along. But I don't know if you agree with that :)
Author
Owner

@AkechiShiro commented on GitHub (Oct 23, 2022):

I've hit this issue on the latest release, I can confirm the fix is working.

<!-- gh-comment-id:1288195491 --> @AkechiShiro commented on GitHub (Oct 23, 2022): I've hit this issue on the latest release, I can confirm the fix is working.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#181
No description provided.