Flatpak Joplin won't launch vim but other external editors work just fine

Version: Joplin 2.3.5 (prod, linux)
OS: Manjaro ARM Linux aarch64

I installed Flatpak Joplin desktop on my raspberry pi. I can use emacs, gedit as an external editor except for vim. All of them are Flatpak applications too. I don't understand why vim is not working.

I found working path and arguments for Flatpak below on this post.

Path: 
/bin/flatpak-spawn
Arguments: 
--host /bin/flatpak run --filesystem=xdg-config/joplin-desktop org.gnu.emacs

Replacing application ID in the end of the arguments launches respective application.

I tried gedit and emacs and both of them seem to work fine except for vim. I made sure I exactly wrote org.vim.Vim like below.

--host /bin/flatpak run --filesystem=xdg-config/joplin-desktop org.vim.Vim

I don't see any difference when it launches emacs and later doesn't launch vim (after changing the arguments of course) in debug log. What could be causing this?

2021-09-19 17:37:40: App: "Profile directory: /home/archerry/.config/joplin-desktop"
2021-09-19 17:37:40: "Database was open successfully"
2021-09-19 17:37:40: "Checking for database schema update..."
2021-09-19 17:37:40: "Current database version", "{"version":39,"table_fields_version":39}"
2021-09-19 17:37:40: "Upgrading database from version 39"
2021-09-19 17:37:40: "New version: 39. Previously recorded version: 39"
2021-09-19 17:37:40: "KeychainService: checking if keychain supported"
2021-09-19 17:37:40: "KeychainService: check was already done - skipping. Supported:", "0"
2021-09-19 17:37:40: handleSyncStartupOperation: "Processing operation:", "0"
2021-09-19 17:37:40: App: "Client ID: 85be36ec2c4a4f57a0613da999405c5c"
2021-09-19 17:37:40: e2ee/utils: "Trying to load 0 master keys..."
2021-09-19 17:37:40: e2ee/utils: "Loaded master keys: 0"
2021-09-19 17:37:40: "ResourceFetcher: Auto-add resources: Mode: always"
2021-09-19 17:37:40: "ResourceFetcher: Auto-added resources: 0"
2021-09-19 17:37:40: App: ""syncInfoCache" was changed - setting up encryption related code"
2021-09-19 17:37:40: e2ee/utils: "Trying to load 0 master keys..."
2021-09-19 17:37:40: e2ee/utils: "Loaded master keys: 0"
2021-09-19 17:37:40: "Scheduling sync operation...", "10000"
2021-09-19 17:37:40: "Setting up recurrent sync with interval 300"
2021-09-19 17:37:40: App: ""syncInfoCache" was changed - setting up encryption related code"
2021-09-19 17:37:40: e2ee/utils: "Trying to load 0 master keys..."
2021-09-19 17:37:40: e2ee/utils: "Loaded master keys: 0"
2021-09-19 17:37:40: "Scheduling sync operation...", "10000"
2021-09-19 17:37:40: "app.start: doing regular boot"
2021-09-19 17:37:41: App: "Refreshing notes:", "null", "null"
2021-09-19 17:37:41: App: ""syncInfoCache" was changed - setting up encryption related code"
2021-09-19 17:37:41: e2ee/utils: "Trying to load 0 master keys..."
2021-09-19 17:37:41: e2ee/utils: "Loaded master keys: 0"
2021-09-19 17:37:41: "Scheduling sync operation...", "10000"
2021-09-19 17:37:41: "Setting up recurrent sync with interval 300"
2021-09-19 17:37:41: App: ""syncInfoCache" was changed - setting up encryption related code"
2021-09-19 17:37:41: e2ee/utils: "Trying to load 0 master keys..."
2021-09-19 17:37:41: e2ee/utils: "Loaded master keys: 0"
2021-09-19 17:37:41: "Scheduling sync operation...", "10000"
2021-09-19 17:37:41: App: "Refreshing notes:", "2", "8bf8abbea69c4900ab21fbc1300c5234"
2021-09-19 17:37:41: "Scheduling sync operation...", "1000"
2021-09-19 17:37:41: RevisionService: "RevisionService::runInBackground: Starting background service with revision collection interval 600000"
2021-09-19 17:37:41: "DecryptionWorker: cannot start because no master key is currently loaded."
2021-09-19 17:37:41: "Saving settings..."
2021-09-19 17:37:42: "Preparing scheduled sync"
2021-09-19 17:37:42: "Starting scheduled sync"
2021-09-19 17:37:42: Synchronizer: "Sync: starting: Starting synchronisation to target 6... supportsAccurateTimestamp = false; supportsMultiPut = false [1632051462688]"
2021-09-19 17:37:42: Synchronizer: "Indexing resources..."
2021-09-19 17:37:42: "ResourceService::indexNoteResources: Start"
2021-09-19 17:37:42: PluginService: "Loading plugin from /home/archerry/.config/joplin-desktop/cache/com.github.joplin.kanban"
2021-09-19 17:37:43: "Settings have been saved."
2021-09-19 17:37:43: SpellCheckerServiceDriverNative: "Set effective language from "en-US" to "en-US""
2021-09-19 17:37:49: "Loading existing note", "b5b81f69cd324b078ea5aa1413116a4e"
2021-09-19 17:37:51: RevisionService: "RevisionService::maintenance: Starting..."
2021-09-19 17:37:51: RevisionService: "RevisionService::maintenance: Service is enabled"
2021-09-19 17:37:51: "SearchEngine: Updating FTS table..."
2021-09-19 17:37:51: "Saving settings..."
2021-09-19 17:37:51: PluginRunner: "Got message (3): joplin.settings.globalValue", "["profileDir"]"
2021-09-19 17:37:51: PluginRunner: "Got message (3): joplin.plugins.register", "[{}]"
2021-09-19 17:37:51: joplin.plugins: "Starting plugin: com.github.joplin.kanban"
2021-09-19 17:37:51: "Loaded note:", "{"id":"b5b81f69cd324b078ea5aa1413116a4e","parent_id":"8bf8abbea69c4900ab21fbc1300c5234","title":"Aug 17, 2021 ","body":"Tuesday, 9:33 PM\n\n\n\n\n\n\n","created_time":1629715012309,"updated_time":1631979502638,"is_conflict":0,"latitude":"22.39480000","longitude":"11.83650000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin","source_application":"net.cozic.joplin-cli","application_data":"","order":1630477998509,"user_created_time":1629715012309,"user_updated_time":1631979502638,"encryption_cipher_text":"","encryption_applied":0,"markup_language":1,"is_shared":0,"share_id":"","conflict_original_id":"","type_":1}"
2021-09-19 17:37:51: "ResourceService::indexNoteResources: Completed"
2021-09-19 17:37:52: PluginRunner: "Got message (3): joplin.workspace.onNoteSelectionChange", "[null]"
2021-09-19 17:37:52: PluginRunner: "Got message (3): joplin.workspace.onNoteChange", "[null]"
2021-09-19 17:37:52: joplin.plugins: "Finished running onStart handler: com.github.joplin.kanban (Took 1385ms)"
2021-09-19 17:37:53: PluginRunner: "Got message (3): joplin.data.get", "[["notes","b5b81f69cd324b078ea5aa1413116a4e"],{"fields":["id","title","parent_id","body"]}]"
2021-09-19 17:37:53: "Saving settings..."
2021-09-19 17:37:53: models/Folder: "updateFolderShareIds:", "{"shareUpdateCount":0,"unshareUpdateCount":0}"
2021-09-19 17:37:53: "SearchEngine: Updated FTS table in 2000ms. Inserted: 0. Deleted: 0"
2021-09-19 17:37:53: RevisionService: "RevisionService::collectRevisions: Created revisions for 0 notes"
2021-09-19 17:37:53: models/Folder: "updateNoteShareIds: notes to update:", "0"
2021-09-19 17:37:53: RevisionService: "RevisionService::maintenance: Done in 2888ms"
2021-09-19 17:37:53: models/Folder: "updateResourceShareIds: resources to update:", "0"
2021-09-19 17:37:53: FileApi: "get info.json"
2021-09-19 17:37:55: "Settings have been saved."
2021-09-19 17:37:55: "Settings have been saved."
2021-09-19 17:37:56: Synchronizer: "Sync target remote info:", "{"version_":3,"masterKeys_":[],"e2ee_":{"value":false,"updatedTime":0},"activeMasterKeyId_":{"value":"","updatedTime":0}}"
2021-09-19 17:37:56: Synchronizer: "Sync target is already setup - checking it..."
2021-09-19 17:37:56: Synchronizer: "Sync target local info:", "{"version_":3,"masterKeys_":[],"e2ee_":{"value":false,"updatedTime":0},"activeMasterKeyId_":{"value":"","updatedTime":0}}"
2021-09-19 17:37:56: FileApi: "list "
2021-09-19 17:37:56: FileApi: "list "
2021-09-19 17:37:57: FileApi: "put temp/timeCheck188385.txt", "null"
2021-09-19 17:38:11: "ResourceService::indexNoteResources: Start"
2021-09-19 17:38:11: "ResourceService::indexNoteResources: Completed"
2021-09-19 17:38:11: "ResourceService::deleteOrphanResources:", "[]"
2021-09-19 17:38:27: FileApi: "Could not retrieve remote date - defaulting to device date:", "Error: PUT temp/timeCheck188385.txt: File with name /Joplin/temp could not be located (Exception Sabre\DAV\Exception\NotFound) (404): <?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Sabre\DAV\Exception\NotFound</s:exception>
  <s:message>File with name /Joplin/temp could not be located</s:message>
