Error at startup of Anki portable

Hello!
I installed Anki on a flash drive following these instructions and, when I double-click on the .bat file to run Anki, I get the following message.

Have I done something wrong?
Thank you!

1 Like

This suggests a problem with your ANKI_BASE variable. Have you adjusted the USB drive letter as suggested? Can you post your Anki.bat?

Could you please explain the 2nd step of the instructions to me?

  1. When the launcher appears, close it without installing.

Since in the 1st step says:

  1. Download the latest Anki launcher, and install it in a custom location: E:\Anki\Launcher. Not E:\Anki\Launcher\Anki.

How can I not install it, when I will already have installed it?

Thanks!

The USB drive letter is L: and the text of my Anki.bat is:

@echo off
echo Starting Anki...
set USB_ROOT=%~dp0
set ANKI_LAUNCHER_VENV_ROOT=L\AnkiProgramFiles
set ANKI_LAUNCHER=L\Launcher\anki
set ANKI_BASE=L\AnkiData
start /b %ANKI_LAUNCHER%

In fact, I do not know if and how I must replace %~dp0 and %ANKI_LAUNCHER%…

I’ve never performed this process. Hopefully someone more familiar with it can help confirm and clarify, but my interpretation is that the instructions are, in more detail:

  1. Download the Anki launcher, and move/copy the launcher into a custom location.
  2. Run the launcher but immediately close it after the launcher menu appears. That is, do not tell the launcher to install Anki itself (which is one of the menu options). Instead, just close the launcher immediately.
2 Likes

I don’t know much about Anki portable, but I notice that the colon (“:”) character is missing in your variable.

2 Likes

So, do I have to replace %USB_ROOT% with L:\Anki?
What about the other two variables: %~dp0 and %ANKI_LAUNCHER%?

You posted a link to a Anki Manual page with instructions. As I understand it, if someone follows the instructions exactly, they don’t need to make any changes to the .bat file. They can copy the .bat file verbatim, run it, and have it work just fine.

Are you saying that you followed the instructions using the .bat file verbatim, but got the error message?

(%~dp0 maps to the drive letter and path of the directory the .bat file is run from. So, it shouldn’t matter if you run it from L:/ or E:/ or F:/. The script should automatically detect and use the correct drive letter and directory path. (As I understand it, that is. I don’t use Windows computers.))


Edit: added:

Yes, the Anki Manual instructions should just work, without any changes to the .bat file, if you follow the steps correctly.

Details:

The Anki Manual instructions are written using the example of installing Anki into the E:\Anki directory.

  1. So, you move/copy the Anki launcher into E:\Anki\Launcher and create the .bat file as E:\Anki\Anki.bat.
  2. In the .bat file, %~dp0 will automatically get mapped as E:\Anki (the directory the .bat file is located in).
  3. So, USB_ROOT also will get mapped as E:\Anki.
  4. So, these will be the final mappings:
    • ANKI_LAUNCHER_VENV_ROOT will be E:\Anki\AnkiProgramFiles
    • ANKI_LAUNCHER will be E:\Anki\Launcher\anki
    • ANKI_BASE will be E:\Anki\AnkiData
  5. With these set, the Anki launcher will put Anki components into those directories during the subsequent initial installation (when run using the .bat file).
  6. And, the launcher will run Anki using those directories during subsequent runs (when run using the .bat file).
  7. The .bat file works even if you use a different directory.
    • For example, if you put the launcher and .bat file into F:\Files, the .bat file still works (because %~dp0 will get mapped to F:\Files)
    • And, if you put them directly into L:\, it still works (because %~dp0 will get mapped to L:\)

At least that is how I understand things should work. Again, I don’t use Windows.

Thank you for your help.
I kept the anki.bat text as it is given in the instructions, but, when I run the anki.bat, I get a message that Windows can not find L:\Anki\\Launcher\anki.
The instructions say not to put the Anki Launcher in E:\Anki\Launcher\Anki.
What can I do?

You copied/moved the Anki launcher directory so that it is L:\Anki\Launcher, and you created the .bat file as L:\Anki\Anki.bat, correct? (If so, then the L:\Anki\Launcher\anki file should exist, as I understand it.)

If not, then where did you put the Anki launcher and/or what are the contents of L:\Anki\Launcher when you look at that directory in File Explorer?

I put the anki-launcher-25.09-windows.exe into the L:\Anki\Launcher. So, the L:\Anki\Launcher has just this file. I run it and immediately close it. So there is no L:\Anki\Launcher\anki file.
In fact the instructions confuse me..

The instruction doesn’t say to put that installer exe file there, it says to install the launcher there.

Installing Anki from scratch requires first installing the launcher, then running the launcher to install Anki. Run that install program you downloaded and choose a custom location for the install.

1 Like

Sorry about that. I didn’t realize that there was an installer program that installs the launcher. So, the instructions should be:

  1. Download the Anki launcher installer, and use it to install the launcher in a custom location.

(The confusion is that the procedure involves 2 installs. The first installs the launcher, and then the launcher is used to install Anki itself.)

The instructions seem to indicate that the launcher gets automatically run after the installer installs it. So, step 2 would be:

  1. When the launcher window appears, close it without using it to install Anki itself.
1 Like

Excuse me, but I can not figure out what the 2nd step indicates:
2. When the launcher appears, close it without installing.
After the installation of anki-launcher-25.09-windows.exe, Anki opens. Is this the “launcher” that I have to close? It doesn’t ask for any other installation.

Finally, it seems that I’ve done it! I did what I had done the first time, but now it works!
Thank you all!

2 Likes