Skip to content
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

[Bug?]: yarn plugin import removes injectEnvironmentFiles: [] from .yarnrc.yml #5545

Closed
1 task
exKAZUu opened this issue Jun 30, 2023 · 0 comments · Fixed by #5548
Closed
1 task

[Bug?]: yarn plugin import removes injectEnvironmentFiles: [] from .yarnrc.yml #5545

exKAZUu opened this issue Jun 30, 2023 · 0 comments · Fixed by #5548
Labels
bug Something isn't working

Comments

@exKAZUu
Copy link

exKAZUu commented Jun 30, 2023

Self-service

  • I'd be willing to implement a fix

Describe the bug

When adding plugin by yarn plugin import ..., injectEnvironmentFiles: [] is removed in .yarnrc.yml.
(cf. #5531 (comment))

Here are reproduction steps:

  1. yarn set version 4.0.0-rc.47
  2. echo "yarnPath: .yarn/releases/yarn-4.0.0-rc.47.cjs\ninjectEnvironmentFiles: []" > .yarnrc.yml
  3. yarn plugin import https://gitlab.com/Larry1123/yarn-contrib/-/raw/master/packages/plugin-production-install/bundles/@yarnpkg/plugin-production-install.js
  4. cat .yarnrc.yml does not include injectEnvironmentFiles like:
plugins:
  - checksum: f545f7b647a6c43a1df5c6091541c3c9d1f067db0c0d8cfe41178ac2e29c9d4d4c692c24935a4c66e7801ceee11b72dd4d75062d0fb4eff3135538deb6c4afc3
    path: .yarn/plugins/@yarnpkg/plugin-production-install.cjs
    spec: "https://gitlab.com/Larry1123/yarn-contrib/-/raw/master/packages/plugin-production-install/bundles/@yarnpkg/plugin-production-install.js"

yarnPath: .yarn/releases/yarn-4.0.0-rc.47.cjs

To reproduce

const fs = require('fs/promises');

await fs.appendFile('.yarnrc.yml', 'injectEnvironmentFiles: []');
expect(await fs.readFile('.yarnrc.yml', 'utf-8')).toContain('injectEnvironmentFiles');

await yarn('plugin', 'import', 'https://gitlab.com/Larry1123/yarn-contrib/-/raw/master/packages/plugin-production-install/bundles/@yarnpkg/plugin-production-install.js');
expect(await fs.readFile('.yarnrc.yml', 'utf-8')).toContain('injectEnvironmentFiles');

Environment

System:
    OS: macOS 13.4.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 20.2.0 - /private/var/folders/9p/8yqjg80d1n9dpmz33_v4hgj80000gn/T/xfs-69436567/node
    Yarn: 4.0.0-rc.47 - /private/var/folders/9p/8yqjg80d1n9dpmz33_v4hgj80000gn/T/xfs-69436567/yarn
    npm: 9.6.6 - ~/.asdf/shims/npm
  npmPackages:
    jest: 29.5.0 => 29.5.0

Additional context

No response

@exKAZUu exKAZUu added the bug Something isn't working label Jun 30, 2023
arcanis added a commit that referenced this issue Jun 30, 2023
**What's the problem this PR addresses?**

It was raised in
#5544 (comment) that
automatically injecting the `.env` file in the environment could break
compatibility with some software that already do this in their own way.
It makes sense, and I prefer to avoid doing that if there's a reasonable
compromise.

Also closes #5545.

**How did you fix it?**

Yarn will now default into loading the `.env.yarn` file, rather than
`.env`.

**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.
arcanis added a commit to yarnpkg/example-repo-zipn that referenced this issue Jul 3, 2023
**What's the problem this PR addresses?**

It was raised in
yarnpkg/berry#5544 (comment) that
automatically injecting the `.env` file in the environment could break
compatibility with some software that already do this in their own way.
It makes sense, and I prefer to avoid doing that if there's a reasonable
compromise.

Also closes yarnpkg/berry#5545.

**How did you fix it?**

Yarn will now default into loading the `.env.yarn` file, rather than
`.env`.

**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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant