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] .env file specified in envFile option is cached #896

Closed
shellscape opened this issue Jun 6, 2023 · 8 comments
Closed

[bug] .env file specified in envFile option is cached #896

shellscape opened this issue Jun 6, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@shellscape
Copy link

shellscape commented Jun 6, 2023

Describe the bug

It appears that a .env file specified in the envFile options is being cached.

Steps to reproduce

Create a .env file with:

export BATMAN=robin

Create a task:

  batman:
    command: ts-node ./scripts/echo.ts
    options:
      cache: false
      envFile: '/.env'

Create scripts/echo.ts:

console.log(process.env.BATMAN);
  • Run moon run root:batman
  • Output is: robin
  • Change the value in the .env file to joker
  • Run moon run root:batman -u
  • Output is: robin
  • Run moon run root:batman --cache off
  • Output is: joker

I'm able to consistently reproduce this in a fresh repo as well as the existing repo.

Expected behavior

.env files should not be cached, nor considered part of any task cache.

What's also troubling is that the cache: false option is specified, but appears to be ignored. -u has no effect but --cache off does have an affect.

Screenshots

n/a

Environment

MacOS Ventura
Moon v1.7.2

Additional context

This is something new since migrating from 1.2 to 1.7.x, so this looks like a regression or a breaking change in a minor.

As an aside, it might be helpful to spin up triage environments that people can fork for reproductions. This is what we setup for rollup https://stackblitz.com/fork/rollup-repro and https://repl.it/@rollup/rollup-plugin-repro

@shellscape shellscape added the bug Something isn't working label Jun 6, 2023
@milesj
Copy link
Collaborator

milesj commented Jun 6, 2023

@shellscape If you use moon task <target>, does the env file path show up as an input?

I also tested this on our 1.8 branch and it's working as expected. We did so some heavy migration as part of 1.8, so this was probably inadvertently fixed.

@shellscape
Copy link
Author

Sorry for the delay, was out of town for a bit. This is on my list to test on 1.8 later today.

@milesj
Copy link
Collaborator

milesj commented Jun 26, 2023

This was reworked again in 1.9, can you give it a look.

@milesj milesj closed this as completed Jun 26, 2023
@milesj milesj reopened this Jun 26, 2023
@shellscape
Copy link
Author

On it.

@shellscape
Copy link
Author

@milesj this is still a problem with 1.9.1

@milesj
Copy link
Collaborator

milesj commented Jun 28, 2023

Ok dug into it more. It's because tasks are expanded when added to the project graph, and then the graph is cached entirely. So subsequent runs are hitting the cache.

This'll take some time to fix.

@milesj
Copy link
Collaborator

milesj commented Jul 31, 2023

Fixed in v1.11 https://moonrepo.dev/blog/moon-v1.11

@milesj milesj closed this as completed Jul 31, 2023
@shellscape
Copy link
Author

DOPE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants