vercel / vercel/hyper

.npmrc shell expansion variables fail

Open
#3,805 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
44.7k
Forks
3.6k
Avg merge
21m
Merged PRs (30d)
1

Description

  • I am on the latest Hyper.app version
  • I have searched the issues of this repo and believe that this is not a duplicate
  • OS version and name: MacOS Mojave
  • Hyper.app version: 10.14.6
  • Link of a Gist with the contents of your .hyper.js:
  • Relevant information from devtools (CMD+ALT+I on macOS, CTRL+SHIFT+I elsewhere):
  • The issue is reproducible in vanilla Hyper.app:

Issue

One nice feature of .npmrc is the ability to add shell expansion variables. So for instance you can do something like:

~/.npmrc
registry = https://my.custom.registry.com/npm
_auth = ${REGISTRY_AUTH_TOKEN}

Where _auth will get evaluated to whatever env variable you set for REGISTRY_AUTH_TOKEN (can verify by running yarn config list).

This works fine when you start hyper from the command line because it preserves your env variables. However, when clicking on the Hyper.app icon, your shell env variables are not brought in, and plugin installation will fail with something like:

Trace: 
  Error: Failed to replace env in config: ${REGISTRY_AUTH_TOKEN}
      at value.replace (/Applications/Hyper.app/Contents/Resources/bin/yarn-standalone.js:90318:13)
      at String.replace (<anonymous>)
      at envReplace (/Applications/Hyper.app/Contents/Resources/bin/yarn-standalone.js:90313:16)
      at Function.normalizeConfig (/Applications/Hyper.app/Contents/Resources/bin/yarn-standalone.js:30313:69)
      at /Applications/Hyper.app/Contents/Resources/bin/yarn-standalone.js:30335:36
      at Generator.next (<anonymous>)
      at step (/Applications/Hyper.app/Contents/Resources/bin/yarn-standalone.js:98:30)
      at /Applications/Hyper.app/Contents/Resources/bin/yarn-standalone.js:109:13

The problem occurs in yarn-standalone.js when it tries to substitute the value for an env variable that is not found.

yarn-standalone.js:90318
if (undefined === env[envVarName]) {
  throw new Error('Failed to replace env in config: ' + match);
}

Ideally, the correct shell env would be passed in when clicking on Hyper.app. But alternatively we might not need to throw an error when an env variable is missing because this kind of ~/.npmrc customization is not relevant to hyper starting up. Or perhaps there is not even a need to parse ~/.npmrc (unless people are publishing custom plugins to private registries or proxying).

But at the very least, it seems yarn-standalone.js should continue with plugin install if an env variable can't be found, instead of throwing an error.

There are a few other issues I found related to ~/.npmrc, but nothing related to shell expansion:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by launching Hyper.app with a .npmrc containing ${REGISTRY_AUTH_TOKEN}, then compare it with starting Hyper from the command line. Start with yarn-standalone.js around the reported envReplace code and trace the plugin-install path; done means plugin installation no longer aborts when the variable is unavailable, with the intended environment behavior verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
desktop, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.