I would recommend 3-M fast bond 10 we used this in the field and found it to be very reliable, spay on both surfaces it will have some open tack time and set in a few minutes.
Pull the carpet back from the wall on an angle be sure to cover the surfaces so you don't get over spray on anything. Spay both surfaces and then work the carpet back into place working any air out as you go.
It's easy and will not take long to fix.
Good luck!
Regards, Jerry