CGI Debugging: 'No Input File specified'

Posted by jeff.griffiths on 2007-02-06 19:25
OS: Linux | Product: Komodo | tags: debugging komodo linux PHP
Question: 

When I try to debug PHP using CGI Emulation, I get this error:

No input file specified.

Answer: 

This is because your PHP CGI interpreter has been compiled with cgi.force_redirect set to on for security reasons. We can fix this in Komodo by changing this setting in the copy of php.ini that Komodo uses:

- open the php.ini copy that Komodo is using:

~/.komodo/host-<hostname>/php/<php-version>/php.ini

- change the setting:

; cgi.force_redirect = 1

to

cgi.force_redirect = 0

Save the php.ini, then try debugging using CGI Emulation again.

Patrick.Hayes@s... | Fri, 2007-02-09 08:22

komodo 4.01 on ubuntu 6.10

I've set cgi.force_redirect to 0 on every php.ini on my system, yet I still get "no input file specified" every time I try to run the following script using cgi emulation:

<&#63;php
$hr = "<HR>";
echo "$hr\n";

if (array_key_exists('foo', $_POST)) {
  print("_POST[foo]=:" . $_POST['foo'] . ":<BR>$hr\n");
} else if (array_key_exists('foo', $_GET)) {
  print("_GET[foo]=:" . $_GET['foo'] . ":<BR>$hr\n");
} else {
  print("no foo defined<BR>$hr\n");
}

//phpinfo();
echo $hr;
&#63;>

jeff.griffiths | Wed, 2007-02-28 17:25

This is because the Ubuntu PHP is set to discard the script file path and not set SCRIPT_FILENAME in the environment. I have yet to find a magic bullet for this issue when using Ubuntu's php build.

--
JeffG | Komodo IDE 4.0 | MacBook Pro OS X Intel / Ubuntu 6.10 i386

brice | Mon, 2007-07-23 21:56

I am having a similar experience under Archlinux (not Ubuntu) using Komodo 4.1.1, build 279677, platform linux-libcpp5-x86.

Regardless of the cgi.force_redirect setting, I get the 'No input file specified' message upon debugging with CGI Emulation. I see that the Debugger Configuration wizard sets cgi.force_redirect to 0 in its "copied" php.ini (along w/ the xdebug reference).

The only way I found around this issue was to manually set the SCRIPT_FILENAME as a CGI environment variable. Set this to the absolute path of the .php file to be debugged.

Screenshot: - http://farm2.static.flickr.com/1419/882417034_53018a8b16_o.png

Does anyone have other ideas for a fix?

Thanks,

~ Brice

toddw
ActiveState Staff
Tue, 2007-07-24 14:32

Open up Komodo file:
&lt;install_dir&gt;/lib/mozilla/components/koInvokeInterpreters.py

At line 600, add another environment flag "SCRIPT_FILENAME" so it looks like:

        env["SCRIPT_NAME"]=scriptName
        env["SCRIPT_FILENAME"]=pathTranslated
        env["REQUEST_METHOD"]=requestMethod

Restart komodo and your CGI scripts should debug properly.

Cheers,
Todd

brice | Tue, 2007-07-24 19:35

Todd,

Your fix worked perfectly. Thanks for the prompt response.

I assume this has made it's way into the beta -- which I look forward to participating in once I purchase the IDE. Komodo is, after all, a project worth supporting! ;)

~ Brice

osmosis | Mon, 2008-06-09 21:54

What else could be causing this? I've tried everything above with no luck.

Komodo 4.3 beta
PHP 5.2.5
Windows XP

The trial period ran out before I had a chance to test cgi debugging, so I installed the beta to extend my trial and finish testing things out...

toddw
ActiveState Staff
Tue, 2008-06-10 10:57

Can you try using Komodo 4.3.2 or the Komodo 4.4 beta:
http://downloads.activestate.com/Komodo/releases/

If that does not fix the problem, we'll need some additional details like:
* where did you download PHP from
* how are performing the CGI debugging (through Komodo's Debug - F5 command)
* which interpreter is set in your PHP language preferences

Thanks,
Todd

osmosis | Tue, 2008-06-10 17:51

Thanks for the help Todd.

I'm using:

Komodo IDE, version 4.4.0-beta1, build 19400, platform win32-x86.
Built on Fri May 30 02:25:59 2008.

Web Developer Suite 2.0 which includes Apache 2.2 and PHP 5.2.5
http://sourceforge.net/projects/webdeveloper/

Preferences, PHP Language:

Interpreter: c:\www\php5\php.exe
php.ini: c:\www\php5\debug

I also tested with c:\www\php5\php-cgi.exe and received the same results.

the debug\php.ini was created during installation of Komodo. It's the default php.ini with the following prepended from Komodo:

; xdebug config added by Komodo
zend_extension_ts=C:\www\php5\ext\php_xdebug.dll
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
cgi.force_redirect = 0

I verified that those parameters are commented out everywhere else in the php.ini file.

Choosing Debug -> Go/Continue:

I choose "Use the CGI interpreter"

I check "Simulate CGI Environment"

and I add the post values according to the debugging PHP tutorial / demo.

It works if I choose "Use the CLI interpreter", but then it doesn't allow me to specify the post variables.

The only thing I can think to add at this point (in case it helps) is a copy of the php.ini along with lists of extensions enabled in php.

troyt
ActiveState Staff
Thu, 2008-06-12 13:48

It looks like doc_root setting in the php.ini bundled with Web Developer Suite 2.0 causes problems for the remote debugger. Comment out that line in c:\www\php5\debug\php.ini and it should work.

Thanks for bringing this to our attention! We'll create a bug for Komodo to handle this better and mention it in the release notes, but it's unlikely to be fixed in time for the 4.4 release.