I have two servers with the same configurations: httpd + mod_perl (I thought the settings were 100% the same), but in one server I got some perl warnings, while in the other server the same warnings get me FATAL errors. Look:
Server A log:
Use of uninitialized value in numeric eq (==) at
Server B log:
[Wed Jun 08 14:32:47 2016] [error] Use of uninitialized value in string eq at
In server A the request flow goes on and the user gets the desired result, but in server B the user gets a 500 error.
I am using
use strict;
use warnings;
in the file on both servers.
Any thoughts ?
Example of the code causing this warning/FATAL:
$allowed_sellers = any { $_ == $user->{user_id} } (111,123,222,345);
UPDATE:
I found this code in a module that I am using (Moo):
package Moo::_strictures;
use strict;
use warnings;
sub import {
if ($ENV{MOO_FATAL_WARNINGS}) {
require strictures;
strictures->VERSION(2);
#_ = ('strictures');
goto &strictures::import;
}
else {
strict->import;
warnings->import;
}
}
1;
But the env variable MOO_FATAL_WARNINGS seems to not be defined. Any thougts ?
SOLVED:
Guys, thanks a lot! We have finally discovered the problem: In server A the version of module Moo was 1.003 while server B was using a newer version 2.000001
Before version 2, calling use Moo; enabled strictures, which makes all warnings fatal except for a few categories. This caused a lot of problems*, so warnings are no longer fatal in version 2 and up.
To fix, upgrade Moo to the latest version. While you're at it, you should really fix the cause of the warnings, too.
* See the following discussions:
Default fatalization of warnings needs mst's clarification before new major strictures
fatal warnings are a ticking time bomb
Moo 2 and strictures 2
Related
I'm installing prestashop 1.6.1.10 on ubuntu/xenial64 (vagrant).
I get error on Configure shop information - An error occurred during installation...
In the log I see:
[Tue Feb 14 08:27:12.364749 2017] [:error] [pid 7587] [client 55.55.56.1:49446] PHP Fatal error: Uncaught PrestaShopException: Property Currency->decimals is not valid in /vagrant/prestashop/classes/ObjectModel.php:909
Stack trace:
#0 /vagrant/prestashop/classes/LocalizationPack.php(299): ObjectModelCore->validateFields()
#1 /vagrant/prestashop/classes/LocalizationPack.php(68): LocalizationPackCore->_installCurrencies(Object(SimpleXMLElement), true)
#2 /vagrant/prestashop/install/models/install.php(549): LocalizationPackCore->loadLocalisationPack('<?xml version="...', '', true)
#3 /vagrant/prestashop/install/controllers/http/process.php(207): InstallModelInstall->configureShop(Array)
#4 /vagrant/prestashop/install/controllers/http/process.php(93): InstallControllerHttpProcess->processConfigureShop()
#5 /vagrant/prestashop/install/classes/controllerHttp.php(173): InstallControllerHttpProcess->process()
#6 /vagrant/prestashop/install/index.php(31): InstallControllerHttp::execute()
#7 {main}
thrown in /vagrant/prestashop/classes/ObjectModel.php on line 909, referer: http://dev.imagine-lotus.design/install/index.php?restart=true
What can it be?
I've installed this same code, on the same ubuntu image before and it was OK.
EDIT:
I by-pass this issue by commenting out /classes/ObjectModel.php:909
I will un comment it after install is done
NOTE: after install an error in the front, I had to create a currency in the backend to solve it
I'm still getting errors, I noticed that prestashop was installed with multi-language, which is different than previous installation.
In the install process I didn't choose to install other language than EN,
Maybe chrome passes some variable that presta recognize as my native language and tries to install, and fails
I by-pass this issue by commenting out /classes/ObjectModel.php:909
I will un comment it after install is done
NOTE: after install an error in the front, I had to create a currency in the backend to solve it
I'm still getting errors, I noticed that prestashop was installed with multi-language, which is different than previous installation.
In the install process I didn't choose to install other language than EN, Maybe chrome passes some variable that presta recognize as my native language and tries to install, and fails
so I Use Firefox instead of chrome and solve the problem
I got the same error while installing Prestashop 1.7 on licalhost xampp. But in my case, I did not even get the error log to find out the error, moreover, the installation request was being made via AJAX so error identification was tough, but after more research, I found out the source of the error.
C:\xampp\htdocs\prestashop\classes\localizationPack.php
I used
"try" and "catch"
to identify the error. The error is originating from
C:\xampp\htdocs\prestashop\vendor\icanboogie\cldr\lib\webProvider.php
as a result of network problem. Here, the script needs to send a cURL request to an online location, so if there is no internet connection, it shows that error.
After finding this out, I connected to a connection and tried it again and it worked perfectly.
Try that too.
Hope it works as it did for me.
I'm trying to upgrade the sensu-puppet module and im getting an error when i run puppet now: the error is:
Error: Could not retrieve catalog from remote server: Error 400 on
SERVER: Invalid parameter prefetch on Sensurabbitmqconfig[<(hostname
is here, removed for this post on ask puppet)>] at
/etc/puppet/environments/staging/modules/sensu/manifests/rabbitmq/config.pp:123
Warning: Not using cache on failed catalog Error: Could not retrieve
catalog; skipping run
I have no idea what's going wrong or how to fix it. I looked in the pathway at the rabbitmq config and found this:
prefetch => $sensu::rabbitmq_prefetch
But I'm not sure what the issue is. Anyone know what might be causing this?
Where did you get the puppet module and what way?
Did you use puppet module install or a git pull?
Make sure sure that the parameter you want to use is in
modules/sensu/lib/puppet/provider/sensu_rabbitmq_config/json.rb
and also
modules/sensu/lib/puppet/type/sensu_rabbitmq_config.rb
I'm using a perl cgi script that uses our own libraries, which use the "no autovivification" pragma. E.g.
/usr/lib/company/mysim.cgi:
#!/usr/bin/perl -w
use strict;
# ... other use
use Company::Module1;
/usr/lib/perl5/Company/Module1.pm
package Company::Module1;
no autovivification;
use strict;
use warnings;
Approximately 50% of the time, when accessing the URL to reach the cgi script the compilation fails with...
[Fri Dec 04 15:40:10.744901 2015] [:error] [pid 30455:tid 2961136448] Bareword "A_HINT_STRICT" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_WARN" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_FETCH" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_STORE" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_EXISTS" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_DELETE" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nCompilation failed in require at /usr/lib/company/mysim.cgi line 14.\nBEGIN failed--compilation aborted at /usr/lib/company/mysim.cgi line 14.\n
(taken from /var/log/apache2/ssl/error.log as this script sits on the https port).
My environment is:
- debian jessie (8.2)
- tomcat7
- apache2 (2.4)
- perl 5.20.2
- libautovivification-perl 0.12-1+b1
My questions are:
Has anyone seen this before? It seems odd that the autovivification module fails to compile due to a "use strict" pragma.
Can anyone explain the intermittent nature of the compilation error? Even more odd, the cgi fails to compile ~half the time, and works fine (i.e. runs and returns expected results) the other ~half.
Thanks for your time.
09/12/2015: Some additional information...
Thanks all for the feedback.
There's no explicit creation of threads, though this is in the context of apache so there's presumably threading of requests.
The root cause does seem to be a failure in the XSLoader. At least this minimal working example...
package autovivification;
use 5.008_003;
use strict;
use warnings;
our $VERSION;
BEGIN {
$VERSION = '0.12';
}
BEGIN {
require XSLoader;
XSLoader::load(__PACKAGE__, $VERSION);
}
my %bits = (
strict => A_HINT_STRICT,
warn => A_HINT_WARN,
fetch => A_HINT_FETCH,
store => A_HINT_STORE,
exists => A_HINT_EXISTS,
delete => A_HINT_DELETE,
);
compiles, whereas this
package autovivification;
use 5.008_003;
use strict;
use warnings;
our $VERSION;
BEGIN {
$VERSION = '0.12';
}
#BEGIN {
# require XSLoader;
# XSLoader::load(__PACKAGE__, $VERSION);
#}
my %bits = (
strict => A_HINT_STRICT,
warn => A_HINT_WARN,
fetch => A_HINT_FETCH,
store => A_HINT_STORE,
exists => A_HINT_EXISTS,
delete => A_HINT_DELETE,
);
fails with the same error.
So, I'll go a-poking around for a load error in the apache logs.... somewhere.
Thanks again for your time.
16/12/2015: Update - Fixed
The root cause was mod_perl, combined with a (possible) change between apache 2.2 and 2.4. The apache configuration for the script, which gives it a ScriptAlias URI of /cgi-bin/script, occurs before setting up the URI /cgi-bin to be handled by mod_perl. In apache 2.2, this ordering seems to be important and the script was not handled by mod_perl. However, in apache 2.4 the ordering does not seem to be important and the script is now handled by mod_perl.
The error arose because this script was not (and never meant to be) handled by mod_perl. The fix was to change the URI for the script to /somethingelse/script.
Thanks to everyone for the comments.
The root cause was mod_perl, combined with a (possible) change between apache 2.2 and 2.4. The apache configuration for the script, which gives it a ScriptAlias URI of /cgi-bin/script, occurs before setting up the URI /cgi-bin to be handled by mod_perl. In apache 2.2, this ordering seems to be important and the script was not handled by mod_perl. However, in apache 2.4 the ordering does not seem to be important and the script is now handled by mod_perl.
The error arose because this script was not (and never meant to be) handled by mod_perl. The fix was to change the URI for the script to /somethingelse/script.
– HalfOpenedEye
I have a long script that was not written by me. When i run it I get:
phantomjs file.js
SyntaxError: Parse error
i checked out the manual and --help, and the best i could came up with was:
phantomjs --debug=yes file.js
(irrelevant debug statement from CookieJar)
SyntaxError: Parse error
Is there any better way to get at least a line number? or any hint at all?
Run the file with node. If there is a parse error it will report it.
If the file is valid, then node will also try to run it, which will fail if your script depends on something not available in your node environment. So you'll have to ignore any runtime errors.
For example, given hello-world.js:
// Say Hello World twice
for (var i=0; i<2; i++) {
console.log("Hello World") );
}
Run it with node:
node hello-world.js
Output:
/home/someone/somewhere/hello-world.js:3
console.log("Hello World") );
^
SyntaxError: Unexpected token )
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Your file.js contains an invalid syntax. You should check it with a syntax validator. An online tool which I have created can be one possible solution, check out http://esprima.org/demo/validate.html.
Getting More Information From PhantomJS
The next version of PhantomJS (presumably it will be 1.9.8, whatever comes after 1.9.7) will output errors like this:
SyntaxError: Parse error
http://localhost:9000/scripts/49e8b4f4.vendor.js:8
So that's slightly more useful than the current message.
Unfortunately there are no nightly builds for PhantomJS, so at this time you will need to compile your own version of master if you want to try this.
Debugging Minified files
If you are working with a minified file, often the line number won't be very helpful, and often debugging the un-minified file won't give you the parse error.
To solve this, once you get phantomjs to give you the name of the file, you can use the online demo of Esprima to get an actual parse of your JavaScript code:
http://esprima.org/demo/parse.html
From there, you can enter strategic line breaks to isolate the actual error.
Lint Tools are Sub-optimal for this use-case
A lint tool like jslint or jshint are more opinionated than a real parser, so if you are looking for a very specific syntax error, I would recommend using a real parser, since it will check only for code validity, and not opinionated styling guidelines. I'm not implying lint tools don't have value, just that they won't be as helpful for solving this type of problem.
You can also use syntax linters like jslint or jshint
I received SyntaxError: Parse error while trying to require a custom minified jquery.
I found the solution was to add a blank line to the bottom of jquery.min.js.
Hopefully this helps someone. Using PhantomJS 1.9.7.
I use a simple shell script that will run Phantom normally if no parse errors are found, otherwise it will display the errors. It runs the script through node, checks for SyntaxError in the output and then re-runs node to the terminal if there are errors. It passes all the command line arguments along to Phantom.
Failure mode for this method is if your node parser is significantly different from your Phantom parser. Mine are close enough that it's never been a problem.
usage: ./debug.sh --myArg1 val1 --myArg2 val2
debug.sh:
ERROR=$(node myscript.js 2>&1 >/dev/null | grep "SyntaxError")
if [ "$ERROR" = "" ]; then
echo "No parse errors, running script..."
# run the script with Phantom and pass all the args to it
phantomjs accession.js $*
else
echo "*********************************************************"
echo "********* There are parse errors in the script: *********"
echo "*********************************************************"
# show the errors by running again but not redirecting
node accession.js
fi
I did have the same issue, but none of the solutions worked for me.
I figured that the issue was probably an unsupported syntax by PhantomJS's webkit, since my page was working correctly in current browsers' versions.
What I did was finding out which webkit version PhantomJS was using, for 1.9.* it's here, 34.534.
Now we have to find the Chromium version using the same webkit, or close to it, in here (for Mac).
Ended up going with the Mac OSX 267668 and installed it.
Loaded the same URL as PhantomJS, and here it was, a real Uncaught SyntaxError: Unexpected token with a full stack trace.
Hope that helps.
Whenever I run any jython program in Eclipse, I got the following error in the beginning of the output:
" Failed to
get environment, environ will be
empty: (0, 'Failed to execute command
([\'sh\', \'-c\', \'env\']):
java.io.IOException: Cannot run
program "sh": Crea teProcess error=2,
The system cannot find the file
specified')
First, my environment is:
Windows 2008
JDK 1.6.0u10
jython 2.2.1
I did some digging, and I realized that this message is produced in the function javaos.getenv().
Whenever I call the javaos.getenv() function, it throws the following error:
C:\jython2.2.1>java -jar jython.jar
import javaos
print javaos.getenv("user.name")
Failed to get environment, environ
will be empty: (0, 'Failed to execute
command ([\'sh\', \'-c\', \'env\']):
java.io.IOException: Cannot run
program "sh": Crea teProcess error=2,
The system cannot find the file
specified')
This is strange, because I'm currently using a Windows machine, not an Unix.
Try to uncomment and change the os setting in the 'registry' file
(it is in the same directory as your jython.jar / i hope)
# python.os determines operating-specific features, similar to and overriding the
# Java property "os.name".
# Some generic values are also supported: 'nt', 'ce' and 'posix'.
# Uncomment the following line for the most generic OS behavior available.
#python.os=None
python.os=nt
# try nt or dos
Interesting. Well, I seem to have found the relevant code here:
http://www.koders.com/python/fid4B7C33153C1427D2CE19CE361EA9519D1652F802.aspx?s=self
If you look towards the bottom, it seems when setting the environment command jython thinks your os is posix. You say you're using "Windows 2008". I'm not sure what that is. Do you mean Windows Server 2008? If so, it's quite new and if you look at the _getOsType function in the same module, it looks like it might be too new for that module. You may need to upgrade to the most recent version of jython or Eclipse. But it's quite possible they haven't yet released a version that supports this OS. If that's the case, you may need to just report the bug to them.
I'm running on Windows 7.
I'm running Jython as a script in the Websphere wsadmin tool.
I encountered this same error.
I cut-n-pasted these lines from javaos.py into my script:
os or sys.registry.getProperty( "python.os" ) or \ java.lang.System.getProperty( "os.name" )
and it returned "Windows Vista".
So I performed the same surgery as suggested above, ie., add Windows Vista to javaos.py and that solved my problem.
I ran into the same error, using Windows Vista, and Jython 2.5.1, under Eclipse/PyDev By editing javaos.py, to include "Windows Vista" in the OR statement in getOsType,;
I fixed the error. (I've filed a bug with the fix under the PyDev Tracker at SourceForge.)
Details:
I installed the full version of Jython, and that did not help.
I also tried editing the "registry" file in the Jython tree. That did not help either.
Then I looked at the files in:
C:\eclipse-platform-3.5-win32\eclipse\plugins\org.python.pydev.jython_1.4.8.2881\Lib
to find "javaos.py" and added a bit of code to read:
def _getOsType( os=None ):
os = os or sys.registry.getProperty( "python.os" ) or \
java.lang.System.getProperty( "os.name" )
_osTypeMap = (
( "nt", r"(nt)|(Windows NT)|(Windows NT 4.0)|(WindowsNT)|"
r"(Windows 2000)|(Windows XP)|(Windows CE)|(Windows Vista)" ),
( "dos", r"(dos)|(Windows 95)|(Windows 98)|(Windows ME)" ),
( "mac", r"(mac)|(MacOS.*)|(Darwin)" ),
( "None", r"(None)" ),
( "posix", r"(.*)" ), # default - posix seems to vary mast widely
)
for osType, pattern in _osTypeMap:
if re.match( pattern, os ):
break
return osType
I've used this hack from Dave Brands blog: http://dbrand666.wordpress.com/2010/04/08/fix1/
try:
import javaos
if javaos._osType == 'posix' and \
java.lang.System.getProperty('os.name').startswith('Windows'):
sys.registry.setProperty('python.os', 'nt')
reload(javaos)
except:
pass