When installing/updating Magisk through “Direct Install” in Magisk Manager, you may get the following error:1
2Unable to detect target image
Installation failed
The solution is to get a copy of the stock boot image of your device and patch it through Magisk Manager. You choose “Select and Patch a file” from the Install options and browse to the boot image file for patching.

The result will tell you where the patched boot image is saved.1
2Output file is placed in
<Download folder> / magisk_patched.img
Copy the magisk_patched.img file to your PC then go to fastboot mode to flash this patched boot image. For simplicity, I copied the .img file to the fastboot folder.
1 | C:\Android\platform-tools |
If you get the following permission error:1
2
3
4
5Sending 'boot' (5028 KB) OKAY [ 0.175s]
Writing 'boot'
FAILED (remote: 'failed to get download permission
for partition 'boot'')
fastboot: error: Command failed
Then you need to unlock the bootloader. The command may not be the same as below for your phone.1
2
3
4C:\Android\platform-tools
> fastboot oem unlock
OKAY [ 27.743s]
Finished. Total time: 27.759s
After flashing the patched boot image, reboot:1
2
3
4C:\Android\platform-tools
> fastboot reboot
Rebooting OKAY [ 0.003s]
Finished. Total time: 0.016s

I had these issues upgrading to Magisk v20.0. Make sure to find the right ADB/fastboot files for your device and always keep a backup of your stock boot image or ROM, just in case.