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

force:project:create --json sometimes results in malformed output with Error: ENOENT trying to rename an sf.log file #2209

Closed
SCWells72 opened this issue Jun 13, 2023 · 4 comments
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue logger-replacement

Comments

@SCWells72
Copy link

I've started to see this when running the force:project:create command for JSON output:

[Error: ENOENT: no such file or directory, rename 'C:\Users\Scott\.sf\sf.log.0' -> 'C:\Users\Scott\.sf\sf.log.1'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'rename',
  path: 'C:\\Users\\Scott\\.sf\\sf.log.0',
  dest: 'C:\\Users\\Scott\\.sf\\sf.log.1'
}
[Error: ENOENT: no such file or directory, rename 'C:\Users\Scott\.sf\sf.log.0' -> 'C:\Users\Scott\.sf\sf.log.1'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'rename',
  path: 'C:\\Users\\Scott\\.sf\\sf.log.0',
  dest: 'C:\\Users\\Scott\\.sf\\sf.log.1'
}
{
  "status": 0,
  "result": {
    "outputDir": "C:\\Users\\Scott\\dev\\projects",
    "created": [
      "projectName\\config\\project-scratch-def.json",
      "projectName\\README.md",
      "projectName\\sfdx-project.json",
      "projectName\\manifest\\package.xml",
      "projectName\\.husky\\pre-commit",
      "projectName\\.vscode\\extensions.json",
      "projectName\\.vscode\\launch.json",
      "projectName\\.vscode\\settings.json",
      "projectName\\force-app\\main\\default\\lwc\\.eslintrc.json",
      "projectName\\force-app\\main\\default\\aura\\.eslintrc.json",
      "projectName\\scripts\\soql\\account.soql",
      "projectName\\scripts\\apex\\hello.apex",
      "projectName\\.eslintignore",
      "projectName\\.forceignore",
      "projectName\\.gitignore",
      "projectName\\.prettierignore",
      "projectName\\.prettierrc",
      "projectName\\jest.config.js",
      "projectName\\package.json"
    ],
    "rawOutput": "target dir = C:\\Users\\Scott\\dev\\projects\n   create projectName\\config\\project-scratch-def.json\n   create projectName\\README.md\n   create projectName\\sfdx-project.json\n   create projectName\\manifest\\package.xml\n   create projectName\\.husky\\pre-commit\n   create projectName\\.vscode\\extensions.json\n   create projectName\\.vscode\\launch.json\n   create projectName\\.vscode\\settings.json\n   create projectName\\force-app\\main\\default\\lwc\\.eslintrc.json\n   create projectName\\force-app\\main\\default\\aura\\.eslintrc.json\n   create projectName\\scripts\\soql\\account.soql\n   create projectName\\scripts\\apex\\hello.apex\n   create projectName\\.eslintignore\n   create projectName\\.forceignore\n   create projectName\\.gitignore\n   create projectName\\.prettierignore\n   create projectName\\.prettierrc\n   create projectName\\jest.config.js\n   create projectName\\package.json\n"
  },
  "warnings": [
    "The \"force project create\" command has been deprecated. Use \"project generate\" instead."
  ]
}

As you can tell, the embedded error causes the JSON output to be malformed resulting in downstream issues when trying to unmarshal it for processing. I would expect such an error to be either added to the JSON document written to stdout in a properly structured manner, or written to stderr.

@SCWells72 SCWells72 added the investigating We're actively investigating this issue label Jun 13, 2023
@github-actions
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@mshanemc mshanemc added the bug Issue or pull request that identifies or fixes a bug label Jun 13, 2023
@git2gus
Copy link

git2gus bot commented Jun 13, 2023

This issue has been linked to a new work item: W-13586057

@SCWells72
Copy link
Author

SCWells72 commented Jun 15, 2023

This is not just an issue with force:project:create but is also manifesting with other commands...which makes sense given that any command could result in a log rotation. For example, it just happened when running force:org:display:

$ sfdx force:org:display -u <username> --json

[Error: ENOENT: no such file or directory, rename 'C:\Users\Scott\.sf\sf.log' -> 'C:\Users\Scott\.sf\sf.log.0'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'rename',
  path: 'C:\\Users\\Scott\\.sf\\sf.log',
  dest: 'C:\\Users\\Scott\\.sf\\sf.log.0'
}
[Error: ENOENT: no such file or directory, rename 'C:\Users\Scott\.sf\sf.log' -> 'C:\Users\Scott\.sf\sf.log.0'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'rename',
  path: 'C:\\Users\\Scott\\.sf\\sf.log',
  dest: 'C:\\Users\\Scott\\.sf\\sf.log.0'
}
[Error: ENOENT: no such file or directory, rename 'C:\Users\Scott\.sf\sf.log' -> 'C:\Users\Scott\.sf\sf.log.0'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'rename',
  path: 'C:\\Users\\Scott\\.sf\\sf.log',
  dest: 'C:\\Users\\Scott\\.sf\\sf.log.0'
}
{
  "status": 0,
  "result": {
    ...
  },

It's worth pointing out that while the ... is used above to elide otherwise correct contents, the end of that response is as-written and incomplete/malformed JSON. Ignoring the dangling ,, Note that absence of an additional closing brace required to complete the JSON object. I don't know if that's just a side-effect of the other issue, though I imagine it is as I've never seen such a problem outside of this intermingling of outputs.

@mcarvin8
Copy link

mcarvin8 commented Jun 21, 2023

This issue also occurs when running sf org login in a Linux pipeline. A temporary workaround is to not cache the .sf folder in the pipeline.

sf org login sfdx-url -f /builds/temp_file.txt --set-default --alias dev
[Error: ENOENT: no such file or directory, rename '/root/.sf/sf.log' -> '/root/.sf/sf.log.0'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'rename',
  path: '/root/.sf/sf.log',
  dest: '/root/.sf/sf.log.0'
}
[Error: ENOENT: no such file or directory, rename '/root/.sf/sf.log' -> '/root/.sf/sf.log.0'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'rename',
  path: '/root/.sf/sf.log',
  dest: '/root/.sf/sf.log.0'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue logger-replacement
Projects
None yet
Development

No branches or pull requests

3 participants