aspect-build / aspect-build/rules_js

[Bug]: Different behavior for $HOME npmrc file with pnpm and rules_js

Open
#2,019 0 comments 1 reaction 0 assignees View on GitHub
bug need: investigation
Dominant language
Starlark
Stars
378
Forks
183
Avg merge
1d 9h
Merged PRs (30d)
32

Description

### What happened?

Rules_js allows you to use your home npmrc file in addition to the project one via `npm_translate_lock` and the `npmrc` and `use_home_npmrc` fields. The contents of the home npmrc file will override any conflicting settings in the project file. This is great and allows us to specify our auth tokens in the project file via environment variables to work in our CI, but still use the home npmrc locally with user-specific auth credentials.

_However_, when using pnpm locally, it does the opposite, it overrides the home npmrc file with the project file's settings. These behaviors should be consistent for getting a solution for both local development and CIs to work.

### Version

Development (host) and target OS/architectures:

Output of `bazel --version`: 6.5.0

Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: WORKSPACE

Language(s) and/or frameworks involved: JavaScript

### How to reproduce

```shell
I think any sample project where local auth tokens are specified in the home npmrc, and in the project npmrc they are specified via env variables. Bazel tasks will install and complete just fine, however local pnpm commands to add/install will fail with "Failed to replace env in config: ${NPM_TOKEN}".
```

### Any other information?

The real issue we're trying to solve is how to have a local npmrc with auth for development that is not checked into source control, while defining environment variables for auth in our CI. If there is a recommended path for this, we'd love to know what it is, if not, creating a path for this would be ideal.

Contributor guide

Open the contributing guide

Research direction

Start by reading the npm_translate_lock handling for the npmrc and use_home_npmrc fields, then reproduce the conflicting home and project npmrc setup described in the issue with a sample project. Done means local pnpm commands and Bazel tasks use a consistent precedence without failing to replace ${NPM_TOKEN}, or the supported configuration path is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.