Using V2 in Termux (Android): "Selecting deleted buffer" error

I was able to use V1 in Emacs running in Termux (on Android) without issue. However, V2 has various errors, including a “Selecting deleted buffer” error that occurs with various operations, including org-roam-setup and org-roam-node-insert.

Here’s the debug error message when running org-roam-setup:

Debugger entered--Lisp error: (error "Selecting deleted buffer")
  #f(compiled-function (connection) "Return true if the end of the buffer has a properly-formatted prompt." #<bytecode 0x1f83958fdd>)(#<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8>)
  apply(#f(compiled-function (connection) "Return true if the end of the buffer has a properly-formatted prompt." #<bytecode 0x1f83958fdd>) #<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8> nil)
  emacsql-waiting-p(#<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8>)
  #f(compiled-function (connection &optional timeout) "Block until CONNECTION is waiting for further input." #<bytecode 0x1f839568e1>)(#<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8>)
  apply(#f(compiled-function (connection &optional timeout) "Block until CONNECTION is waiting for further input." #<bytecode 0x1f839568e1>) #<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8> nil)
  emacsql-wait(#<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8>)
  #f(compiled-function (#<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8> (:file "/data/data/com.termux/files/home/.emacs.d/org-roam..."))
  apply(#f(compiled-function 
  #f(compiled-function (&rest args) #<bytecode 0x1f83926501>)(#<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8> (:file "/data/data/com.termux/files/home/.emacs.d/org-roam..."))
  apply(#f(compiled-function (&rest args) #<bytecode 0x1f83926501>) #<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8> (:file "/data/data/com.termux/files/home/.emacs.d/org-roam..."))
  initialize-instance(#<emacsql-sqlite-connection emacsql-sqlite-connection-1f839264c8> (:file "/data/data/com.termux/files/home/.emacs.d/org-roam..."))
  #f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #<bytecode 0x1f84005641>)(emacsql-sqlite-connection :file "/data/data/com.termux/files/home/.emacs.d/org-roam...")
  apply(#f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #<bytecode 0x1f84005641>) emacsql-sqlite-connection (:file "/data/data/com.termux/files/home/.emacs.d/org-roam..."))
  make-instance(emacsql-sqlite-connection :file "/data/data/com.termux/files/home/.emacs.d/org-roam...")
  emacsql-sqlite("/data/data/com.termux/files/home/.emacs.d/org-roam...")
  org-roam-db()
  org-roam-db-sync()
  org-roam-setup()
  (progn (org-roam-setup) (require 'org-roam-protocol) t)
  (condition-case err (progn (org-roam-setup) (require 'org-roam-protocol) t) ((debug error) (funcall use-package--warning46 :config err)))
  (lambda nil (condition-case err (progn (org-roam-setup) (require 'org-roam-protocol) t) ((debug error) (funcall use-package--warning46 :config err))))()
  eval-after-load-helper("/data/data/com.termux/files/home/.emacs.d/elpa/org...")
  run-hook-with-args(eval-after-load-helper "/data/data/com.termux/files/home/.emacs.d/elpa/org...")
  do-after-load-evaluation("/data/data/com.termux/files/home/.emacs.d/elpa/org...")
  (org-roam-setup)
  eval-buffer(#<buffer  *load*> nil "/data/data/com.termux/files/home/.emacs.d/init.el" nil t)  ; Reading at buffer position 49758
  load-with-code-conversion("/data/data/com.termux/files/home/.emacs.d/init.el" "/data/data/com.termux/files/home/.emacs.d/init.el" t t)
  load("/data/data/com.termux/files/home/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x1f841fb7f1>) #f(compiled-function () #<bytecode 0x1f8402afed>) t)
  command-line()
  normal-top-level()

I tried setting inhibit-modification-hooks to t (as per Migration: the process fails with "selecting deleted buffer" · Issue #1603 · org-roam/org-roam · GitHub ; and I’m not running git-gutter) and running the commands again, including trying the migration wizard again, but that too stops with a “Selecting deleted buffer” error.

Not the same error but this user is successfully doing the same thing as you are trying (?)

Thanks! It’s weird that it’s different error messages, but I’ll see if I have any luck this way.

I’ve got it working at least better using chunglak’s “hack”: On Android Termux, any access to the database fails with "middleware out of memory" error · Issue #1605 · org-roam/org-roam · GitHub