Loraserver-pi-gen failing to build image

Hello,

I’m trying to use the pi image generator but it is failing and I’m not sure why. It ends with the below. Any info would be greatly appreciated. Thank you.

"losetup: /pi-gen/work/2018-09-24-raspbian/export-image/2018-09-24-raspbian-LoRaPi.img: failed to set up loop device: No such file or directory"

[23:45:15] Begin /pi-gen/export-image
[23:45:15] Begin /pi-gen/export-image/prerun.sh

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x56409a2c.

Command (m for help): Created a new DOS disklabel with disk identifier 0xccf8f6d2.

Command (m for help): Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 
Using default response p.
Partition number (1-4, default 1): First sector (2048-3588095, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (8192-3588095, default 3588095): 
Created a new partition 1 of type 'Linux' and of size 43.8 MiB.

Command (m for help): Disk /pi-gen/work/2018-09-24-raspbian/export-image/2018-09-24-raspbian-LoRaPi.img: 1.7 GiB, 1837105152 bytes, 3588096 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xccf8f6d2

Device                                                                        Boot Start   End Sectors  Size Id Type
/pi-gen/work/2018-09-24-raspbian/export-image/2018-09-24-raspbian-LoRaPi.img1       8192 97906   89715 43.8M 83 Linux

Command (m for help): Selected partition 1
Partition type (type L to list all types): Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): 
Using default response p.
Partition number (2-4, default 2): First sector (2048-3588095, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (98304-3588095, default 3588095): 
Created a new partition 2 of type 'Linux' and of size 1.7 GiB.

Command (m for help): 

Command (m for help): 
Disk /pi-gen/work/2018-09-24-raspbian/export-image/2018-09-24-raspbian-LoRaPi.img: 1.7 GiB, 1837105152 bytes, 3588096 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xccf8f6d2

Device                                                                        Boot Start     End Sectors  Size Id Type
/pi-gen/work/2018-09-24-raspbian/export-image/2018-09-24-raspbian-LoRaPi.img1       8192   97906   89715 43.8M  c W95 FAT32 (LBA)
/pi-gen/work/2018-09-24-raspbian/export-image/2018-09-24-raspbian-LoRaPi.img2      98304 3588095 3489792  1.7G 83 Linux

Command (m for help): The partition table has been altered.
Syncing disks.

losetup: /pi-gen/work/2018-09-24-raspbian/export-image/2018-09-24-raspbian-LoRaPi.img: failed to set up loop device: No such file or directory

Finally… after trying numerous times and researching possible causes as a noob in this area, I finally got it to work. Weird, though… just adding a debug line made it work.

in

loraserver-pi-gen/export-image/prerun.sh

Added

LOOPDEV_DEBUG=all

in lines 51 and 52

BOOT_DEV=$(LOOPDEV_DEBUG=all losetup --show -f -o "${BOOT_OFFSET}" --sizelimit "${BOOT_LENGTH}" "${IMG_FILE}")
ROOT_DEV=$(LOOPDEV_DEBUG=all losetup --show -f -o "${ROOT_OFFSET}" --sizelimit "${ROOT_LENGTH}" "${IMG_FILE}")

Then ran again

CONTINUE=1 ./build-docker.sh

And it worked! “Done! Your image(s) should be in deploy/”