You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to set the .npmrc based on environment variables, so I added the following content to the .npmrc:
store-dir=${PNPM_STORE_DIR:-~/.pnpm/store}
This configuration means that when the environment variable PNPM_SOTRE_DIR exists, the store-dir takes its value. If it does not exist, then it takes ~/.pnpm/store
Pnpm supports this feature
Values in the .npmrc files may contain env variables using the ${NAME} syntax. The env variables may also be specified with default values. Using ${NAME-fallback} will return fallback if NAME isn't set. ${NAME:-fallback} will return fallback if NAME isn't set, or is an empty string. —— https://pnpm.io/npmrc
However, After executing "rush install", I found that rush modified the content of the npmrc file. The line "store-dir" was added with the prefix ; MISSING ENVIRONMENT VARIABLE. This causes this configuration to be invalid.
Add store-dir=${PNPM_STORE_DIR:-~/.pnpm/store} to the common/config/rush/.npmrc file.
Then, execute rush install command.
Expected result:
The content of common/temp/.npmrc displays store-dir=${PNPM_STORE_DIR:-~/.pnpm/store}
Actual result:
The content of common/temp/.npmrc displays ; MISSING ENVIRONMENT VARIABLE: store-dir=${PNPM_STORE_DIR:-~/.pnpm/store}
Details
I located the logical code causing the problem. This code seems to have not considered the fallback syntax.
Actually, I don't understand why the prefix MISSING ENVIRONMENT VARIABLE is added here.
fzxen
changed the title
[rush] Rush should support the ${NAME:fallback} syntax in .npmrc
[rush] Rush should support the ${NAME:-fallback} syntax in .npmrc
Dec 4, 2024
I suspect the fallback feature didn't exist when this was first implemented.
There is(/used to be) a behavior where a missing env variable that a .npmrc depends on would cause an error, so Rush automatically just filters those lines out. Supporting the fallback syntax with a regexp would be pretty easy.
Summary
I want to set the .npmrc based on environment variables, so I added the following content to the .npmrc:
store-dir=${PNPM_STORE_DIR:-~/.pnpm/store}
This configuration means that when the environment variable PNPM_SOTRE_DIR exists, the
store-dir
takes its value. If it does not exist, then it takes~/.pnpm/store
Pnpm supports this feature
However, After executing "rush install", I found that rush modified the content of the npmrc file. The line "store-dir" was added with the prefix
; MISSING ENVIRONMENT VARIABLE
. This causes this configuration to be invalid.; MISSING ENVIRONMENT VARIABLE: store-dir=${PNPM_STORE_DIR:-~/.pnpm/store}
Repro steps
Add
store-dir=${PNPM_STORE_DIR:-~/.pnpm/store}
to thecommon/config/rush/.npmrc
file.Then, execute
rush install
command.Expected result:
The content of
common/temp/.npmrc
displaysstore-dir=${PNPM_STORE_DIR:-~/.pnpm/store}
Actual result:
The content of
common/temp/.npmrc
displays; MISSING ENVIRONMENT VARIABLE: store-dir=${PNPM_STORE_DIR:-~/.pnpm/store}
Details
I located the logical code causing the problem. This code seems to have not considered the fallback syntax.
Actually, I don't understand why the prefix
MISSING ENVIRONMENT VARIABLE
is added here.rushstack/libraries/rush-lib/src/utilities/npmrcUtilities.ts
Lines 55 to 89 in ca5a3a9
Standard questions
Please answer these questions to help us investigate your issue more quickly:
@microsoft/rush
globally installed version?rushVersion
from rush.json?node -v
)?The text was updated successfully, but these errors were encountered: