How can I carry a heavy bag without a rack? I want to buy a heavy 20kg bag of rice and bring it home.

The problem is that I only have access to a bike without any rack or formal way to store bags. The bag is too big to fit in my backpack. The distance is about 3km from the shop to my home.

I am using a Bixi (Shared bike in Montreal). There are stations near both my home and the store.

How can I safely carry heavy and bulky items on a bike without a rack?
Depending on your backpack you may be able to lash it to the outside.  I've carried bike wheels this way. I've also carried 10-15kg backpacks while riding, so know it takes some care.  You might have to ride quite gently but that's OK over 3 km.  I'd probably have the sack sideways across the backpack, rather than vertical, as it's less likely to slip between the straps.

Buying a bigger backpack might be a good idea if this is going to become a habit.

The backpack I used has straps on the outside running from bottom to top, so a big load can be held between them and the backpack itself.  An additional side-to-side strap/rope is a good idea.  If you think it feels like it's started moving, get off and have a look.

Alternatively, don't take the bike, walk with the sack on your shoulder.