githubocto/flat-editor

Initialize Flat YML gives me error

Closed this issue ยท 10 comments

Hi, when I run it I have the below error.

What should he do? Should it create an empty file?

I'm using Win10 and VSC 1.56.2.

image

Hi @aborruso. Are you able to link to the repo for which you're seeing this issue?

Hi @aborruso. Are you able to link to the repo for which you're seeing this issue?

It's this https://github.com/aborruso/flat_data_bash_example

Thank you

Thanks!

We'll have to dig in further on our end โ€“ I wasn't able to reproduce this in Codespaces ๐Ÿ‘‡

Screen Shot 2021-05-21 at 7 31 22 AM

In the interim, can you tell me if you see any errors/messages in either the Output or Debug Console when you encounter this issue on your machine?

Screen Shot 2021-05-21 at 7 32 17 AM

In the interim, can you tell me if you see any errors/messages in either the Output or Debug Console when you encounter this issue on your machine?

I have nothing.

The full errors is

Command 'Flat Editor: Initialize Flat YML File' resulted in an error (Running the contributed command: 'flat.initializeFlatYml' failed.)

Bummer! Can you help me understand what might have happened between #10 and now? It looks like the webview loaded fine beforehand? Did anything in your environment change?

Bummer! Can you help me understand what might have happened between #10 and now? It looks like the webview loaded fine beforehand? Did anything in your environment change?

Nothing has changed: since "Initialize Flat YML" doesn't work, I simply create it using "new file".

Hey @mattrothenberg

I've just experienced the same issue as @aborruso.

I've documented the error that occurs, what the root cause seems to be, a workaround for others that experience this, and steps on how to reproduce it on Windows.

Later this week/next week I can try to submit a PR if you like. I haven't done it yet as whilst the change suggested below worked okay in my brief testing it may not be the right thing to do, especially for non-Windows environments which I currently don't have access to.

Cheers
echdata

Error

  • It is failing on the call to fs.mkdirSync at

    fs.mkdirSync(workflowsDir, { recursive: true })

  • The error thrown is Error: ENOENT: no such file or directory, mkdir '\c:\Development\Repos\flat-editor-testing\.github\workflows'

  • It appears (tbc) to fail because when the workflowsDir path is constructed the extension is using rootPath.uri.path which ultimately results in a path like \\c:\\Development\\Repos\\flat-editor-testing\\.github\\workflows being sent to fs.mkdirSync

  • Changing workflowsDir to use rootPath.uri.fsPath instead a few lines up at /src/extension.ts#L64 results in a better formed c:\\Development\\Repos\\flat-editor-testing\\.github\\workflows which succeeds when passed to fs.mkdirSync

Workaround

  1. Manually create a new file relative to workspace root at /.github/workflows/flat.yml
  2. The Flat Editor extension will pick this up and allow editing through the UI ๐ŸŽ‰

Steps to Reproduce

Steps

  1. Install Flat Editor https://marketplace.visualstudio.com/items?itemName=GitHubOCTO.flat
  2. Create an empty directory at c:\development\repos\flat-editor-testing\
  3. Open the folder in VS Code
  4. Open VS Code Command Pallete
  5. Type Initialize FLAT
  6. Run the Flat Editor: Initialize Flat YML File
  7. See Expected Behavior

Expected

  1. A new file will be created relative to workspace root at /.github/workflows/flat.yml
  2. VS Code will open the flat.yml with the default flat stub

Actual

  1. VS Code errors out with error Command 'Flat Editor: Initialize Flat YML File' result in an error (Running the contributed command: 'flat.initializeFlatYml' failed.)
  2. The file and directories are not created or opened
  3. No error is printed to console and no other VS Code info message is shown
  4. Stepping through shows the error is

Environment

Device

Version: 1.59.0 (user setup)
Commit: 379476f0e13988d90fab105c5c19e7abc8b1dea8
Date: 2021-08-04T23:13:12.822Z
Electron: 13.1.7
Chrome: 91.0.4472.124
Node.js: 14.16.0
V8: 9.1.269.36-electron.0
OS: Windows_NT x64 10.0.19042

Extension

Name: Flat Editor
Id: githubocto.flat
Description: An editor for flat-data configurations
Version: 0.20.0
Publisher: GitHub OCTO
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=GitHubOCTO.flat
Flat Editor Install Link: https://marketplace.visualstudio.com/_apis/public/gallery/publishers/GitHubOCTO/vsextensions/flat/0.20.0/vspackage

Thanks @echdata , we'd welcome a PR!

still experiencing this issue, has @echdata's PR been merged?

I've used a workaround to create the file manually, however the GUI isn't loading.

image

Just published 0.22.0 โ€“ it should be available via the VSCode Marketplace momentarily. Please upgrade and let me know (via a new issue) if you run into any trouble.