LuaJIT -- "ngx" module isn't found. Should I install it? - nginx

I'm trying to create a Hello World in Lua using LuaJit for nginx. When I run a script:
luajit my_test.lua
I get this:
luajit: my_test.lua: attempt to index global 'ngx' (a nil value)
Do I have to install a library? I've already tried "luarocks install " with "ngx", "nginx", "ngx_lua" and some others -- they weren't found.
Error: No results matching query were found.
Why isn't it getting found? Should I install a module at all?

ngx is not a part of Lua, so it cannot be found. It also isn't possible to just install it as a library.
The only place where ngx can be used is inside openresty.

Related

GNU/GUIX fails to locate custom modules specified in a manifest

I'm trying run guix package install for following manifest:
(specifications->manifest
'("noguix-hugo" ;; A CUSTOM MODULE implemented in /module/root-1/site-lisp/nonguix-hugo.scm
"go"))
The custom module in the manifest is declared as follows:
(define-module (nonguix-hugo)
;; implementation detail
;; ....
)
And the installation command looks like:
guix package --load-path="/module/root1/site-lisp" \
--load-path="/module/root-2/site-lisp" \
--manifest="/path/to/manifest.scm" \
--profile="/path/to/profile"
The command fails with error message:
guix package: error: noguix-hugo: unknown package
However, building the noguix-hugo using guix build command works just fine
guix build --load-path="/module/root1/site-lisp" \
--load-path="/module/root-2/site-lisp" \
nonguix-package
# The command builds and outputs the module location as expected
# /gnu/store/7js349wb17371225njzll9gma8kmwf-nonguix-hugo-1.0
My question:
Why does Guix succeed to locate the module when building it,
but can't seem to locate it when specified in a manifest file.
I even tried adding a (use-modules (nonguix-hugo)) to the manifest and setting GUIX_PACKAGE_PATH as specified in[1], yet the install still fails.
References
[1] https://guix.gnu.org/manual/en/html_node/Package-Modules.html
Okay, turns out this was a typo in the manifest:
(specifications->manifest
'("noguix-hugo"
"go"))
which should be corrected to:
(specifications->manifest
'("nonguix-hugo" ;; <= this line
"go"))
Sheesh!....

Local Perl DBI module, Can't locate object method "connect"

I've installed DBI module via cpan. CPAN has been configured to use local directory, so I have ~/perl5 and ~/.cpan directories. The module apparently is in ~/.cpan/build/DBI-1.642-0, which in fact does have DBI.pm file there.
However, when I execute the following command as a test, the command suggests there is no "connect" object:
$ perl -e 'use lib qw( .cpan/build/DBI-1.642-0/ ); DBI->connect("dbi:SQLite:dbname=foo.sqlite","","");'
Can't locate object method "connect" via package "DBI" (perhaps you forgot to load "DBI"?) at -e line 1.
Environment: Debian-based distribution, perl 5.26.2 .
Note on possible duplicates:
Can't locate object method via package subclassing DBI Asks about module subclassing, not what I'm doing
Addendum: From the discussion in the comments, it's clear that a lot of users focus on just use DBI statement. As I've mentioned in the comments:
The whole goal is to make use of DBI module installed via cpan. Prior to installing DBD::SQLite neither use lib nor use DBI were giving a working solution. So the suggestion use DBI by itself was not useful.
Please note, I have tried both use DBI and use lib qw() methods prior to asking the question. The use DBI line by itself was not effective without installing DBD::SQLite module as mentioned in my answer.
Converted from a command line script to an actual program, your code looks like this:
use lib qw( .cpan/build/DBI-1.642-0/ );
DBI->connect("dbi:SQLite:dbname=foo.sqlite","","");
And the error message you get is:
Can't locate object method "connect" via package "DBI" (perhaps you forgot to load "DBI"?) at -e line 1.
That error is pretty clear.
(perhaps you forgot to load "DBI"?)
The problem here is that you are missing the line of code which actually loads the DBI module. You need to add this:
use DBI;
Your use lib qw( .cpan/build/DBI-1.642-0/ ) line is very strange. You're asking Perl to load the module from the temporary build directory that was used during the installation. That's not the version that you want to use at all. When cpan has finished its work, you will have a version of DBI installed in your standard Perl library directories that you will be able to access without the need for any use lib code.
I'll also add that if you're using the system-installed version of Perl, there's no need to use cpan to install the most popular modules. You can use your distribution's repository of pre-built packages. For example apt get install libdbi-perl (on Debian and similar) or dnf install perl-DBI (on Red Hat).
In your answer, you have silently added the missing use DBI statement and you claim that installing DBD::SQLite solved your problem. That may have solved a different problem that you had, but it didn't solve the problem in your original question.
Issue with perl -e has been resolved, since apparently SQLite was not installed. I had to open cpan shell and run install DBD::SQLite. Now, the command-line works properly:
$ $ perl -e 'use DBI; my $db = DBI->connect( "dbi:SQLite:dbname=foo.sqlite","","" );my $stmt = qq(CREATE TABLE foo(a int, b text); ); $db->do($stmt)'
$ sqlite3 foo.sqlite
SQLite version 3.23.1 2018-04-10 17:39:29
Enter ".help" for usage hints.
sqlite> .tables
foo
sqlite> .schema foo
CREATE TABLE foo(a int, b text);
sqlite>
As for the module itself, it has been installed in ~/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/DBD/ directory.
Based on Berserk's answer, the following also works for explicitly calling the :
$ perl -e 'use lib qw( /home/user/perl5/x86_64-linux-gnu-thread-multi/DBD ); use DBI; my $db = DBI->connect( "dbi:SQLite:dbname=foo.sqlite","","" );my $stmt = qq(CREATE TABLE foo(a int, b text); ); $db->do($stmt)'
To ensure this uses the library declaration from use lib qw() explicitly, I've also cleared the #inc array in some of my tests.

