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

ENOENT -4058 when beautifying php #51

Closed
AndalfTheBeard opened this issue Jul 24, 2014 · 24 comments
Closed

ENOENT -4058 when beautifying php #51

AndalfTheBeard opened this issue Jul 24, 2014 · 24 comments
Assignees
Labels

Comments

@AndalfTheBeard
Copy link

As seen below:
http://prntscr.com/461gkr

@Glavin001 Glavin001 added the bug label Jul 25, 2014
@Glavin001
Copy link
Owner

Could you show what your editor's source code is? (which is the input text to the PHP beautifier)

If an error occurred in the beautification process of your PHP source code, the output file may not have been created and therefore when the call to delete temporary output file was executed it was unnecessary (there is no existing output file since an error had occurred) and it errored again because it was attempting to delete a file that does not exist.

@BOOMER74
Copy link

BOOMER74 commented Aug 3, 2014

Same trouble, code not formatted:
image
Beautifier work, but with warnings, like "Strict standards: Non-static method PEAR::isError() should not be called statically". PHP 5.5.11. PHP_Beautifier 0.1.15.

@Glavin001
Copy link
Owner

Please paste your source code so I can quickly test later without having to retype and possibly mistype your code. Thank you for posting version numbers @BOOMER74

@Glavin001 Glavin001 self-assigned this Aug 3, 2014
@Glavin001
Copy link
Owner

So I am using:

<?php
function add($a,     $b) {
  return $a +$b; }
echo   add(1,2);

and it beautifies correctly.

I will add a little more logging in the Console that you can send me to debug.

@Glavin001
Copy link
Owner

v0.4.4 is the version with additional logging. Let me know how that goes.

@BOOMER74
Copy link

BOOMER74 commented Aug 4, 2014

Log this: Beautifcation Error: Error {killed: false, code: 1, signal: null}

@AndalfTheBeard
Copy link
Author

Hey, sorry I didn't respond to this sooner. Only recently got atom installed and running again, it appears that the initial error I was having no longer occurs but I'm running into a new one now regardless. Using various code examples, and for consistencies sake, the one posted above too, I'm getting the following error:

Uncaught TypeError: Cannot read property 'split' of undefined /usr/local/share/atom/resources/app/node_modules/text-buffer/lib/range.js:48

No idea why that would be happening.

@Glavin001
Copy link
Owner

Glad to hear the previous error is no longer persisting, @AndalfTheBeard.

That new error looks like the result of the beautification is undefined instead of a string containing the beautified source code. Can you confirm what version of Atom, Atom Beautify, and php_beautify you have, as well as some sample source code I can test for myself.

@AndalfTheBeard
Copy link
Author

Atom Version 0.121.0
Atom Beautify 0.6.2
PHP_Beautifier-0.1.15

running Xubuntu 14.04 LTS

I've tried various code samples, all resulted in the same error.

<?php
function add($a,     $b) {
  return $a +$b; }
echo   add(1,2);

included, as it was the example you provided above.

@Glavin001
Copy link
Owner

My beautification is working properly.

Before

<?php
function add($a,     $b) {
  return $a +$b; }
echo   add(1,2);

After:

<?php
function add($a, $b) {
    return $a + $b;
}
echo add(1, 2);

This (and even the previous error you and @BOOMER74 are experiencing) could be caused by an incorrect PATH environment variable, and therefore it cannot find php_beautifier.

Could you retrieve the php_beautifier path using which php_beautier. Mine for instance:

$ which php_beautifier
/Users/glavin/pear/bin/php_beautifier

And set your php_beautifier_path variable in either your .jsbeautifyrc file or in your Atom Beautify package settings:

image

I have put in some special code as a workaround for Node.js's issue with the PATH environment variable with using exec: https://github.com/Glavin001/atom-beautify/blob/master/lib/langs/cli-beautify.coffee#L40-L49

However, it may not be working in you cases. So by forcing the php_beautifier_path, you should then be using the proper command and it should hopefully work not. Keep me posted!

@Glavin001
Copy link
Owner

@BOOMER74
Copy link

@Glavin001 I have install atom-beautify and php_beautifier to third PC. Formatting work good. The problem was in the wrong PEAR paths when installing php_beautifier. Today I check this on other PC.

@Glavin001
Copy link
Owner

