-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for .env file #4718
Comments
Looking forward to that PR getting merged. Until then, the only solution is to inject the variable manually every time you run a command, which is not ideal.
npmScopes:
my-organization:
npmRegistryServer: https://npm.pkg.github.com
npmAlwaysAuth: true
npmAuthToken: ${GITHUB_PAT_PACKAGES} We lost the ability to use a global |
**What's the problem this PR addresses?** A common need is to provide environment values into the environment via `.env` files. There's been a couple of issues and attempts at implementation already, which all were decently upvoted. I myself could have used it once or twice 😄 Props to @jj811208 for his implementation in #4835 - I wanted to make the configuration a little more generic (allowing to have multiple environment files, and to possibly disable it altogether), but it was a appreciated start. Fixes #4718 Closes #4835 (Supercedes it) **How did you fix it?** A new setting, `injectEnvironmentFiles`, lets you define files that Yarn will load and inject into all scripts. It only affects subprocesses - Yarn itself still uses `process.env` for its checks, so you can't for example set `YARN_*` values and expect them to be applied to the current process (use the yarnrc file for that instead). The `injectEnvironmentFiles` setting has a few properties: - It defaults to `.env` - Nothing will be injected if it's set to an empty array or null - The paths inside may be suffixed by `?` - in that case, Yarn won't throw if the file doesn't exist The idea with this last property is to allow for simple user configuration (imagine, with the example below, that the project also has a gitignore with `.env.*`): ``` injectEnvironmentFiles: - .env - .env.${USER}? ``` **Checklist** <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
Thank you so much @arcanis for implementing this feature, very much appreciated 🙏 Do you have any idea when the new version will be released with this change? |
@jmariller I've created a new release candidate so you can get it now by running yarn set version canary |
awesome, thanks a lot @merceyz 👍 |
@jmariller is it working for you? with my .yarnrc.yml file
|
@co-sic no it does not work for me either, I am getting precisely the same error with a very similar setup - I am using pnp instead of node-modules for nodeLinker, aside from that all the same. |
Turns out I forgot to make a change, and since the test was missing I didn't see it; I fixed it and added a test in #5544 |
**What's the problem this PR addresses?** I forgot in #4718 to add a test making sure that the yarnrc settings could use the variable set in the dotenv files (the existing tests were mainly around the values set during script execution), and of course I forgot a change 🥲 **How did you fix it?** We now pass the updated environment when interpolating values. **Checklist** <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
thank you @arcanis is there already a new release candidate so we can also try it? |
Not yet, I prefer to wait until releasing a new one until #5542 is fixed by the Nx folks. In the meantime you can try it by running Note that I'm considering changing the default value of |
fair enough - and by the way, it works perfectly now 🙂 looking forward to getting the new release. |
Hi,
I am referring to an already existing issue which was closed, imho, without a proper resolution:
#2724
There was a pull request which was eventually rejected, with a proposed alternative solution (see one of the first messages from @paul-soporan):
#3938
Now I would really love to try and implement the proposal myself, unfortunately I do not have enough time and knowledge on my end. However with some hints and support I would be more than happy to help: is anybody willing to support this?
Many thanks!
The text was updated successfully, but these errors were encountered: