How do I best handle a needed patch for Perl/Tk? - perl

I am making a change to Perl/Tk for an application that has its own resident Perl and modules installation (so we can drop the app in and go).
I've found a problem I am experiencing that I just stumbled on what seems to be the patch I need here: http://osdir.com/ml/lang.perl.tk/2004-10/msg00030.html
Bug confirmed. Here's the patch against Tk804.027:
--- Tk-804.027/pTk/mTk/generic/tkEntry.c Sat Mar 20 19:54:48 2004
+++ Tk-804.027-perl5.8.3d/pTk/mTk/generic/tkEntry.c Tue Oct 19 22:50:31 2004
## -3478,6 +3478,18 ##
Tcl_DStringFree(&script);
#else
+ switch (type) {
+ case VALIDATE_INSERT:
+ type = 1;
+ break;
+ case VALIDATE_DELETE:
+ type = 0;
+ break;
+ default:
+ type = -1;
+ break;
+ }
+
code = LangDoCallback(entryPtr->interp, entryPtr->validateCmd, 1, 5, "%s
%s %s %d %d",
new, change, entryPtr->string, index, type);
if (code != TCL_OK && code != TCL_RETURN) {
Regards,
Slaven
I'd like to apply this patch or if there is a newer version of the Perl/Tk module I can upgrade to that includes this patch already that doesn't require I change the version of Perl, do that.
Here is what I can find from the installation for this app:
perl -v = 5.8.4
$Tk::version = '8.4'
$Tk::patchlevel = '8.4'
$Tk::VERSION = '804.027'
So..
1a) if there is a newer Tk VERSION that includes the patch in the link above, how do I upgrade just that module in the specific Perl installation location for this app?
1b) how do I know if that upgrade is compatible with 5.8.4 of Perl (I don't want to upgrade perl at this point)
2) if not, how do I apply that patch defined in that link?

First, check CPAN to see what the current version of Tk is. At the time of this response, it's 804.028, so it's possible that your bug has been fixed. You can check the Tk bug queue to see the state of reported bugs, although I don't know if your specific one was ever entered in the queue. You can also check the Changes file for the release to see if your issue is mentioned there.
If you don't see anything specific, you might note that the author of your quoted message is the maintainer of Tk, so it's likely that the patch has been applied. :)
Tk is a distribution. You can't upgrade individual modules.
Check the Perl/Platform Version Matrix to see which versions of Tk work on which platforms and under what versions of Perl.
If you absolutely must apply just this one change, download the source for the version of Tk you're using, apply the patch, and rebuild it.

Related

mod_perl cannot use threaded MPM without ithreads enabled Perl

Firstly, I have asked a similar previous question years ago for an older version Compile Perl without threads but my previous answer doesn't seem to work now.
My set up is a custom compiled version of Perl
This is perl 5, version 34, subversion 1 (v5.34.1) built for x86_64-linux
CFLAGS='-m64 -mtune=nocona' ./Configure -des -A ccflags=-fPIC -Dprefix=/opt/perl
Which to my understanding shows that threads aren't enabled (I think it would say at the end if so)
I have trying to get this running with Apache 2.4.53 (but I don't think it's getting that far anyway).
Apache config options..
./configure --enable-proxy --enable-rewrite --enable-headers --enable-ssl --with-apr=/usr/local/apr/
As far as I'm aware, and previous answer, was if using Perl without threads, you can compile mod_perl without threads also, this is done by using
mod_perl version is 2.0.12
MP_NO_THREADS=1
So my full command for trying to compile mod_perl is
perl Makefile.PL MP_NO_THREADS=1 MP_APXS=/usr/local/apache2/bin/apxs
the readme says...
# For httpd-2.4, we can't use mpm_is_threaded(), because MPMs are loadable
# modules. We therefore treat httpd as a whole project as threaded. It is
# still possible to disable threading by using MP_NO_THREADS=1
I can also see a bit of code in the Makefile.PL
if ($build->{MP_NO_THREADS}) {
$build_threaded = 0;
}
and I can see $build_threaded indeed gets set to 0.
However, when I
make && make test
I get
[Thu Apr 28 12:18:02.392480 2022] [perl:error] [pid 38185:tid 140616570507840]
cannot use threaded MPM without ithreads enabled Perl
I can't really see anything in the code (other than checks) that does anything different depending on that code though, but I'm not familiar with it at all, so probably missing something important ?
I have also tried with -Uuseithreads -Uusethreads -Dusethreads=undef
Edit: the bit of code producing the error looks like
## src/modules/perl/mod_perl.c
#ifndef USE_ITHREADS
if (modperl_threaded_mpm()) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, base_server,
"cannot use threaded MPM without ithreads enabled Perl");
exit(1);
}
#endif
and
Apache2::Build::PERL_HAS_ITHREADS ? "w/" : "w/o";
shows as "w/o" when running
Digging further I see the code seems to call ap_mpm_query() so checking with Apache and in apachectl -v this looks incorrect...I think threaded should be no, so checking on why that is..
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Which is odd..so I think
Looks like something changed with Apache, so seem to have to specify the mpm mode, so if I change Apache compile to --with-mpm=prefork this seems to work.
./configure --enable-proxy --enable-rewrite --enable-headers --enable-ssl --with-apr=/usr/local/apr/ --with-mpm=prefork

ng server command opens file open option menu

In VS code editor, ng serve command opening "How do you want to open this file?" dialog box in
The answer by Petr Freiberg helped get me to what I believe is a better solution. Instead of deleting files that may or may not actually be important for the system, we should update our PATH variables so that the "correct" command is found first.
In my situation, I had my npm paths in this order:
C:\Users\Me\AppData\Roaming\npm\node_modules\#angular\cli\bin
C:\Users\Me\AppData\Roaming\npm
I just switched the order so that C:\Users\Me\AppData\Roaming\npm came first.
The issue is that the terminal is finding the first "command match" which may just be a file, so that is why it is asking where you want to open it.
I did run the command Run Get-Command -All ng | ForEach-Object Path as Petr suggested, which called out the order issue I describe here.
I encountered a similar problem when executing a Docker command within Visual Studio Code. I also got a window asking "How do you want to open this file?". I think the problem is not in Visual Studio Code, but in PowerShell, which Visual Studio Code uses.
I solved it like this:
Run Get-Command -All docker | ForEach-Object Path
Among the file paths returned, remove those that do not end in *.exe (use
Remove-Item):
For ng it should be same.
Credits: https://stackoverflow.com/a/63981418/1816014
i have faced the same issue, while trying to run ng -v or ng --version, it pops open a Open option editor, which gives following ng.js text...
#!/usr/bin/env node
'use strict';
// Provide a title to the process in `ps`.
// Due to an obscure Mac bug, do not start this title with any symbol.
try {
process.title = 'ng ' + Array.from(process.argv).slice(2).join(' ');
} catch (_) {
// If an error happened above, use the most basic title.
process.title = 'ng';
}
// This node version check ensures that extremely old versions of node are not used.
// These may not support ES2015 features such as const/let/async/await/etc.
// These would then crash with a hard to diagnose error message.
// tslint:disable-next-line: no-var-keyword
var version = process.versions.node.split('.').map((part) => Number(part));
if (version[0] % 2 === 1 && version[0] > 14) {
// Allow new odd numbered releases with a warning (currently v15+)
console.warn(
'Node.js version ' +
process.version +
' detected.\n' +
'Odd numbered Node.js versions will not enter LTS status and should not be used for production.' +
' For more information, please see https://nodejs.org/en/about/releases/.',
);
require('../lib/init');
} else if (
version[0] < 12 ||
version[0] === 13 ||
(version[0] === 12 && version[1] < 14) ||
(version[0] === 14 && version[1] < 15)
) {
// Error and exit if less than 12.14 or 13.x or less than 14.15
console.error(
'Node.js version ' +
process.version +
' detected.\n' +
'The Angular CLI requires a minimum Node.js version of either v12.14 or v14.15.\n\n' +
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
);
process.exitCode = 3;
} else {
require('../lib/init');
}
what is the error here, i tried uninstall clear cache and install but still same error....

Reprocessing - VSCode Reason Refmt breaks project

I'm hunting a fun little bug in a tiny reprocessing test: reprocessing01.
The project builds just fine until I make a change and trigger refmt via vscode, and then the project will no longer compile.
Here's the code that compiles and runs just fine for me before making any changes.
open Reprocessing;
type stateT = {
image: imageT,
};
let setup = (env) => {
Env.size(~width=800, ~height=600, env);
let image = Draw.loadImage(
~filename="assets/Wave_pattern_by_inkelv1122_on_flickr_800w.jpg",
~isPixel=false, env);
{
image: image
}
};
let draw = ({image} as state, env) => {
Draw.background(Constants.white, env);
Draw.image(
image,
~pos=(0,0),
~width=Env.width(env),
~height=Env.height(env),
env
);
state
};
run(~setup, ~draw, ());
If I open the project in vscode, make a change such as adding let myvar = 42; at the top, and save to trigger refmt, that introduces this error:
/Users/myer/dev/react/reasonml-playground/reprocessing01/node_modules/bs-platform/lib/bsc.exe -pp "/Users/myer/dev/react/reasonml-playground/reprocessing01/node_modules/bs-platform/lib/refmt3.exe --print binary" -bs-super-errors -w -30-40+6+7+27+32..39+44+45+101 -bs-D BSB_BACKEND="bytecode" -nostdlib -I '/Users/myer/dev/react/reasonml-playground/reprocessing01/node_modules/bs-platform/lib/ocaml' -no-alias-deps -color always -c -o src/index.mlast -bs-syntax-only -bs-simple-binary-ast -bs-binary-ast -impl /Users/myer/dev/react/reasonml-playground/reprocessing01/src/index.re
File "/Users/myer/dev/react/reasonml-playground/reprocessing01/src/index.re", line 12, characters 4-5:
Error: 2817: <UNKNOWN SYNTAX ERROR>
The line in question is the last one of this code block:
Draw.loadImage(
~filename="assets/Wave_pattern_by_inkelv1122_on_flickr_800w.jpg",
~isPixel=false,
env,
);
After this, the only way out is to revert the code to before the changes introduced by refmt.
I suspect that my version of refmt is out of sync with the one required by bsb-native#2.1.1, but I'm not sure which one to install. I have:
$ refmt --version
Reason 3.0.0 # bee43b0
Is there a table that shows compatible versions between reason-cli and bs-platform?
Are there other ways I should investigate this issue or other potential root causes of this behavior?
UPDATE:
I was able to upgrade bsb-native to the master branch and it worked when building to native until I added some more code in reprocessing02
this issue is because bsb-native#2.1.1 comes with an old version of refmt (pre version 3) which can't read the code that your global refmt outputs (most likely because of the trailing commas). I'm working on making a new release 3.2.0 on all platforms, which comes with the latest refmt. If you're on OSX you can try it by just changing your dep to bsansouci/bsb-native#3.2.0, nuking node_modules and reinstalling.
Sorry for the inconvenience. I'm planning on making my release cycle tighly coupled with bsb's release cycle.

What does vim-perl plugin do that "syntax on" doesn't?

I'm trying to get vim set up as an IDE for Perl. I'm using generic, text-based vim, not gvim.
I installed the "vim-perl" addon at https://github.com/vim-perl/vim-perl using the vim addon manager per the suggestion of someone else. At least I think it's installed but I don't notice any difference in how the file is processed.
First I installed the vim-addon-manager with Debian's package manager. Then I put the following code in my .vimrc file and reloaded it:
" put this line first in ~/.vimrc
set nocompatible | filetype indent plugin on | syn on
fun! SetupVAM()
let c = get(g:, 'vim_addon_manager', {})
let g:vim_addon_manager = c
let c.plugin_root_dir = expand('$HOME', 1) . '/.vim/vim-addons'
" Force your ~/.vim/after directory to be last in &rtp always:
" let g:vim_addon_manager.rtp_list_hook = 'vam#ForceUsersAfterDirectoriesToBeLast'
" most used options you may want to use:
" let c.log_to_buf = 1
" let c.auto_install = 0
let &rtp.=(empty(&rtp)?'':',').c.plugin_root_dir.'/vim-addon-manager'
if !isdirectory(c.plugin_root_dir.'/vim-addon-manager/autoload')
execute '!git clone --depth=1 git://github.com/MarcWeber/vim-addon-manager '
\ shellescape(c.plugin_root_dir.'/vim-addon-manager', 1)
endif
" This provides the VAMActivate command, you could be passing plugin names, too
call vam#ActivateAddons([], {})
endfun
all SetupVAM()
" ACTIVATING PLUGINS
" OPTION 1, use VAMActivate
VAMActivate github:vim-perl/vim-perl
" OPTION 2: use call vam#ActivateAddons
"call vam#ActivateAddons([vim-perl], {})
use <c-x><c-p> to complete plugin names
" OPTION 3: Create a file ~/.vim-srcipts putting a PLUGIN_NAME into each line
" See lazy loading plugins section in README.md for details
" call vam#Scripts('~/.vim-scripts', {'tag_regex': '.*'})
So what exactly is the vim-perl addon supposed to do for me? I can't find any good documenation anywhere.
At least parts of vim-perl are incorporated in the factory-default configuration of Vim; cp. $VIMRUNTIME/ftplugin/perl.vim and $VIMRUNTIME/syntax/perl.vim. By installing (and regularly upgrading) the plugin, you'll get:
a newer version of the scripts, with potential enhancements and bug fixes
some additional functionality (f.e. there's a syntax/mason.vim that's not yet in Vim itself)
If you regularly edit non-trivial Perl scripts, or use latest language features, installing vim-perl is worth contemplating. If you're just a casual programmer, I would wait until a real need arises.

commands.py: name 'play_command' is not defined

I am new to Play and GWT and following the documentation given here. But I see the following errors:
bash-3.2$ play deps test-gwt
!! Error whileloading /opt/play-1.2.1/modules/gwt-1.0/commands.py: name 'play_command' is not defined
~
~ Resolving dependencies using /Users/Harit/Documents/personal/projects/test-gwt/conf/dependencies.yml,
~
~ play->gwt 1.0 (from playLocalModules)
~
~ Installing resolved dependencies,
~
~ modules/gwt-1.0 -> /opt/play-1.2.1/modules/gwt-1.0
~
~ Done!
I see that there is a corresponding bug here, and status is fix_commited, but I don't know what shall I do?
Isn't it just because play-gwt module is not compatible with play 1.2 ?
Apparently this module is quite old and not very active and command syntax has changed in version 1.1.x or something like that.
Before, you wrote commands.py like that:
...
if play_command.startswith('gwt:'):
...
and now, it is like that:
...
MODULE = "secure"
COMMANDS = ["secure:", "secure:ov", "secure:override"]
HELP = {
"secure:": "Show help for the secure module",
"secure:override": "Override the CSS, login or layout"
}
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == 'secure:':
...
In my opinion, the modification is really light so you can either ask the module owner if he would accept to do it or even do it by yourself ;)
There is also a GWT2 module which seems much more active: http://www.playframework.org/modules/gwt2 (apparently no new version since last october but the github project shows very recent commits with play1.2 support)