rust.aws-cdk-lambda icon indicating copy to clipboard operation
rust.aws-cdk-lambda copied to clipboard

Unhelpful error thrown when cargo is missing

Open shirakaba opened this issue 2 years ago • 2 comments

TypeError: Cannot read properties of null (reading 'toString')

This rather cryptic error is thrown from: https://github.com/rnag/rust.aws-cdk-lambda/blob/73b8cdb93d4a00a16e57e8a7552092ffc77444de/lib/build.ts#L178

... when trying to call cargo.stderr.toString(). The reason is that cargo.stderr may be null if a cargo executable was not found by the call to spawnSync('cargo' /* ... other args... */).

Troubleshooting:

If, when you run which cargo in your usual shell, you get cargo not found or similar, then you need to make sure the cargo executable is both installed and on your shell's path.

Recommendations:

I think ideally this library should have some way of double-checking whether cargo is indeed on-path (I'm not sure what the usual approach for this is), but this kind of environment health-check may arguably be out-of-scope.

At the very least, it would save some onboarding friction if this library could, in the event of cargo.stderr being null, suggest that perhaps cargo is either not installed or not on path.

shirakaba avatar Jan 23 '23 05:01 shirakaba

Hi @shirakaba ! Thanks for opening this issue. I agree this would be a worthwhile addition and for quality of life purposes, at least for making developer's life easier.

I suppose that an argument could be made, that as a user would ideally already have cargo and a working rust environment set up -- it is briefly mentioned in the "getting started" section.

Although, I agree that for clarity sake it might be better for onboarding purposes as was mentioned -- as not everyone would necessarily have cargo installed beforehand.

That said, I would more than welcome a contribution towards achieving or addressing this issue. If not, I can certainly look into this as and when time allows.

rnag avatar Feb 04 '23 04:02 rnag

For now I'm just happy that if anyone else runs into the same issue, they'll find this pointer in the GitHub Issues! Not starving for it to be implemented anytime soon.

shirakaba avatar Feb 05 '23 09:02 shirakaba