soso_ynak has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I'm not very fluent in English, but I ran into a problem that I couldn't solve on the Japanese question forum, so I decided to ask here.

Assumptions:

I have a contract with one of the major rental servers in Japan and run Perl CGI scripts on that server.
Unfortunately, in my contract, I don't have write permission for the Perl installation directory on that server, and can't connect SSH so I can't upgrade the module version.

Details of the problem:

Here is the problem I encountered this time.
I wrote ' use Encode; use Net::IMAP::Client; (or use Mail::IMAPClient;) ' because I wanted to use these two or three modules on the same script.
But the server returns the error below.

----------------------------------------- Encode version 2.87 required--this is only version 2.68 at ../lib_ext/ +Email/MIME/ContentType.pm line 7. BEGIN failed--compilation aborted at ../lib_ext/Email/MIME/ContentType +.pm line 7. -----------------------------------------

It says the ContentType.pm line 7 in Net::IMAP::Client requires the Encode version 2.87, even though the server has Encode version 2.68 module.
Unfortunately, I don't have permission to write to the Perl installation directory as already mentioned above.
So I installed the Encode-2.87.tar.gz downloaded from his CPAN in the user directory (../lib_ext) instead of XAMPP/Perl's standard lib directory on my Windows machine.
And I copied following generated files and folders to the server's user directory (../lib_ext).
File: Encode.pm/Encoding.pm/perllocal.pod
Directory: auto/encode
And when I added 'BEGIN { unshift(@INC, "../lib_ext") };' to the top of my script and ran it, the server returned the following error.

----------------------------------------- Encode object version 2.68 does not match bootstrap parameter 2.87 at +/usr/local/perl/5.10/lib/5.10.1/x86_64-linux-thread-multi/DynaLoader. +pm line 223. Compilation failed in require at my_script.pl line 8. BEGIN failed--compilation aborted at my_script.pl line 8. -----------------------------------------

My question:

Can someone please tell me how to use a module with a different version than the server's standard module?
Thank you for your patience in reading to the end.

Replies are listed 'Best First'.
Re: Using a different module version than the one installed
by syphilis (Archbishop) on Sep 01, 2022 at 06:00 UTC
    Encode object version 2.68 does not match bootstrap parameter 2.87

    Version 2.87 of Encode.pm is being found ok, but the Encode.dll for version 2.87 is not being found.
    If version 2.87 of Encode.pm is in the "..\lib_ext" folder, then its Encode.dll should be found in the ..\lib_ext\auto\Encode folder.

    That dll is not part of the Encode source distribution. It gets created when you build the Encode module by running "perl Makefile.PL", then "make test". (It would then normally be installed into the correct location when you run "make install".)
    If you haven't done the build, then the required Encode.dll won't even exist and Encode will be unusable.
    You need to build that dll, and get it placed in the correct location.

    UPDATE: I assumed that the server running the Perl CGI scripts was on a Windows system. On re-reading the original post I now realize that might not be so. Is the server running on MicroSoft Windows ?

    Cheers,
    Rob

      Thanks for all your comments, and sorry for my slow response.
      I will explain the situation to all your comments.
      Below are the situations and concerns that I reconfirmed.
      First, the auto directory I installed doesn't contain Encode.dll, it has Encode.xs.dll instead.
      Is this correct?
      And I have the following concerns.
      When I installed Encode 2.87 with Perl on Windows10/XAMPP(standard Encode version: 3.08) by running "perl makefile.pl prefix='c:\xampp\perl\lib_ext'","gmake","gmake test","gmake install" , the following folders/files were generated.

      c:\xampp\perl----\lib |--\lib_ext----\bin |--\lib----\auto----\Encode---- Encode.xs.dl +l | |-- .paclist | |--\Byte | |-- (\JP/\EBCDIC +/...another folder) | |--\Encode---- Alias.pm | |-- Byte.pm | |-- Config.pm | |-- EBCDIC.pm | |-- encode.h | |-- Encoder.pm | |-- Encoding.pm | |-- JP.pm | |-- (Another file) | | |-- Encode.pm |-- encoding.pm |-- perllocal.pod

      Then I copied these to the following directory on the web server(Linux).

      /home/users/0/usrxxxx/web/usr/bin----/lib_ext---- Encode.pm | |-- encoding.pm | |-- perllocal.pod | | | |-- /auto----/Encode---- + Encode.xs.dll | | |-- + .paclist | | |-- +/Byte | | |-- + (\JP/\EBCDIC/...another folder) | | | |-- /Encode---- Alias.pm | |-- Byte.pm | |-- Config.p +m | |-- EBCDIC.p +m | |-- encode.h | |-- Encoder. +pm | |-- Encoding +.pm | |-- JP.pm | |-- (Another + file) | |--( /target directory ---- target s +cript )

      As a result, I got the following error(same as 2nd error) when running the script:

      -- Error3: Encode object version 2.68 does not match bootstrap parameter 2.87 at +/usr/local/perl/5.10/lib/5.10.1/x86_64-linux-thread-multi/DynaLoader. +pm line 223.

      The error when using the server's standard module Encode.pm 2.68 was the 1st error (Encode version 2.87 required--this is only version 2.68 at ../lib_ext/Email/MIME/ContentType.pm line 7.) I posted, but the error after copying above file/folder was the second Error (Encode object version 2.68 does not match bootstrap parameter 2.87 at /usr/local/perl/5.10/lib/5.10.1/x86_64-linux-thread-multi/DynaLoader.pm line 223.), so I think "use lib qw{../lib_ext};" or "BEGIN { unshift(@INC, "../lib_ext") };" in my script works.
      (At least Encode.pm 2.87 is searched, but I think the related files are incorrect. maybe)
      Just in case, I also tried "use FindBin qw($RealBin); use lib "$RealBin/../lib_ext";", but the result was the same.

      I have the following question now.
      I'm very curious what the error on the server, "DynaLoader.pm line 223" means.
      In addition, the following error occurred when the same script was executed on Localhost on Windows/xampp.

      Can't load '(C:/Users/localhost directry)/usr/bin/target folder/../lib +_ext/auto/Encode/Encode.xs.dll' for module Encode: load_file: The spe +cified module could not be found at C:/usr/lib/XSLoader.pm line 93. at C:/Users/localhost directry)/usr/bin/mail_rcv_spam/../lib_ext/Enco +de.pm line 10.

      The "C:/usr/lib/XSLoader.pm line 93" part in this error indicates the path of the standard module of the server.
      Is it impossible to use a different Encode module with the same name just by copying the files/folders installed on Winodws/xampp?
      Or is my installation/copy work wrong?

Re: Using a different module version than the one installed
by hippo (Archbishop) on Sep 01, 2022 at 10:25 UTC

    Hello soso_ynak. There are several problems here - I will try to explain.

    Firstly, your paths suggest that you are using version 5.10.1 of Perl. This is very old indeed. It is so old that I'm unaware of any supported operating system which ships with it any more. It may be that your hosting company's O/S is out of date in which case you might ask them to move you to a supported server instead (and that might solve a lot of the problems).

    Secondly, Encode is in core which means it ships with Perl itself. Modifying the versions of core modules without moving to the associated version of Perl may cause problems. You might be lucky but then again you might not.

    Finally, Encode is an XS module which means that even if you get the source onto the server and some means to install it you will still either need access to a C compiler on the server or else you will have to cross-compile it, neither of which will likely be easy.

    In your position I would contact the hosting company and ask to be moved to a modern O/S with a recent version of Perl and take it from there.


    🦛

Re: Using a different module version than the one installed
by ikegami (Patriarch) on Sep 01, 2022 at 16:27 UTC

    There's actually two directories that need to be added to @INC, the one that allows it to locate the .pm, and the one that allows it to locate the .so. The following will add both:

    use FindBin qw( $RealBin ); use lib "$RealBin/../lib_ext";

    (This also removes assumption that the PWD is the directory containing the script.)

      There's actually two directories that need to be added to @INC, the one that allows it to locate the .pm, and the one that allows it to locate the .so.

      Not in my experience.
      If you add a single location to @INC that will locate the .pm file, then that's all you need to do - assuming that you've located the .so in the location (relative to the .pm file) where perl will look for it.
      Of course, if you've placed the .so file in some other location (where perl won't look for it) then you will need to add a second path to @INC that will enable the .so file to be found by perl.

      I guess you are referring to the latter scenario.

      Cheers,
      Rob

        Yeah, nevermind. Both the pm and so are installed in the arch dir. I was confused. The error actually suggests an incorrectly installed module.

        That said, it is usually needed to add both the lib and arch dirs (because there are some modules in one and some modules in the other), and use lib adds both.

Re: Using a different module version than the one installed
by ikegami (Patriarch) on Sep 02, 2022 at 17:19 UTC

    Please provide the output of find ../lib_ext.