vim-prettier not working when editing files that have white spaces on its path

Created on 30 Jan 2018  路  15Comments  路  Source: prettier/vim-prettier

I'm getting Prettier: failed to parse buffer. error when I run :Prettier or :PrettierAsync.
Running the executable itself (i.e., npx prettier or npm run prettier) doesn't causes any issue.

Version info:
vim-prettier: latest (updated just today)
Prettier version: 1.10.2 (local node_modules)
OS: macOS 10.13.3
Vim:
8.0 (2016 Sep 12, compiled Jan 7 2018 10:47:02)
macOS version
Included patches: 1-1420

bug good-first-issue help wanted

Most helpful comment

Great finding @nelsyeung, looks like we are not handling directories with spaces well, I can try to have a look into it soon, in the meantime please feel free to submit a PR for it!

All 15 comments

Hi @nelsyeung ,

Thank you for submitting this issue, in order for me to better assist / debug this problem could you please provide me some more info on:

the resolved prettier cli version:

:PrettierCliVersion

the prettier executable path:

:PrettierCliPath

vim prettier version

:PrettierVersion

Other information is the extension of the file you were editing while running that command.

thanks a lot!

That's interesting, it looks like it could be a problem with directories with spaces:

:PrettierCliVersion
zsh:1: no such file or directory: /Users/nelsyeung/Sites/Twitter^@

:PrettierCliPath
/Users/nelsyeung/Sites/Twitter Help Desk/Web App/node_modules/.bin/prettier

:PrettierVersion
0.2.6

Extensions: js, jsx, css

Great finding @nelsyeung, looks like we are not handling directories with spaces well, I can try to have a look into it soon, in the meantime please feel free to submit a PR for it!

I also editing the title description of this issue, please feel free to edit the description to anything else you may think better describes this issue.

Sounds perfect. Thanks. 馃憤

I'm still getting the same error, if my files are in a path that has spaces in it. Everything works great elsewhere.

:PrettierVersion : 0.2.7

:PrettierCliVersion: 1.13.7

:PrettierCliPath: prettier

I'm on macOS 10.13.6

I could not reproduce this on the same version as you:
This is the path to my file: ~/Sites/test test/src/test test/test test.js
Do you mind posting your path as well?

It's ~/Work/Festival Scope/fspro/src/FSPro/FrontBundle/Resources/src/scss/header.scss

But I just renamed Festival Scope to FestivalScope because I wasn't expecting such a fast response ! :) And it was always awkward to insert the escape character...

I tried with other paths as well and they all fail if they contain a white space.

This is really strange, I just can't reproduce this at all. Just a sanity check: you file doesn't contain errors right? If you use the following file as your header.scss, does it still occur?

body {
  text-align: center;
}

I just checked with the above snippet and it still gives Prettier: failed to parse buffer.

Maybe Node version at play? I have v10.6.0

@bfulop, is this issue still happening to you ? If so I will reopen this issue

Yes, Prettier is still failing when there's a space in the file path. (I just run PlugUpdate, but the plugin was already up to date).

Will look into this again

This issue has been fixed on release/1.x

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blacksails picture blacksails  路  5Comments

ajcrites picture ajcrites  路  8Comments

dedoyle picture dedoyle  路  11Comments

rkulla picture rkulla  路  3Comments

mitermayer picture mitermayer  路  6Comments