This may be well explained by the basic conditions first turn your H-CN to NaCN or KCN then react it with your Alkyl Halide creating the Nitrile and a salt Na-X or K-X
H-CN is unreactive with R-X because the byproduct is an acid (H-X) whereas H-CN is also an acid.
Hope this helps!
Lutesium...