Installing sqlite driver in Haskell using stack

I have sqlite3 installed in Ubuntu.
$ which sqlite3
/home/user/anaconda3/bin/sqlite3
I'm trying to install the sqlite driver in Haskell and see the following error:
$ stack install sqlite
sqlite-0.5.5: configure
sqlite-0.5.5: build
-- While building custom Setup.hs for package sqlite-0.5.5 using:
/tmp/stack16820/sqlite-0.5.5/.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/setup/setup --builddir=.stack-work/dist/x86_64-linux/Cabal-2.2.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: /home/user/.stack/global-project/.stack-work/logs/sqlite-0.5.5.log
[1 of 2] Compiling Main ( /tmp/stack16820/sqlite-0.5.5/Setup.hs, /tmp/stack16820/sqlite-0.5.5/.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/setup/Main.o )
[2 of 2] Compiling StackSetupShim ( /home/user/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /tmp/stack16820/sqlite-0.5.5/.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/setup/StackSetupShim.o )
Linking /tmp/stack16820/sqlite-0.5.5/.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/setup/setup ...
Configuring sqlite-0.5.5...
Preprocessing library for sqlite-0.5.5..
Building library for sqlite-0.5.5..
[1 of 5] Compiling Database.SQL.Types ( Database/SQL/Types.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Database/SQL/Types.o )
/tmp/stack16820/sqlite-0.5.5/Database/SQL/Types.hs:481:37: error:
Ambiguous occurrence ‘<>’
It could refer to either ‘Prelude.<>’,
imported from ‘Prelude’ at Database/SQL/Types.hs:15:8-25
(and originally defined in ‘GHC.Base’)
or ‘Text.PrettyPrint.HughesPJ.<>’,
imported from ‘Text.PrettyPrint.HughesPJ’ at Database/SQL/Types.hs:56:1-32
|
481 | FunSQLExpr f es -> text f <> parens (commaH ppSQLExpr es)
| ^^
Which of ghc, stack, cabal, anaconda, sqlite should I interrogate to figure out what is failing?
I'm trying to install the sqlite driver in Haskell and see the following error
The sqlite package is deprecated in favour of sqlite-simple So, I would recommend you to not use this. If you are looking for a much higher level of interface to sqlite, I would recommend persistent library.
If you want to still make it work, the easiest way is to just fix the compile errors by forking the code and make it work with the required GHC version.
TL;DR
stack install sqlite --resolver=lts-11.22 should work
First of all i would follow sibi advise and install the maintaned package sqlite-simple.
But if you want to use the deprecated one we could analyze the error:
The error is thrown in the haskell part, the combination of stack and haskell. No mention about c code so the sqlite lib (or anaconda) is not involved here
Ambiguous occurrence ‘<>’ It could refer to either ‘Prelude.<>’, or ‘Text.PrettyPrint.HughesPJ.<>’: The simbol <> is defined in two modules and the client code doesn't disambiguate them (surely cause it was only in one module at the time)
So we have to compile with a version of Prelude or Text.PrettyPrint.HughesPJ without the definition of <>
Text.PrettyPrint.HughesPJ is a module from the pretty package and all versions of the package have the operator exported
The Prelude is defined in the base library and it is fixed for each version of ghc, that in turn is fixed for each major version of the stackage resolver. You can set the global stack resolver in ~/stack/global-project/stack.yaml or in each call to stack with the option --resolver=
The package sqlite accepts base versions in the range >=3 && <5 (in fact that is the cause of the problem, it is too flexible)
If we search for <> in the changelog of base we can see it was exported since version 4.11.0. And that version was shipped with ghc-8.4.1 (you can see the matrix between versions here). So we have to choose a stackage resolver linked to a previous version of ghc: f.e. lts-11.22 with ghc-8.2.2

