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

electron 6: app.getPath('logs') throws error on Windows #19543

Closed
3 tasks done
MareikeTaeubner opened this issue Jul 31, 2019 · 4 comments
Closed
3 tasks done

electron 6: app.getPath('logs') throws error on Windows #19543

MareikeTaeubner opened this issue Jul 31, 2019 · 4 comments

Comments

@MareikeTaeubner
Copy link

MareikeTaeubner commented Jul 31, 2019

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 6.0.0
  • Operating System:
    • Microsoft Windows 10 Pro (10.0.18362 Build 18362)
  • Last Known Working Electron version:
    • 5.0.8

Expected Behavior

Function returns the path to the logs directory like electron 5.0.8 does:

C:\Users\taeubnerm\AppData\Roaming\Electron\logs

Actual Behavior

Function throws an error:

Error: Failed to get 'logs' path
    at App.<anonymous> (D:\workspace-js\scribble\index.js:10:26)
    at App.emit (events.js:205:15)

To Reproduce

const { app } = require("electron");

app.on("ready", () => {
  try {
    const logsPath = app.getPath("logs");
    console.log(logsPath);
  } catch (e) {
    console.error(e);
  }
});

app.getPath('userData') worked fine so it does seem like a logs specific problem.

Additional Information

May be related to #15877 but I'm not sure, since this is on Windows.

@SimonDD7
Copy link

You should call app.setAppLogsPath() as #17841 stated I believe.

@codebytere
Copy link
Member

codebytere commented Jul 31, 2019

@MareikeTaeubner if you read our breaking changes notes you'll see that that's the case: no default log path is set becuase that created issues with portability so you need to call app.setAppLogsPath() first. I'll be backporting a fix shortly so that a more descriptive error is thrown.

@MareikeTaeubner
Copy link
Author

MareikeTaeubner commented Jul 31, 2019

@DragDay7 @codebytere Ah, I see. Thank you very much for explaining. I seem to have misunderstood this in the release notes and the documentation (I somehow expected to get undefined if not present or something like that - sorry about that). Thank you for adding a more descriptive error message for people like me ^^"

@LefterisJP
Copy link

LefterisJP commented Jan 6, 2020

@codebytere Hey guys, I also came across this issue.

When reading the docs one can be lead to assume that it's safe to call app.getPath("logs") due to the following entry in the documentation:

If app.getPath('logs') is called without called app.setAppLogsPath() being called first, a default log directory will be created equivalent to calling app.setAppLogsPath() without a path parameter.

Shouldn't the docs also be adjusted?

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

No branches or pull requests

4 participants