How to edit Catalyst source files with proper syntax checking?

Hi,

I am working on a Perl Catalyst application. I have set up an Ubuntu (14.04) server with Apache, Subversion, and Jenkins so that a Jenkins job will be fired off any time a file is checked in, and the tests will be run on it. I’ve also configured Starman to run the Catalyst app, and Apache to use mod_proxy_fcgi to access it.

On my laptop (running Windows 8.1), I’ve got the Subversion repo checked out under my Documents folder. I’ve opened in Komodo the file …/app/lib/app/Controller/Room.pm (created by default when creating a Catalyst app – the one I’m working on is just the default, for right now). It’s complaining about line 36: “Invalid CODE attribtutes: Path : Args(0).”

However, if I open a command prompt and navigate to that folder, and run “perl -c Root.pm” it says “Root.pm syntax OK”.

So, Komodo is missing some libraries somewhere, or something?

With that in mind, I went into Komodo Preferences and added …/app/lib to it, and re-ran the syntax check, but it’s still reporting “Invalid CODE attributes” as above.

Years ago I used Komodo to edit Catalyst files and the syntax check was working – but that was using a company and computer that are long gone. Hopefully this is something simple I’ve overlooked. Appreciate any insight.

Thanks,
Ken

Any chance you could share the file in question?

Also be sure to check out the prefs under Preferences > Syntax & Spell Checking > Language: Perl

Particularly the “Don’t execute BEGIN blocks in current document during syntax-checking” settings.

Certainly, below is the “generic” Root.pm source file. There are other files involved in the project but the error seems to be regarding the “sub” construct. If this isn’t enough let me know and I’ll share everything somehow.

Thanks,
Ken


package app::Controller::Root;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller' }

#
# Sets the actions in this controller to be registered with no prefix
# so they function identically to actions created in MyApp.pm
#
__PACKAGE__->config(namespace => '');

=encoding utf-8

=head1 NAME

app::Controller::Root - Root Controller for app

=head1 DESCRIPTION

[enter your description here]

=head1 METHODS

=head2 index

The root page (/)

=cut

sub index :Path :Args(0) {
    my ( $self, $c ) = @_;

    # Hello World
    $c->response->body( $c->welcome_message );
}

=head2 default

Standard 404 error page

=cut

sub default :Path {
    my ( $self, $c ) = @_;
    $c->response->body( 'Page not found' );
    $c->response->status(404);
}

=head2 end

Attempt to render a view, if needed.

=cut

sub end : ActionClass('RenderView') {}

=head1 AUTHOR

Catalyst developer

=head1 LICENSE

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

__PACKAGE__->meta->make_immutable;

1;

Ok, so after some internal investigation (thanks @andyg) it appears that your error is caused because Komodo is indeed unable to see some of your dependencies. Specifically the dependency that defines MODIFY_CODE_ATTRIBUTES. You were on the right track in defining import directories for Perl. My guess is you simply didnt define the correct directory.

I can’t tell you exactly what directory you need to import unfortunately, as I’m not familiar with Catalyst.

Thanks Nathan.

I searched for “MODIFY_CODE_ATTRIBUTES” throughout the Catalyst files, and found nothing. Then I repeated that grep in c:\Perl64, and it found it in several places. Checking Komodo, I found no other libs defined, so I added c:\Perl64\lib. I also noticed the “Default Perl Interpreter” was “find on path” so I set it to the only Perl I have installed, C:\Perl64\bin\perl.exe. I also filled in the next two fields, “PPM Location” C:\Perl64\bin\ppm.bat and “cpan Location” C:\Perl64\bin\cpan.bat.

However, even with these changes, it’s still giving the error.

Can you tell me how to determine exactly what command-line it’s running when it invokes the “perl -c” syntax check?

I just did one from a command line, from the Catalyst project’s root (i.e., outside of its “lib” folder) and it still finds no errors. I think the answer might be either that command line, or the environment variables set when it runs – can you help me find those as well?

Thanks again,
Ken

Seems the command it’s running is:

/usr/bin/perl -I . -cw /path/to/file

Although it might have some additional import statements in your case.

Maybe you could compare what perl specific env variables you have on your terminal by executing printenv to what perl specific environment variables are configured in Komodo (Prefs > Environments).

Hi nathanr,

I’m running Komodo on Windows, so I did “set > set.txt” and then compared it to the env vars listed when I start up the debugger (I didn’t find Prefs > Environment), and updated set.txt with comments indicating the differences.

Basically, it seems the differences are solely 32-bit vs. 64-bit related (apparently, Komodo is a 32-bit application?).

Below is the comparison and notes. I added "x " at the beginning of a line if the env var was identical, and "! " if it was different. Also [not_in_komodo] and [in_komodo] to indicate values that are only in one and not the other.

Appreciate any additional insight to get this working.

Thanks,
Ken


x ALLUSERSPROFILE=C:\ProgramData
x APPDATA=C:\Users\name\AppData\Roaming
x CLOUDSDK_PYTHON=C:\python27\python.exe

! CommonProgramFiles=C:\Program Files\Common Files

The above is different in Komodo, it reads “C:\Program Files (x86)\Common Files” (i.e., like below, in other words, both env vars have same contents).

x CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
x CommonProgramW6432=C:\Program Files\Common Files
x COMPUTERNAME=ENVY
x ComSpec=C:\Windows\system32\cmd.exe
x dircmd=/ogn/a
x FP_NO_HOST_CHECK=NO
x HAXEPATH=C:\HaxeToolkit\haxe
x HOMEDRIVE=C:
x HOMEPATH=\Users\name
x LOCALAPPDATA=C:\Users\name\AppData\Local
x LOGONSERVER=\ENVY
x NEKO_INSTPATH=C:\HaxeToolkit\neko
x NUMBER_OF_PROCESSORS=8
x OnlineServices=Online Services
x OS=Windows_NT

! Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\ActiveState Komodo IDE 9;C:\Perl64\site\bin;C:\Perl64\bin;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Hewlett-Packard\SimplePass;C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\Microsoft\Web Platform Installer;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\WinMerge;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Windows NT\Accessories;C:\Program Files (x86)\Notepad++;C:\HaxeToolkit\haxe;C:\HaxeToolkit\neko;C:\Program Files (x86)\Skype\Phone;C:\Users\name.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\

The Path is different. Break the above apart and identify where it’s different:

x C:\ProgramData\Oracle\Java\javapath
[not_in_komodo] C:\Program Files (x86)\ActiveState Komodo IDE 9
x C:\Perl64\site\bin
x C:\Perl64\bin
x C:\Program Files (x86)\Intel\iCLS Client
x C:\Program Files\Intel\iCLS Client
x C:\Windows\system32
x C:\Windows
x C:\Windows\System32\Wbem
x C:\Windows\System32\WindowsPowerShell\v1.0
x C:\Program Files\Intel\Intel® Management Engine Components\DAL
x C:\Program Files\Intel\Intel® Management Engine Components\IPT
x C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL
x C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT
x C:\Program Files\Hewlett-Packard\SimplePass
x C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin
x C:\Program Files\Microsoft\Web Platform Installer
x C:\Program Files\Microsoft SQL Server\110\Tools\Binn
x C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0
x C:\Program Files\Microsoft SQL Server\120\Tools\Binn
x C:\Program Files (x86)\Windows Live\Shared
x C:\Program Files (x86)\WinMerge
x C:\Program Files\TortoiseSVN\bin
x C:\Program Files\Windows NT\Accessories
x C:\Program Files (x86)\Notepad++
x C:\HaxeToolkit\haxe
x C:\HaxeToolkit\neko
x C:\Program Files (x86)\Skype\Phone
[not_in_komodo] C:\Users\name.dnx\bin
[in_komodo] C:\Windows\system32\config\systemprofile.dnx\bin
x C:\Program Files\Microsoft DNX\Dnvm
x C:\Program Files\Microsoft SQL Server\130\Tools\Binn\

x PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
x PCBRAND=Pavilion
x Platform=MCD

! PROCESSOR_ARCHITECTURE=AMD64

In Komodo, the above is “x86”, and it has an additional env var:
[in_komodo] PROCESSOR_ARCHITEW6432=AMD64

x PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
x PROCESSOR_LEVEL=6
x PROCESSOR_REVISION=3c03
x ProgramData=C:\ProgramData

! ProgramFiles=C:\Program Files

In Komodo, the above is “C:\Program Files (x86)” (i.e., it and the below have identical contents).

x ProgramFiles(x86)=C:\Program Files (x86)
x ProgramW6432=C:\Program Files
PROMPT=$P$G
x PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement
x PUBLIC=C:\Users\Public

There’s an extra env var in Komodo:
[in_komodo] SESSIONNAME=Console

x SystemDrive=C:
x SystemRoot=C:\Windows
x TEAMCITY_DATA_PATH=C:\ProgramData\JetBrains\TeamCity
x TEMP=C:\Users\name\AppData\Local\Temp
x TMP=C:\Users\name\AppData\Local\Temp
x USERDOMAIN=envy
x USERDOMAIN_ROAMINGPROFILE=envy
x USERNAME=name
x USERPROFILE=C:\Users\name
x VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox
x VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools
x VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools
x windir=C:\Windows

Hi Ken, in your Edit > Preferences > Syntax and Spell Checking > Perl, do you have “Errors and Warnings” selected? Or “Errors only”? If the former, please try the latter. Your original post does not indicate whether you are getting a warning message or an error message, while your manual running of perl -c ... is only checking for errors.