New version of OpenSSL causes Plone/Zope to not start

Today's (1 Mar 2016) OpenSSL release has caused the following error when running Plone/Zope
.buildout/eggs/ZODB3-3.10.5-py2.7-linux-x86_64.egg/persistent/cPersistence.so: undefined symbol: SSLv2_method
It's hard to see what's going on since it's a binary file. I also tried updating to ZODB3 3.11.0 which yields the following traceback
.buildout/eggs/ZConfig-2.9.0-py2.7.egg/ZConfig/loader.py", line 217, in schemaComponentSource
package=package)
ZConfig.SchemaResourceError: could not load package ZServer:
.buildout/eggs/zope.security-3.7.4-py2.7-linux-x86_64.egg/zope/security/_proxy.so: undefined symbol: SSLv2_method
Package name: 'ZServer'
File name: 'component.xml'
Package path: None
Is there any workaround for this other than reverting OpenSSL?
zope security is a compiled egg, like all the ones ending with -py2.7-linux-x86_64.egg.
As the traceback says, it cannot find anymore a symbol.
Probably you have to recompile it with the new openssl-dev.
I would try (on a development server first):
backup your compiled egg (mkdir eggs-backup && mv `eggs/zope.security-3.7.4-py2.7-linux-x86_64.egg eggs-backup/)
rerun buildout
This will recompile your missing egg.
Hopefully it works and hopefully it is the only one linked to that library.
Anyway, dependending on the way you patched openssl you may have a lot of other issues (I am thinking about Python, urllib*, curl, wget, ...)
OpenSSL 1.0.2g by default doesn't build with SSLv2 (because of the recent DROWN attack). You may need to manually build it without OPENSSL_NO_SSL2 flag.
(but in fact you shouldn't do this if you're doing some server-related stuff, there is a serious security reason because of which it was disabled, see https://drownattack.com)
I was able to resolve this by upgrading python to 2.7.10+, and then upgrading Pillow and lxml.

R-2.15 on AIX5.3 - rl_readline_name error and configure

I am trying to install R package on AIX5.3. I've two queries regarding it:
I followed Fan Long's steps. I installed the GNU utilities: libiconv and gettext also. However, on running
./configure --with-libpth-prefix=/home/jayant/utils --disable-nls --without-libintl-prefiX --with-included-gettext=home/jayant/utils --with-blas="-llapack -lessl -lblas" --prefix=home/jayant/R-2.15.3
I get the following error:
"sys-std.c", line 893.13: 1506-045 (S) Undeclared identifier rl_readline_name.
Native 'sed' on aix does not support '-e' option. I installed sed from GNU utilities. In the configure script, how should I force it to take my sed instead of the native one. I tried
export sed=/home/jayant/sed-4.2/bin/sed.
but it does'nt work?
You need to ensure that the desired sed gets picked up. Say:
PATH=/home/jayant/sed-4.2/bin:${PATH} ./configure ...
Or if you want to add it to the PATH, say:
PATH=/home/jayant/sed-4.2/bin:${PATH}; export PATH
(Add it to your ${HOME}/.bashrc if you so desire.)

Resources