</d:error>

Code: 404
Error: PUT temp/timeCheck188385.txt: File with name /Joplin/temp could not be located (Exception Sabre\DAV\Exception\NotFound) (404): <?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Sabre\DAV\Exception\NotFound</s:exception>
  <s:message>File with name /Joplin/temp could not be located</s:message>
</d:error>

    at newError (/app/joplin-desktop/resources/app/node_modules/@joplin/lib/WebDavApi.js:414:11)
    at WebDavApi.exec (/app/joplin-desktop/resources/app/node_modules/@joplin/lib/WebDavApi.js:441:11)
    at async FileApiDriverWebDav.put (/app/joplin-desktop/resources/app/node_modules/@joplin/lib/file-api-driver-webdav.js:201:10)"
2021-09-19 17:38:27: FileApi: "put locks/sync_desktop_85be36ec2c4a4f57a0613da999405c5c.json", "null"
2021-09-19 17:38:29: FileApi: "list "
2021-09-19 17:38:29: FileApi: "list "
2021-09-19 17:38:32: FileApi: "delta "
2021-09-19 17:38:34: Synchronizer: "BasicDelta: Report: {"timestamp":1632036783000,"older":405,"newer":0,"equal":1}"
2021-09-19 17:38:34: Synchronizer: "Sync: fetchingTotal: Fetching delta items from sync target"
2021-09-19 17:38:34: FileApi: "delete locks/sync_desktop_85be36ec2c4a4f57a0613da999405c5c.json"
2021-09-19 17:38:35: "Saving settings..."
2021-09-19 17:38:35: "Settings have been saved."
2021-09-19 17:38:37: Synchronizer: "Sync: finished: Synchronisation finished [1632051462688]"
2021-09-19 17:38:37: Synchronizer: "Operations completed: "
2021-09-19 17:38:37: Synchronizer: "fetchingTotal: -"
2021-09-19 17:38:38: Synchronizer: "Total folders: 10"
2021-09-19 17:38:38: Synchronizer: "Total notes: 56"
2021-09-19 17:38:38: Synchronizer: "Total resources: 18"
2021-09-19 17:38:38: "Setting up recurrent sync with interval 300"
2021-09-19 17:38:38: "Updating all notifications..."
2021-09-19 17:38:38: "Garbage collecting alarms..."
2021-09-19 17:38:38: "Sync has finished and note has never been changed - reloading it"
2021-09-19 17:38:38: "Saving settings..."
2021-09-19 17:38:38: "Settings have been saved."
2021-09-19 17:38:39: "DecryptionWorker: cannot start because no master key is currently loaded."
2021-09-19 17:38:58: "Saving settings..."
2021-09-19 17:38:59: "Settings have been saved."
2021-09-19 17:39:02: "Loading existing note", "b5b81f69cd324b078ea5aa1413116a4e"
2021-09-19 17:39:02: "Loaded note:", "{"id":"b5b81f69cd324b078ea5aa1413116a4e","parent_id":"8bf8abbea69c4900ab21fbc1300c5234","title":"Aug 17, 2021 ","body":"Tuesday, 9:33 PM\n\nwhy vim donesn't work\n\n\n\n\n","created_time":1629715012309,"updated_time":1631979502638,"is_conflict":0,"latitude":"22.39480000","longitude":"11.83650000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin","source_application":"net.cozic.joplin-cli","application_data":"","order":1630477998509,"user_created_time":1629715012309,"user_updated_time":1631979502638,"encryption_cipher_text":"","encryption_applied":0,"markup_language":1,"is_shared":0,"share_id":"","conflict_original_id":"","type_":1}"
2021-09-19 17:39:03: "Saving settings..."
2021-09-19 17:39:04: "Settings have been saved."
2021-09-19 17:39:09: "CommandService::execute:", "toggleExternalEditing", "[]"
2021-09-19 17:39:09: "CommandService::execute:", "startExternalEditing", "["b5b81f69cd324b078ea5aa1413116a4e"]"
2021-09-19 17:39:10: "ExternalEditWatcher: Event: add: /home/archerry/.config/joplin-desktop/edit-b5b81f69cd324b078ea5aa1413116a4e.md"
2021-09-19 17:39:10: "Started editor with PID 170"
2021-09-19 17:39:10: "ExternalEditWatcher: Started watching /home/archerry/.config/joplin-desktop/edit-b5b81f69cd324b078ea5aa1413116a4e.md"
2021-09-19 17:39:20: "CommandService::execute:", "toggleExternalEditing", "[]"
2021-09-19 17:39:20: "CommandService::execute:", "stopExternalEditing", "["b5b81f69cd324b078ea5aa1413116a4e"]"
2021-09-19 17:39:20: "ExternalEditWatcher: Stopped watching /home/archerry/.config/joplin-desktop/edit-b5b81f69cd324b078ea5aa1413116a4e.md"
2021-09-19 17:39:39: "Saving settings..."
2021-09-19 17:39:40: "Settings have been saved."
2021-09-19 17:39:43: "Loading existing note", "b5b81f69cd324b078ea5aa1413116a4e"
2021-09-19 17:39:43: "Loaded note:", "{"id":"b5b81f69cd324b078ea5aa1413116a4e","parent_id":"8bf8abbea69c4900ab21fbc1300c5234","title":"Aug 17, 2021 ","body":"Tuesday, 9:33 PM\n\nwhy vim doesn't work\n\n\n\n\n","created_time":1629715012309,"updated_time":1631979502638,"is_conflict":0,"latitude":"22.39480000","longitude":"91.83650000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin","source_application":"net.cozic.joplin-cli","application_data":"","order":1630477998509,"user_created_time":1629715012309,"user_updated_time":1631979502638,"encryption_cipher_text":"","encryption_applied":0,"markup_language":1,"is_shared":0,"share_id":"","conflict_original_id":"","type_":1}"
2021-09-19 17:39:44: "Saving settings..."
2021-09-19 17:39:45: "Settings have been saved."
2021-09-19 17:39:45: "CommandService::execute:", "toggleExternalEditing", "[]"
2021-09-19 17:39:45: "CommandService::execute:", "startExternalEditing", "["b5b81f69cd324b078ea5aa1413116a4e"]"
2021-09-19 17:39:45: "ExternalEditWatcher: Event: add: /home/archerry/.config/joplin-desktop/edit-b5b81f69cd324b078ea5aa1413116a4e.md"
2021-09-19 17:39:45: "Started editor with PID 175"
2021-09-19 17:39:45: "ExternalEditWatcher: Started watching /home/archerry/.config/joplin-desktop/edit-b5b81f69cd324b078ea5aa1413116a4e.md"
2021-09-19 17:41:21: "CommandService::execute:", "toggleExternalEditing", "[]"
2021-09-19 17:41:21: "CommandService::execute:", "stopExternalEditing", "["b5b81f69cd324b078ea5aa1413116a4e"]"
2021-09-19 17:41:21: "ExternalEditWatcher: Stopped watching /home/archerry/.config/joplin-desktop/edit-b5b81f69cd324b078ea5aa1413116a4e.md"
2021-09-19 17:41:27: "Saving settings..."
2021-09-19 17:41:27: "Settings have been saved."

I think it's possible that the name isn't explicitly the name of the flatpak ID, but actually it's desktop file (lacking the .desktop extension). I don't think it's common that Vim actually sets up a desktop icon unlike e.g Emacs, so you'd need to create one yourself if one isn't automatically installed.

Hi, I don't know much about linux or software, I found these files here. Are these the desktop files you are talking about? Could you guide me through the process?

thanks for the awesome information.

Funnily enough I'm unable to get the Flatpak Vim working via flatpak-spawn on my machine too. However, since it does have a desktop file, it should appear as an available option if you try use the external editor without any paths/arguments set.

When I press control-e, I get a menu like the following

This menu does disappear and begin to autoselect your preferred editor after 3 attempts, has it appeared for you at all? If it didn't, clear the external editor settings, run pacman -S xdg-desktop-portal in the terminal, re-open Joplin and retry. If it's the case that this menu used to appear but doesn't appear anymore and you wanted to change it manually, then I've got solutions for that too.

Opening Vim with that UI works fine for me, and is generally preferable to making use of the flatpak-spawn capabilities.

1 Like

Hi, now the menu appears, shows all installed editors and all of them seem to work fine after clearing paths/arguments in the settings and reinstalling xdg-desktop-portal. Thanks a lot @james-carroll! Curious to know what to do if the menu doesn't appear anymore and how to change it manually.:smiley:

You can set a default editor like so, in the system terminal:

flatpak permission-set desktop-used-apps text/markdown net.cozic.joplin_desktop org.gnome.gedit 0 3

You could repace text/markdown with e.g image/jpeg, and replace org.gnome.gedit with e.g org.vim.Vim (based again on desktop file names at a guess). The 0 3 bit, if I I remember correctly, is how many times it's currently asked and how many times it will keep asking until it stops showing the prompt entirely.

But you could do for example

flatpak permission-set --data "{'always-ask':<true>}" desktop-used-apps text/markdown net.cozic.joplin_desktop org.gnome.gedit 0 3

Importantly, the always-ask=true bit forces the prompt to always pop up when trying to open the mimetype. I'm under the impression the rest is still relevant so things don't break, even though it looks like it's still asking for gedit in the example above.

And finally you could always rm $HOME/.local/share/flatpak/db/desktop-used-apps to reset the entire learnt preferences database entirely, but I assume the flatpak permissions command has a nicer way to achieve it.

Generally, these same principles apply to snap, and the flatpak permissions command can actually set these preferences for snap too.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.