In underdense plasmas, the transverse ponderomotive force of an intense laser beam with Gaussian transverse profile expels electrons radially, and it can lead to an electron cavitation. An improved cavitation model with charge conservation constraint is applied to the determination of the width of the electron cavity. The envelope equation for laser spot size derived by using source-dependent expansion method is extended to including the electron cavity. The condition for self-guiding is given and illuminated by an effective potential for the laser spot size. The effects of the laser power, plasma density and energy dissipation on the self-guiding condition are discussed.