[Tutorial] Running Anki from a USB flash drive on Mac

I did some testing to come up with a procedure for installing and running Anki from a USB flash drive on Mac computers. This worked for me on an M1 Mac Mini with macOS Tahoe 26.0.1.

Installation:

  1. Create an Anki.command shell script file in the folder on the USB flash drive where you want Anki files installed:
#!/bin/zsh
echo "Starting Anki..."
USB_ROOT=`realpath $0 | sed 's/\/[^/]*$//'`
export ANKI_LAUNCHER_VENV_ROOT=$USB_ROOT/AnkiProgramFiles
export ANKI_LAUNCHER=$USB_ROOT/Anki.app
export ANKI_BASE=$USB_ROOT/AnkiData
open $ANKI_LAUNCHER
  1. In Terminal, go into the directory with the Anki.command file and run chmod 755 Anki.command to make the file runnable.
  2. Download the Mac Anki launcher .dmg file from apps.ankiweb.net.
  3. Open the .dmg file and drag the “Anki” file into the folder that contains the Anki.command file (to copy the launcher there).
  4. Double-click the Anki.command file to run it. It will start the launcher (which will open up a blank Terminal window). The launcher menu will eventually appear in the Terminal window. (It may take up to 40-50 seconds for the menu to appear.)
  5. Install Anki from the launcher menu (by pressing the Enter key). It can take up to 10-20 minutes for the many individual Anki components to be downloaded and installed during the process.
  6. Once the installation is complete, the launcher will automatically start the Anki app.

macOS may ask you for various permissions during the installation process, for example:

  • For Terminal to access files on the removable drive
  • To allow the Anki launcher (an app downloaded from the internet) to run
  • For Anki to access files on the removable drive

Running Anki:

  • From now on, you will double-click the Anki.command file whenever you want to run Anki.
  • A Terminal window will briefly appear and then close when Anki.command is run.
  • The Anki.command file will run the Anki launcher and start the Anki app for you.
  • Do not run the Anki launcher app (the Anki icon) directly.
  • If you accidentally do so, just close/exit the launcher Terminal window when it appears.

Changing the Anki.command icon:

  • To make things easier visually in Finder, you can make the Anki.command file’s icon the Anki icon instead of the shell script file icon it normally uses.
  • Similarly, you can change the “Anki” app’s icon to something else, to make it less likely that you accidentally click on it.
6 Likes

Thanks for posting this. Is this different enough from what’s described in the manual that we should be considering an update there?

1 Like

Personally, I think it would be great to include MacOS and Linux in Managing Files - Anki Manual as well; it currently is very windows focused.

1 Like

Yes, I think we should consider adding the instructions to the documentation. While the general procedure is the same as for Windows, the exact steps and the shell script are significantly different.


Since writing the instructions, I came up with some improvements to the process:

  • Put the launcher app into a subfolder on the flash drive. This will “hide” it and make it less likely to accidentally click on. Adjust the path in the script accordingly.
  • Leave the “Anki” app’s icon as-is. Don’t change it. This will make it so the icon continues to appear correct in the Dock when Anki is running.

I imagine that the Mac version of the shell script would also work for Linux, with possibly a few minor changes. The realpath utility comes installed on all Mac computers, but I don’t know whether it is standard on all Linux distributions. The default Mac shell is zsh, but perhaps bash might be better for Linux.

It appears to be there by default at least on debian based distros. At least I never installed it knowingly but it is there.

True, I think bash is the default on most distros. Though users could switch to e.g. zsh as well if they wish; I guess if the script was posix compatible (and uses /bin/sh as the shebang) then there shouldn’t be any issue on linux.