Can't run luarocks, tonumber is a nil value - macos

To install luarocks, I downloaded the most recent (2.0.11) tar.gx file from here. I unpacked it, and followed the instructions.
$ ./configure
Lua interpreter found: /usr/local/bin/lua...
Lua version detected: 5.1
Looking for Lua...
lua found in $PATH: /usr/local/bin
Checking Lua includes...
lua.h found in /usr/local/include/lua.h
curl found at /usr/bin
openssl found at /opt/local/bin
Configuring for system...
Darwin
Configuring for architecture...
i386
Writing configuration...
Installation prefix: /usr/local
LuaRocks configuration directory: /usr/local/etc/luarocks
Using Lua from: /usr/local
Done. You can now run 'make' to build.
I then ran sudo make install, and finally tried installing a package but when I try to run it I get this error:
$ sudo luarocks install lpeg
/usr/local/bin/lua: /usr/local/share/lua/5.1//luarocks/cfg.lua:355: attempt to call global 'tonumber' (a nil value)
stack traceback:
/usr/local/share/lua/5.1//luarocks/cfg.lua:355: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1//luarocks/command_line.lua:6: in main chunk
[C]: in function 'require'
/usr/local/bin/luarocks:4: in main chunk
[C]: ?
Running lua manually, tonumber works just fine as does everything else. I don't know why it's failing here.

At the top of cfg.lua you need to add
local tonumber = tonumber
before the module call. You can include tonumber in both lines of the list of similar local definitions. You can make these changes in the installed version in /usr/local/share/lua/5.1//luarocks/cfg.lua or in the source version and make install once again.
This is a bug in luarocks and will be fixed in the next release.
My modified luarocks-2.0.11/src/luarocks/cfg.lua contains:
local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert, tonumber, _VERSION =
rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert, tonumber, _VERSION
module("luarocks.cfg")

Related

Failde to compile : ocamlfind: Package `xmlm' not found

I am trying to compile an OCaml .ml file with make command via command line remote machine but it shows me this error:
+ ocamlfind ocamlc -c -package xmlm -package unix -o pms.cmo pms.ml
ocamlfind: Package `xmlm' not found
Command exited with code 2.
Hint: Recursive traversal of subdirectories was not enabled for this build,
as the working directory does not look like an ocamlbuild project (no
'_tags' or 'myocamlbuild.ml' file). If you have modules in subdirectories,
you should add the option "-r" or create an empty '_tags' file.
To enable recursive traversal for some subdirectories only, you can use the
following '_tags' file:
true: -traverse
<dir1> or <dir2>: traverse
Compilation unsuccessful after building 6 targets (5 cached) in 00:00:00.
Makefile:10 : la recette pour la cible « native » a échouée
make: *** [native] Erreur 10
I tried to export the environment with this command:
eval $(/usr/bin/opam config env --root=/path/Ocaml/opam-ocaml-4.04-strech)
But also I had this error :
# opam-version 1.2.2
# os linux
File /p/opas/src/Ocaml/opam-ocaml-4.04-strech/config does not exist
while the config file does exist in the directory
any help Please ?!!
Thank you
To make a package available via opam (assuming that opam is properly installed and configured) you need to:
install the package
activate your opam
To install a package named foo, execute the following command in your shell
opam install foo
To activate your opam installation (which enables the search paths), issue the following command
eval $(opam config env)
or, with modern opam (that is of version 2.x) just eval $(opam env)
Before doing this, you need to properly initialize your opam installation, i.e., to install the compiler (or use the system compiler) and the base packages. This is done via the opam init command that creates an opam-managed subdirectory in your home, e.g., using an (old by today's standards) OCaml version 4.04.0, you can initialize it like this
opam init --comp=4.04.0
once the initialization is finished, do not forget to activate it via eval $(opam config env) and now you can install the package.
Finally, the version of opam that you're using is outdated and long ago deprecated, thus it is not receiving updates and the repositories that this version can understand are frozen and no longer updated. You really need to update your opam to a 2.x version. Please follow the opam installation instructions to get the latest version.

wrk how to install additional lua modules

I am using mac OSX. I have Lua installed through brew and Luarocks. I have the lua sockets package installed too.
When I call local http = require("socket") from the terminal lua command line interface, the module loads fine.
However when I include local http = require("socket") in my wrk test scripts, I get errors not just for socket but for other modules too. It seems like its not using the Lua on my system.
Is there a way to install dependent modules for wrk?
package.searchpath( "socket", package.path ) returns /usr/local/share/lua/5.2/socket.lua
Here is the error for reference
scripts/get_call_setup.lua: scripts/get_call_setup.lua:1: module 'socket' not found:
no field package.preload['socket']
no file './socket.lua'
no file '/Users/sak/go/src/personal/wrk/obj/share/luajit-2.0.4/socket.lua'
no file '/usr/local/share/lua/5.1/socket.lua'
no file '/usr/local/share/lua/5.1/socket/init.lua'
no file '/Users/sak/go/src/personal/wrk/obj/share/lua/5.1/socket.lua'
no file '/Users/sak/go/src/personal/wrk/obj/share/lua/5.1/socket/init.lua'
no file './socket.so'
no file '/usr/local/lib/lua/5.1/socket.so'
no file '/Users/sak/go/src/personal/wrk/obj/lib/lua/5.1/socket.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
Running 3s test # https://ccx-courier-stage.adobe.io
Be sure Luarocks config correctly and luarocks install destination is in your path.
In terminal, run this below code to add the installed library to your path.
eval "$(luarocks path)"
Then run your code:
lua myscript.lua
Beside that, your package is installed for lua 5.2:
package.searchpath( "socket", package.path ) returns /usr/local/share/lua/5.2/socket.lua
But you run your code with lua 5.1:
no file '/usr/local/share/lua/5.1/socket.lua'
Install socket for lua 5.1 then run your code or run your script with lua 5.2 if all library is install for lua 5.2.
lua5.2 myscript.lua

Why can't pip find pysvn?

I'm working on a project which was written in Python 2, and I'm upgrading it to Python 3. So far, I've just been finding minor syntax errors which are easily fixable. What I've done is created a new project in Python 3, ensured that it worked, and copies chunks of code from the old project into the new one.
Right now, I'm having trouble with pysvn. Initially, I was getting this error:
ImportError: No module named 'pysvn'
At this point, I tried using pip install pysvn, which didn't work. I got the following:
pip install pysvn
Collecting pysvn
Could not find a version that satisfies the requirement pysvn (from versions:)
No matching distribution found for pysvn
So then after a bit of research, I went to the pysvn download site and tried:
>pip install --index-url http://pysvn.tigris.org/project_downloads.html pysvn, which gave me this error:
Collecting pysvn
The repository located at pysvn.tigris.org is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pysvn.tigris.org'.
and also the same error as when I tried >pip install pysvn.
My next step was to manually download the .exe file for the version I needed, and I was able to successfully install pysvn. I have checked the site-packages directory, and pysvn is indeed there, but pip still can't tell me anything about it:
>pip show pysvn
>
When I do this for another installed module, selenium for example, I get the following:
pip show selenium
Metadata-Version: 1.1
Name: selenium
Version: 2.49.2
Summary: Python bindings for Selenium
Home-page: https://github.com/SeleniumHQ/selenium/
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: ...\lib\site-packages
Requires:
I was able to verify that the installation of pysvn was successful because my project now runs instead of giving me that ImportError.
So why can pip not give me information for another module in the same directory that was successfully installed?
As it turns out, because I didn't use pip install for pysvn, pip didn't know that pysvn existed. Because it wasn't available from PyPI (the Python Package Index), there was no way that pip could see it (because that's where pip goes first to find packages that it's attempting to install).
From the pip user guide:
pip supports installing from PyPI, version control, local projects, and directly from distribution files.
Since I had eventually downloaded pysvn from its own download site (which was not any of the above 4 options) and ran the .exe manually, pip simply doesn't know about it even though it's in the same directory as other packages installed by pip.
I suppose I could've also retrieved the distribution files and used pip with those, but my workaround did the trick.
My way on linux:
Get sources from here
tar -zxf pysvn-1.9.10.tar.gz
apt-get install subversion libsvn1 libsvn-dev make g++
cd pysvn-1.9.10/Source
python setup.py configure --pycxx-dir=/pysvn-1.9.10/Import/pycxx-7.1.3/
make
Here i've got errors below:
Compile: /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx into cxxsupport.o
/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx:42:10: fatal error: Src/Python3/cxxsupport.cxx: No such file or directory
#include "Src/Python3/cxxsupport.cxx"
Compile: /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c into cxxextensions.o
/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c:42:10: fatal error: Src/Python3/cxxextensions.c: No such file or directory
#include "Src/Python3/cxxextensions.c"
It is needed to edit that files:
vi /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx
change #include "Src/Python3/cxxsupport.cxx" to
#include "Python3/cxxsupport.cxx"
and same on second file. Than make again:
make clean && make
...
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c into cxxextensions.o
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/IndirectPythonInterface.cxx into IndirectPythonInterface.o
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxx_exceptions.cxx into cxx_exceptions.o
Link pysvn/_pysvn_3_7.so
Then just copy it to the site-packages (change to yours directory):
mkdir /usr/local/lib/python3.7/site-packages/pysvn
cp /code/pysvn-1.9.10/Sources/pysvn/__init__.py /usr/local/lib/python3.7/site-packages/
cp /code/pysvn-1.9.10/Sources/pysvn/_pysvn*.so /usr/local/lib/python3.7/site-packages/

How to install Net::SSH2 from CPAN on Cygwin

I needed to install Net:SSH2 in a Cygwin environment under Windows 7 (64 bit). As usually I tried to install it with cpanm.
I already had the necessary Cygwin packages (see below) installed but the Perl build failed because it couldn't find the libssh2 library.
There is a special text file BUILDING.WIN32 in the Net::SSH2 package but this is only useful when building the module by hand and it refers mainly to MinGW. So this no help.
This is the log of the build:
Entering Net-SSH2-0.53
Checking configure dependencies from META.yml
Checking if you have ExtUtils::MakeMaker 6.59 ... Yes (7.02)
Running Makefile.PL
Configuring Net-SSH2-0.53 ... Subroutine checklibs redefined at inc/Module/Install/CheckLib.pm line 11.
Subroutine assertlibs redefined at inc/Module/Install/CheckLib.pm line 25.
Subroutine _author_side redefined at inc/Module/Install/CheckLib.pm line 39.
The libssh2 library is required by this module. If you don't have it, you can
download it from http://www.libssh2.org; you may also need OpenSSL, which can
be obtained from http://www.openssl.org , or libgcrypt, which can be obtained
from http://www.gnupg.org .
Debian: sudo aptitude install libssh2-1-dev
OpenSUSE: sudo zypper in libssh2-1 libssh2-devel
You can pass your libssh2 lib and include dirs (and extra link args) on the
command line. E.g.:
perl Makefile.PL lib=$HOME/libssh2/lib inc=$HOME/libssh2/include \
ldargs="-lz"
These can also be set through the LIBSSH2_LIB/LIBSSH2_INCLUDE/LIBSSH2_LDARGS
environment variables.
To build with libgcrypt instead of OpenSSL, pass 'gcrypt' as a parameter to
Makefile.PL, e.g.:
perl Makefile.PL gcrypt
If you want to build on Windows, see the file BUILDING.WIN32 in the
distribution.
Can't link/include C library 'ssh2', aborting.
First install the libssh2-devel package from Cygwin, e.g. with apt-cyg the command line frontend for installing packages from within a cygwin shell.
apt-cyg install libssh2-devel
Then set some environment variables to the right path for getting Net::SSH2 to work with the Cygwin packages:
LIBSSH2_LIB=/usr/lib/ LIBSSH2_INCLUDE=/usr/include/ cpanm -v Net::SSH2
That worked for me. Much easier than what the readme file linked above looked like.

OS X 10.8.2 python 3 import sqlite error

Both brew installed python3 and manually compiled python3 with -–enable-loadable-sqlite-extensions fails when import sqlite from python3 shell. Please help!
The module is named sqlite3, not sqlite:
import sqlite3
http://docs.python.org/3/library/sqlite3.html
Update: Now that we've cleared up the module name, the problem being reported:
ImportError: No module named '_sqlite3'
means that your Python instance cannot find the C extension module, _sqlite3.so, that is part of the sqlite3 module in the standard library. Since the file path of the dbapi2.py in the traceback looks reasonable, the issue is probably not a path issue (sys.path). Most likely the _sqlite3 extension module failed to build or link. Check the output from your Python build for errors. OS X 10.8 includes a version of sqlite3 but for security reasons it does not include the optional loadable extensions feature. Your Python build likely included this message:
Failed to build these modules:
_sqlite3
and, earlier, this:
*** WARNING: renaming "_sqlite3" since importing it failed: dlopen(build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so, 2): Symbol not found: _sqlite3_enable_load_extension
Referenced from: build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so
Expected in: flat namespace
in build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so
The solution is to build and install a separate copy of sqlite3 that is built with the loadable extensions feature. If you are using Homebrew, its sqlite recipe with the with-functions option should do that. Then rebuild Python.
Homebrew provides python3 with sqlite3 support and loadable modules.
brew install python3 will do the right thing (and brew sqlite, too).
There was a bug, that probably struck you, but it has been fixed

Resources