-
Notifications
You must be signed in to change notification settings - Fork 22
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
Version 18 does not reformat code but version 16 does #74
Comments
Can you paste the full output from the plugin when formatting doesn't work? Curious to see if there's anything that jumps out at me |
v18 config: pom.xml <properties>
[...]
<plugin.prettier.goal>write</plugin.prettier.goal>
[...]
</properties>
[...]
<build>
<plugins>
<plugin>
<groupId>com.hubspot.maven.plugins</groupId>
<artifactId>prettier-maven-plugin</artifactId>
<version>0.18</version>
<configuration>
<prettierJavaVersion>1.6.2</prettierJavaVersion>
<printWidth>120</printWidth>
<tabWidth>4</tabWidth>
<useTabs>false</useTabs>
<ignoreConfigFile>true</ignoreConfigFile>
<ignoreEditorConfig>true</ignoreEditorConfig>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>${plugin.prettier.goal}</goal>
</goals>
</execution>
</executions>
</plugin>
[...] FIle with formatting issues:
[...]
public class MyApplication implements Application
{
private final Logger log = Logger.getLogger(MyApplication.class);
private KafkaProducer kafkaProducer;
[...] Run Maven output was:
Notes:
|
@jknight are you using MacOS? I'm asking as I face the same issue locally but everything is fine on CI. Also, I created a simple repository that reproduces the issue: https://github.com/gaetanmaisse/prettier-maven-plugin-issue As I explain in the readme of my repo, everything is ok when using version
...
[DEBUG] Determined os: MAC_X64
[DEBUG] Downloading node from url: https://nodejs.org/dist/v16.13.2/node-v16.13.2-darwin-x64.tar.gz
[DEBUG] Downloaded node to: /Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-9379861215282969351.tmp
[DEBUG] Extracted node to: /Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-8885610596549673583
[DEBUG] Moved node to: /Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64
[DEBUG] Running npm install command: [/Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/bin/node, /Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/lib/node_modules/npm/bin/npm-cli.js, install, prettier-plugin-java@1.6.1]
changed 2 packages, and audited 1664 packages in 12s
243 packages are looking for funding
run `npm fund` for details
23 vulnerabilities (22 high, 1 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
[DEBUG] Downloaded prettier-java to: /Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1
[DEBUG] Running prettier with args: /Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/bin/node /Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1/node_modules/prettier/bin-prettier.js --plugin=/Users/gmaisse/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1/node_modules/prettier-plugin-java --color --check src/main/java/**/*.java src/test/java/**/*.java
[DEBUG] Prettier exit code: 1 We can notice the Same command in sudo mode: ...
[DEBUG] Determined os: MAC_X64
[DEBUG] Reusing cached node at: /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64
[DEBUG] Reusing cached prettier-java at: /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1
[DEBUG] Running prettier with args: /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/bin/node /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1/node_modules/prettier/bin-prettier.js --plugin=/var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1/node_modules/prettier-plugin-java --color --check src/main/java/**/*.java src/test/java/**/*.java
[ERROR] Incorrectly formatted file: src/main/java/org/example/Main.java
[INFO] No files matching the pattern were found: "src/test/java/**/*.java".
[DEBUG] Prettier exit code: 2 And Let me know if I can help with further investigation! |
Thanks to both of you for the detailed write-up. @gaetanmaisse I tried your reproducer but everything seemed to behave as expected for me (16" M1 Macbook, macOS 12.6). I ran |
Are y'all on macOS Ventura? I wonder if there might be some sort of permission change going on? Especially since you mentioned it works with sudo. When you build with
|
Using @gaetanmaisse repo, I get the same results he does - 17 ✅ 18 ❌
I also see the Full results here:
|
Something with the download + permissions? # Pre-clear the prettier dir to force new download ...
rm -rf /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin
# Run, non-sudo ...
mvn prettier:check
[...]
[DEBUG] Determined os: MAC_X64
[DEBUG] Downloading node from url: https://nodejs.org/dist/v16.13.2/node-v16.13.2-darwin-x64.tar.gz
[DEBUG] Downloaded node to: /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-1021355396566564595.tmp
[DEBUG] Extracted node to: /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-14205196155308076570
[DEBUG] Moved node to: /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64
[DEBUG] Running npm install command: [/Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/bin/node, /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/lib/node_modules/npm/bin/npm-cli.js, install, prettier-plugin-java@1.6.1]
up to date, audited 10 packages in 2s
found 0 vulnerabilities
[DEBUG] Downloaded prettier-java to: /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1
[DEBUG] Running prettier with args: /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/bin/node /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1/node_modules/prettier/bin-prettier.js --plugin=/Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1/node_modules/prettier-plugin-java --color --check src/main/java/**/*.java
[DEBUG] Prettier exit code: 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.882 s
[INFO] Finished at: 2022-11-09T13:11:10Z
[INFO] ------------------------------------------------------------------------ ^^ says it "Downloaded prettier-java to: /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1" -- let's check: > ls -alh /Users/jknight/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1
total 0
drwxr-xr-x 2 jknight staff 64B Nov 9 13:02 .
drwxr-xr-x 9 jknight staff 288B Nov 9 13:02 .. Empty ? But doing the same with # Remove it to force a new download ...
sudo rm -rf /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/
# Run prettier -X as sudo ...
sudo mvn:prettier -X
[...]
[DEBUG] Determined os: MAC_X64
[DEBUG] Downloading node from url: https://nodejs.org/dist/v16.13.2/node-v16.13.2-darwin-x64.tar.gz
[DEBUG] Downloaded node to: /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-11761585108782352696.tmp
[DEBUG] Extracted node to: /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-17376624761748570133
[DEBUG] Moved node to: /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64
[DEBUG] Running npm install command: [/var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/bin/node, /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/node-v16.13.2-darwin-x64/lib/node_modules/npm/bin/npm-cli.js, install, prettier-plugin-java@1.6.1] Did it download in > sudo ls -alh /var/root/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.1
total 16
drwxr-xr-x 5 root wheel 160B Nov 9 13:06 .
drwxr-xr-x 9 root wheel 288B Nov 9 13:06 ..
drwxr-xr-x 10 root wheel 320B Nov 9 13:06 node_modules
-rw-r--r-- 1 root wheel 4.0K Nov 9 13:06 package-lock.json
-rw-r--r-- 1 root wheel 65B Nov 9 13:06 package.json |
We are noticing the same issue, and have reproduced it on both macOS Ventura and Monterey. For Monterey, we noticed that macOS versions 12.6.2 and 12.6.3 both experience the issue, but 12.6.1 does not (I assume @jhaber was running 12.6.1?) |
I'm now on Ventura 13.2 and still haven't had any luck reproducing the issue. Our company has >1,000 engineers on a mix of MacOS versions and no one has seen this issue either 🤔 I wonder if there's maybe a specific MacOS security setting that triggers the issue? |
Strange... My team of 4 is using company-managed MacBook Pros, so perhaps they have enabled such a security setting. |
Hello, When i execute the command manually i got:
I noticed that the module was installed to
After that the check works. Maybe the module was just installed to the wrong place? Furthermore i see another issue: That the exit code is 1 should lead to an build error. It is not helpful that the plugin is not failing when it was not able to perform the work. I would thing is just found nothing to complain about. Instead it was doing nothing. |
Cleaning the following files/dirs helped to solve it:
content of
It seemt to be that npm is installing it to the gloabl |
Maybe 84af10d already is doing the trick? Yes it does, tested it against 0.19-SNAPSHOT When can we expect a release? |
Ah the plugin version we use internally tracks the master branch, so we've already picked up that commit which could explain why we can't reproduce this issue. I can cut a new release and see if it the new version fixes this issue for people |
Please keep in mind that the directory |
It turns out in another instance of that issue we had to remove all the following:
|
I just released version 0.19, if some people reporting this issue can try upgrading and see if it fixes this issue I would appreciate it |
@jhaber just tested version 0.19 on the simple repo I used to highlight the issue and everything is back to normal 🎉 🍾 |
Confirmed working in v19 - let's close it ! 🥳 THANK YOU @jhaber ! |
Awesome, sorry it took so long to track down the issue |
Version 18 does not reformat my code whereas version 16 does.
Here's my configuration that works (following README.md)
with this config,
mvn verify
reformats my code as expected ✅However, if I change to v18:
mvn verify
does not reformat my code. I don't see any complaints - it just doesn't do anything.mvn prettier:print-args
seems happy enough (?)I see from the PR Notes
Is there some extra manual step I need to perform to use v18 ?
The text was updated successfully, but these errors were encountered: