phpfmt_stable icon indicating copy to clipboard operation
phpfmt_stable copied to clipboard

Ubuntu 20.04 fmt and sublime installed via flatpak

Open mpmont opened this issue 5 years ago • 2 comments

At first I thought that had something to do with the fact that Ubuntu 20.04 ships with php 7.4. So I uninstalled that and installed php 7.2 and then went as far as installing 7.1.

Here's my config:

{
	"enable_auto_align": false,
	"format_on_save": true,
	"indent_with_space": true,
	"passes":
	[
		"ConvertOpenTagWithEcho",
		"PrettyPrintDocBlocks",
		"ReturnNull",
		"OnlyOrderUseClauses"
	],
	"psr1": false,
	"psr2": true,
	"version": 2
}

This gives the following error:

  File "/home/marco/.var/app/com.sublimetext.three/config/sublime-text-3/Packages/phpfmt/phpfmt.py", line 122, in dofmt
    p = subprocess.Popen(cmd_ver, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1448, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'php'

So I tried to specify the absolute path like so:

{
	"php_bin":"/bin/php",
	"enable_auto_align": false,
	"format_on_save": true,
	"indent_with_space": true,
	"passes":
	[
		"ConvertOpenTagWithEcho",
		"PrettyPrintDocBlocks",
		"ReturnNull",
		"OnlyOrderUseClauses"
	],
	"psr1": false,
	"psr2": true,
	"version": 2
}

Same error:

  File "/home/marco/.var/app/com.sublimetext.three/config/sublime-text-3/Packages/phpfmt/phpfmt.py", line 122, in dofmt
    p = subprocess.Popen(cmd_ver, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1448, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: '/bin/php'

But the file is there because when I go to the terminal and type:

$ /bin/php -v

I get the following output.

PHP 7.1.33-16+ubuntu20.04.1+deb.sury.org+1 (cli) (built: May 14 2020 08:27:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33-16+ubuntu20.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Also tried with /usr/bin/php but same result.

mpmont avatar Jun 07 '20 15:06 mpmont

Just found out what the problem was. I installed sublime via flatpak. So the plugin can't get to the php binary. Just removed the flatpak and installed sublime normally and now everything works fine.

But documentation on how to get this working when sublime is installed via flatpak would be great.

mpmont avatar Jul 04 '20 08:07 mpmont

For future reference permission issues like this with flatpaks can be solved with Flatseal .

kalligator avatar Nov 04 '23 11:11 kalligator