rules_js icon indicating copy to clipboard operation
rules_js copied to clipboard

npmrc registry cafile config not respected

Open jbedard opened this issue 2 years ago • 1 comments

When using a custom registry a custom certificate might also be required. Yarn and NPM support a cafile property in the npmrc to specify a custom certificate.

jbedard avatar Oct 27 '22 06:10 jbedard

So, this may not be a fix for the npmrc file issue, but this was helpful for me when dealing with my org's custom certs.

I was having an issue where pnpm install was failing because it wasn't recognizing our my custom certificate ("self-signed certificate" error) whereas the yarn_install rule of rules_nodejs, worked fine. The problem was that I was I had an environment variable configuration for my own certs called NODE_EXTRA_CA_CERTS that was already set on my local machine.

But rules_js is (probably) more hermetic and scrubbing the local environment variables whereas the yarn_install workspace rule from rules_nodejs (probably) does not.

So the workaround, was to simply set this variable again in my .bazelrc file.

build --action_env=NODE_EXTRA_CA_CERTS='/etc/ssl/certs/my-ca-cert.crt'

And that was able to get everything to work. Just another FYI, I found that passing in my cert into the bazel jre itself, didn't matter in this case. It would matter for doing an HTTP_ARCHIVE rule, but it didn't matter for my PNPM install rule whether it was set or not.

cfife-btig avatar Aug 24 '23 18:08 cfife-btig