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

Breaks Dockerfile #176

Open
Makoehle opened this issue Jun 8, 2021 · 7 comments
Open

Breaks Dockerfile #176

Makoehle opened this issue Jun 8, 2021 · 7 comments

Comments

@Makoehle
Copy link

Makoehle commented Jun 8, 2021

Having a Dockerfile with the following instruction:

FROM node:lts-alpine3.12 
RUN echo "Installing ..." \
  apk update > /dev/null && \
  apk upgrade > /dev/null && \
  apk add zip > /dev/null

this extension formats this code block to removing \

FROM node:lts-alpine3.12 
RUN echo "Installing ..." \
  apk update >/dev/null &&
  apk upgrade >/dev/null &&
  apk add zip >/dev/null

Which will lead to the following error: Error response from daemon: dockerfile parse error line 17: unknown instruction: APK

Update

  • I disabled Prettier and reloaded VS-Code but the Dockerfile kept getting formatted
  • I disabled shell-format and the Dockerfile stopped being formatted.
@foxundermoon
Copy link
Owner

You can provide the complete dockerfile.
or test by shfmt command line tool.

@AchillesG
Copy link

have same problem

@matrixik
Copy link

Looks like this is bug in shfmt that is officially not supporting Dockerfiles mvdan/sh#640

@stormsilver
Copy link

I've just installed this extension and it's true that the automatic formatting of Dockerfiles that contain multiline RUN statements leads to broken Dockerfiles. If shfmt doesn't explicitly support Dockerfiles, perhaps disabling Dockerfile formatting is the right thing to do? Or at least provide optional configuration?

@sbrunner
Copy link

sbrunner commented Nov 7, 2021

The solution is probably provided in this comment: #29 (comment)

@mcnesium
Copy link

mcnesium commented Dec 9, 2021

To save some time for everyone arriving here, just add the following to your settings.json:

"shellformat.effectLanguages": ["shellscript"],
"[dockerfile]": {
  "editor.formatOnSave": false
}

I am not sure why both "do only shellscript" and "do not do dockerfile" is required, but it won't work with only one of the settings.

@bluebrown
Copy link

bluebrown commented Mar 24, 2022

@mcnesium, better configure a different formatter for Dockerfiles. This one works great.

"[dockerfile]": {
    "editor.defaultFormatter": "ms-azuretools.vscode-docker"
}

But your effect langauges is good. Because disable formatOnSave is not respected by this extension for some reason.

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

No branches or pull requests

8 participants