Closed artfulrobot closed 1 month ago
According to this comment an exit code of 3 indicates that an invalid standard was given. I have no idea what that means, but perhaps it makes sense to someone more familiar with phpcbf.
It is possible that phpcbf behaves differently because of the temp file. Try copying test.php
to conform.7289672.test.php
and re-run the command on the CLI targeting that file.
It's also possible that the cwd could affect it. Make sure you're opening vim from the same directory that you're running the command from.
You can also try running the command directly with jobstart
to see if that's where the problem is coming from
vim.fn.jobstart(
{
"/home/rich/.local/share/nvim/mason/bin/phpcbf",
"--standard=/home/rich/nobackup/civicrm-coder/coder_sniffer/Drupal",
"test.php",
},
{
on_exit = function(_, code)
print("Exited with code", code)
end,
}
)
@stevearc thanks so much for your time on this.
Try copying test.php to conform.7289672.test.php and re-run the command on the CLI targeting that file.
CLI called command runs fine, corrects the conform.7289672.test.php file.
It's also possible that the cwd could affect it. Make sure you're opening vim from the same directory that you're running the command from.
Done and makes no difference.
try running the command directly with jobstart ...
Same.
But I've found the problem!
conform - as configured by me - was not passing in the filename to be worked on.
Altering my config to this fixed it:
formatters = {
phpcbf = {
command = '/home/rich/.local/share/nvim/mason/bin/phpcbf',
- args = { "--standard=/home/rich/nobackup/civicrm-coder/coder_sniffer/Drupal" }
+ args = { "--standard=/home/rich/nobackup/civicrm-coder/coder_sniffer/Drupal", '$FILENAME' }
}
},
Thanks for the ace plugin and your help here. @stevearc
Neovim version (nvim -v)
v0.9.5
Operating system/version
Fedora 39 Linux
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
17:16:43[DEBUG] Running formatters on /home/rich/conformbug/test.php: { "phpcbf" }
17:16:43[INFO] Run phpcbf on /home/rich/conformbug/test.php
17:16:43[DEBUG] Creating temp file /home/rich/conformbug/conform.7289672.test.php
17:16:43[DEBUG] Run command: { "/home/rich/.local/share/nvim/mason/bin/phpcbf", "--standard=/home/rich/nobackup/civicrm-coder/coder_sniffer/Drupal" }
17:16:43[INFO] phpcbf exited with code 3
17:16:43[DEBUG] phpcbf stdout: nil
17:16:43[DEBUG] phpcbf stderr: { "" }
17:16:43[DEBUG] Cleaning up temp file /home/rich/conformbug/conform.7289672.test.php
17:16:43[ERROR] Formatter 'phpcbf' error:
Describe the bug
Fails to run the command, yet running the command on the command line (outside of vim) works.
What is the severity of this bug?
blocking (cannot use plugin)
Steps To Reproduce
Expected Behavior
It should format/fix the formatting in the file.
e.g. taking the command from ConformInfo and pasting it onto the command line works:
Minimal example file
test.php
Minimal init.lua
Additional context
It references
/home/rich/nobackup/civicrm-coder/coder_sniffer/Drupal
You get that by:
git clone https://github.com/civicrm/coder civicrm-coder