We derive conditions for a nonholonomic system subject to nonlinear
constraints (obeying Chetaev’s rule) to preserve a smooth volume form. When
applied to affine constraints, these conditions dictate that a basic invariant
density exists if and only if a certain 1-form is exact and a certain function
vanishes (this function automatically vanishes for linear constraints).
Moreover, this result can be extended to geodesic flows for arbitrary metric
connections and the sufficient condition manifests as integrability of the
torsion. As a consequence, volume-preservation of a nonholonomic system is
closely related to the torsion of the nonholonomic connection. Examples of
nonlinear/affine/linear constraints are considered.