Thanks for checking @BOOMER74. I will be adding more setup document for languages like PHP that require the PATH ( #58 ). Hopefully that will help users like yourselves in the future from having this issue.

@Glavin001
Copy link
Owner

@AndalfTheBeard could you confirm if that was your issue as well?

@AndalfTheBeard
Copy link
Author

having purged php5, php5-cli and php-pear then reinstalling, along with running

sudo pear install --alldeps php_beautifier-0.1.15

I am still unable to get this to work. which php_beautifier returns absolutely nothing for me in the terminal however I'm sure that php_beautifier is installed and I can find the file in ~/pear/bin/php_beautifier setting that to the path just results in this

cmd: "/bin/sh -c [ -f ~/.bash_profile ] && source ~/.bash_profile;[ -f ~/.bash_rc ] && source ~/.bash_rc;php "~/pear/bin/php_beautifier" "/tmp/input114713-3313-1uewpzf" "/tmp/114713-3313-iifrnm""
code: 1
killed: false
message: "Command failed: /bin/sh -c [ -f ~/.bash_profile ] && source ~/.bash_profile;[ -f ~/.bash_rc ] && source ~/.bash_rc;php "~/pear/bin/php_beautifier" "/tmp/input114713-3313-1uewpzf" "/tmp/114713-3313-iifrnm"↵"
signal: null
stack: (...)
get stack: function () { [native code] }
set stack: function () { [native code] }
__proto__: d

I have no idea what is happening here.

trying to use php_beautifier -help results in the reponse php_beautifier: command not found even when I'm cded into the same folder as it.

@Glavin001
Copy link
Owner

To execute a command, even when in the same directory, you should prefix you command with ./
So it should look like: ./php_beautifier --help
Furthermore, php_beautifier is a PHP script, which is why I also prefix it with php to force PHP to interpret the script. Your terminal should detect it is a PHP script if the script has the proper headings.

If you can get php_beautifer to work with the above, then we know it is correctly installed.

Instead of using the ~ symbol in the settings path exchange that for the full absolute path, for instance mine is /Users/Glavin/ instead of ~. Sometimes that causes problems.

Besides that, you generated command from atom beautify looks correct. You should test your source code with php_beautifier directly via command line and see the result. If that works via command line and does not work via atom beautify, then I have an issue to resolve.

@AndalfTheBeard
Copy link
Author

andy@Porrim:~$ cd pear/bin
andy@Porrim:~/pear/bin$ ls
docblockgen     pci      pear     pecl            php_beautifier.bat
gen_php_doc.sh  pciconf  peardev  php_beautifier  scripts
andy@Porrim:~/pear/bin$ ./php_beautifier -help
PHP Warning:  require_once(PHP/Beautifier.php): failed to open stream: No such file or directory in /home/andy/pear/bin/php_beautifier on line 49
PHP Fatal error:  require_once(): Failed opening required 'PHP/Beautifier.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/andy/pear/bin/php_beautifier on line 49
andy@Porrim:~/pear/bin$ 

@Glavin001
Copy link
Owner

Not quite sure why you insist on using the long option help with only a single - (used for short options). See Command line documentation: http://beautifyphp.sourceforge.net/docs/PHP_Beautifier/tutorial_PHP_Beautifier.howtouse.commandline.pkg.html#command.options

It should be: ./php_beautifier --help (notice the double -, so --help, NOT -help. If you want to use just one - then use the short option, -?). It is failing to parse your incorrect usage and assuming there is instead a file to open, showing error failed to open stream: No such file or directory in.

@AndalfTheBeard
Copy link
Author

-help --help and -? all result in the same error anyway, so that's not at all what's happening.

@Glavin001
Copy link
Owner

At least we can now guarantee we are using it as expected.

Sounds like your installation of php_beauifier is broken. This is a php_beautifier issue and you can follow up with them (or do some independent research) and see if they have any experience with this issue.
Once you have php_beautifier working on your machine then we can resume verifying if there are any problems with Atom Beautify.

@Glavin001
Copy link
Owner

I am closing this as it appears resolved from an Atom Beautify perspective. Looks like it was a php_beautifier installation issue. / wrong pear path as @BOOMER74 mentioned.

@BOOMER74
Copy link

Ok, if you have this problem try this:

  • Uninstall PHP_Beautifier
  • Type commands and check path:
    • pear config-get data_dir
    • pear config-get test_dir
    • pear config-get doc_dir
  • If paths incorrect, set paths:
    • pear config-set data_dir C:\php\data
    • pear config-set test_dir C:\php\tests
    • pear config-set doc_dir C:\php\docs
  • Install PHP_Beautifier again with all deps:
    • pear install -a channel://pear.php.net/php_beautifier-0.1.15

@AndalfTheBeard
Copy link
Author

Can confirm it was a bad install of PHP_Beautifier, not sure how but I managed to fix it. Thanks for the help.

@Glavin001
Copy link
Owner

Glad to hear it's working out for everyone. Good to have this discussion available for other Atom Beautify and PHP_Beautifier users. Thanks guys!

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

No branches or pull requests

3 participants