install dependencies using the stdlib ensure_packages function to avoid duplicate declaration errors

taking inspiration from @jjtorroglosa this PR has essentially the same changes but can be merged easily (at least as of now)