Make pkg.install respect __env__

This fixes #5209.
Merge pull request #5247 from terminalmage/issue5209

Make pkg.install respect __env__