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

Failed to spawn command phpcs. #11

Closed
lukasoppermann opened this issue Nov 16, 2015 · 15 comments
Closed

Failed to spawn command phpcs. #11

lukasoppermann opened this issue Nov 16, 2015 · 15 comments

Comments

@lukasoppermann
Copy link
Contributor

Hey, I get the error:

Failed to spawn command `phpcs`. Make sure `phpcs` is installed and on your PATH

However I did install phpcs via composer https://github.com/squizlabs/PHP_CodeSniffer and I have composer in my PATH export PATH="/usr/local/bin:/usr/local/sbin:~/.composer/vendor/bin:$PATH"

This should be fine, correct? I still get the error though. Maybe it would be good if you could add the installation of phpcs to the readme. Thanks.

@bpearson
Copy link
Owner

You should be able to put the full path to PHPCS in the settings (by default its just phpcs and relies on your path). Go to Edit -> Preferences and find AtomPHPCS and click the settings.

@lukasoppermann
Copy link
Contributor Author

It somehow does not help I just get the same error message with the path:

Failed to spawn command `~/.composer/vendor/bin/phpcs`. Make sure `~/.composer/vendor/bin/phpcs` is installed and on your PATH

But when I run it from the cli it works fine. Maybe it can not access this? Is it possible that I have to do something so atom can access it?

@bpearson
Copy link
Owner

You got me. The only thing I can think of is maybe expand ~ to the full path? I know from experience some applications do not handle this.

@lukasoppermann
Copy link
Contributor Author

If I do this I get an atom error cannot open file. Did you install phpcs via composer?

@bpearson
Copy link
Owner

na I still use PEAR.

@bpearson
Copy link
Owner

Just tried the composer way, by expanding the ~, seems to have it working. The cannot open file could be a problem with a config callback I have on that page. I can't look now, but I will file an issue and address it later. Try building the complete path outside and pasting it in, seems to workaround it.

@lukasoppermann
Copy link
Contributor Author

Sadly it does not work for me either, are you on a mac as well? The expanded path would be /Users/lukasoppermann/.composer/vendor/bin/phpcs correct? I still get the cannot open file error.

Also all methods I tried with ~, expanded, just phpcs work fine in the cli.

@bpearson
Copy link
Owner

Nope, I'm on Linux. Yeah the error is fine, I think its because the setting registers a change and it tries to run phpcs on each editor open, so it should pop up cos it cannot open the file, but once its correct in the settings, the error should disappear. (To test it, once the setting is correct, go to an editor, make a cs violation and save (or ctrl-alt-s)). The path looks correct to me as well. Oh obviously assuming you did the composer global require command to install and not the package one. If none of that works, I got nothing :-(

@bpearson
Copy link
Owner

BTW the config setting issue is at #12

@lukasoppermann
Copy link
Contributor Author

Hmm, no I still can not get it to work. :(

@bpearson
Copy link
Owner

Not sure what is going on. I cannot replicate it here. You could try the new version which fixes the config bug, but I'm not holding my breath.

@lukasoppermann
Copy link
Contributor Author

Hmm, no, sadly not, I still get the "incorrectly setup" option in the console. Can I provide any information? Could I have missed some setup step or something?

@bpearson
Copy link
Owner

This might explain the problem about the PATH atom-community/atom-script#61,

But this doesn't address the issue of using the full path. In the CLI, did u try the full path and double check the full path. ie. if you try: /fullpath/to/phpcs --standard=STANDARD --report=csv /fullpath/to/file

Also what standard are you using? Is it a correct standard (check by phpcs -i)?

@lukasoppermann
Copy link
Contributor Author

Okay, somehow it seems to now be working using the full path to both phpcs and phpcbf

/Users/lukasoppermann/.composer/vendor/bin/phpcbf
/Users/username/.composer/vendor/bin/phpcs

And the standard to PSR2.

I am a little bit confused, because it had it like this (apart from PSR1) before and it did not work. Maybe I restarted my mac in between and that fixed it. Works anyhow, thanks for your support. 👍

@bpearson
Copy link
Owner

w00t!

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

No branches or pull requests

2 participants