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

[FR] Self-provided --user-data-dir #89

Closed
lowlighter opened this issue Sep 27, 2024 · 1 comment · Fixed by #90
Closed

[FR] Self-provided --user-data-dir #89

lowlighter opened this issue Sep 27, 2024 · 1 comment · Fixed by #90

Comments

@lowlighter
Copy link
Contributor

Currently you always need the temp dir in --allow-write because the following is not gated so you'll always hit a permission request:

const tempDir = Deno.makeTempDirSync();

And the arg --user-data-dir is always set by astral:

`--user-data-dir=${tempDir}`,

But it'd be nice if the above lines are ignored if user specify the arg theymselves in args:

const args = opts?.args ?? [];

Basically doing something like:

if (!args.find(arg => arg.startsWith("--user-data-dir=")) {
  const tempDir = Deno.makeTempDirSync(); 
  args.push(`--user-data-dir=${tempDir}`) 
}

I know the workaround from #56, but setting TMPDIR is not always convenient because:

  • it sets the value globally for all the program and its dependencies, not only astral
  • it conflicts with users wanting to manually set this parameter
    • additionally it prevents the pattern where a single directory is used to store all of app's cache/data, etc.
    • users cannot handle the lifecycle of their app completly as there's no way to retrieve the generated user-data-dir so it cannot be cleaned when exiting (although leaving stuff in temp dir is usually not a big deal, but it's still a small inconvenience)
  • not sure as I haven't personally tested yet, but firefox may not have this arg so it'd mean that an extra permission is requested although it may be unneeded
@lino-levan
Copy link
Owner

Basically doing something like:

if (!args.find(arg => arg.startsWith("--user-data-dir=")) {
const tempDir = Deno.makeTempDirSync();
args.push(--user-data-dir=${tempDir})
}

I would support this. If you want to submit a PR this makes sense to me.

I haven't personally tested yet, but firefox may not have this arg

Firefox compatibility is currently really broken. Hoping that #84 fixes it in the medium-long term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants