Is the exact lua binary able to be specified in the luarocks compilation options? - luarocks

Right now I have to create a symlink to the lua runtime I'm using:
ln -s $PREFIX/bin/lua-tarantool $PREFIX/bin/tarantool
Then I have to use --lua-suffix="-tarantool" for the ./configure options.
Is there a way to specify the exact name of the binary without resorting to symbolic links? For example: --with-lua-bin=$PREFIX/bin/tarantool
I checked the options and there doesn't seem to be anything like that: https://github.com/keplerproject/luarocks/wiki/Installation-instructions-for-Unix#Customizing_your_settings

You can set the following in your ~/.luarocks/config.lua file:
lua_interpreter = "/some_dir/bin/tarantool"
variables = {
LUA = "/some_dir/bin/tarantool"
}
You might need to tweak the first line of the luarocks script, though (or run it with tarantool /path/to/luarocks).
But you can also ask yourself: do you need to run LuaRocks with tarantool? It should be possible to install plain Lua, LuaRocks and Tarantool, and configure LuaRocks to use plain Lua, but to install modules to the Tarantool path.

Related

Singularity Recipe: How to access executable within container?

I am a beginner with Singularity.
What I want to achieve in the long run: I have a programming project with a long lists of dependencies, and I want to be able to give the program to other people in my company without there being bugs caused by missing dependencies, or wrong versions of dependencies.
The idea was now to use Singularity in order to easily provide a working environment.
In order to test this, I wrote a Hello World application which I now want to run in a container. I have a folder HelloWorld/ which contains the source code for a C++ Qt project. Then I wrote the following recipe file:
project.recipe
Bootstrap: docker
From: ubuntu:18.04
%setup
cp -R <some_folder>/HelloWorld ${SINGULARITY_ROOTFS}/HelloWorld
%post
apt update
apt-get install -y qt5-default
apt install -y g++
apt-get install -y build-essential
cd HelloWorld
qmake
make
echo "after build:"
ls
%runscript
echo "before execution:"
ls HelloWorld/
./HelloWorld/HelloWorld
where the echos and directory listings are for my current debugging process.
I can sucessfully build an image file using sudo singularity build --writable project.img project.recipe. (My debugging output shows me that the executable was build successfully.)
The problem is now that if I try to run it using ./project.img, or singularity run project.img, it won't find the executable.
Using my debugging output, I found out that the lines in %runscript use the folders outside of the container.
Tutorials like https://sylabs.io/guides/3.1/user-guide/build_a_container.html made it seem to me as if my recipe was the way to go, but apparently it isn't?
My questions:
Is there some way for me to access my executable? Am I calling it wrong?
Is the way I do it the way it is supposed to be done? Or would one normally do something like getting the executable outside of the container and then use the container to call that outside file? Or is there a different best practice?
If the executable is to be copied outside of the container after compilation, how do I do that? How do I access outside folders when I'm within %post?
Is this the best work process for what I want to achieve? Later on, my idea is that the big project is copied likewise in the container, dependencies are either installed or copied, then the project is compiled and finally its source being deleted. I also considered using a repository, but I can't have the project being in an open repository, and I don't want to store any passwords.
Firstly, use %files, don't use %setup. %setup is run as root and can directly modify the host server. You can very easily and accidentally break things without realizing it. You can get the same effect this way:
%files
some_folder/HelloWorld /HelloWorld
You are calling it wrong. In your %setup (and hopefully now in your %files) steps, you are copying the data to /HelloWorld. In your %runscript your are calling ./HelloWorld/HelloWorld which is the equivalent of $PWD/HelloWorld/HelloWorld. Since singularity automatically mounts in $PWD (as well as $HOME and some other directories), you are not calling what you're trying to call.
You don't copy the executable outside of the container, you just need to make sure what you're executing is where you think it is.
There is no access to the host filesystem in %post, you should have everything you need copied in via %files first.
That's a reasonable workflow. Having a local private repo for the code is probably a good idea for tracking your changes, but that's your call.

Getting an installed module to recognize changes to config files

I have a package that uses config.json for some settings it uses. I keep the package locally rather than installing it from CPAN. My problem is when I make changes to config.json, the package doesn't recognize the changes since the config file's cached elsewhere, forcing me to run zef install --force-install or delete precomp. How can I ensure that the package always recognizes updates to the config file?
When you install packages using zef, it keeps them in the filesystem, but their names are converted into sha1, something like
/home/jmerelo/.rakudobrew/moar-2018.03/install/share/perl6/site/sources/81436475BD18D66BFD96BBCEE07CCCDC0F368879
zef keeps track of them, however, and you can locate them using zef locate, for instance:
zef locate lib/Zef/CLI.pm6
You can run that from a program, for instance this way:
sub MAIN( Str $file ) {
my $location = qqx/zef locate $file/;
my $sha1 = ($location ~~ /\s+ \=\> \s+ (.+)/);
say "$file → $sha1[0]";
}
which will return pretty much the same, except it will give you the first location of the file you give it at the command line:
lib/Zef/CLI.pm6 → /home/jmerelo/.rakudobrew/moar-2018.03/install/share/perl6/site/sources/81436475BD18D66BFD96BBCEE07CCCDC0F368879
You probably need to install your config.json file in a resources directory (which is the preferred location) and then use something like that.
That said, probably actually installing a module you're testing is not the best strategy. If you're still testing things, it's probably better if you just keep it in the directory you're working with and use perl6 -I<that directory> or else use lib <that directory> is probably a better option. You can just delete that when you release, or keep it, since that only adds another directory to the search path and will not harm the released module.

how to use CAM::PDF to find + replace from command line

Sorry for the noob question. I just downloaded CAM::PDF along with Strawberry for Windows, and trying to do find/replace from the command line. Ran buidinstalldeps to get all needed prereqs.
I'm trying to run changepagestring.pl from command line. But idk how to reference the file location and have it put the output file for me in a specified location:
changepagestring.pl master-exch-manual.pdf "as shown in Figure" figure output.pdf
My goal is to replace "see above figure" with "figure" in this file. But it's in a different directory than the one I'm in, C:\Users\Me\Doc\CAM-PDF-1.60\
So how do I run and do all this from the command line. I've seen the help file with example, but I get this:
CAM::PDF from command shell with PL file not recognized
There are a few possible solutions. The easiest one from the directory you mentioned is:
perl -Ilib bin/changepagestring.pl ...
Alternatively, if you run the usual Perl install commands from that folder, then changepagestring.pl should be included in your usual path
perl Makefile.PL
make install
Alternatively^2, you can use the "cpan" tool to automate the download, build, test and install steps in one go:
cpan install CAM::PDF

How do I install local modules?

For creating and maintaining Perl 5 modules, I use Dist::Zilla. One of my favorite features is being able to install local modules.
However, with Perl 6, I'm not sure how to install local modules. Sure, I can use use lib:
use lib 'relative/path';
use My::Awesome::Module;
But, I'd really like to be able to install My::Awesome::Module, so that all I had to do was use it:
use My::Awesome::Module;
One way to accomplish this, would be setting PERL6LIB, but that still isn't "installing" a module like zef install ./My-Awesome-Module.
Update: Looks like I need to craft an appropriate META6.json file.
To understand how to setup a module to be understood by toolchain utilities, see Preparing the module. Typically this means adding a META6.json file that describes the distribution, including quasi-manifest elements such as which files you really meant to include/provide. Once the META6.json is created the module is ready to be installed:
zef install ./My-Awesome-Module
which (assuming no uninstalled dependencies) is essentially:
my $install-to-repo = CompUnit::RepositoryRegistry.repository-for-name("site");
my $preinstall-dist = Distribution::Path.new("./My-Awesome-Module");
$install-to-repo.install($preinstall-dist);
Starting with rakudo 2019.01 you can, assuming no uninstalled dependencies, install a local distribution without a META6.json -- but this is purely developmental nicety that won't work on complex setups that do not have e.g. namespacing and file structures that can be inferred.
my $read-from-repo = CompUnit::Repository::FileSystem.new(prefix => "./My-Awesome-Module/lib");
my $install-to-repo = CompUnit::RepositoryRegistry.repository-for-name("site");
my $some-module-name = "My::Awesome::Module"; # needed to get at the Distribution object in the next step
my $preinstall-dist = $read-from-repo.candidates($some-module-name).head;
$install-to-repo.install($preinstall-dist);
I'm writing a bin that may help you: http://github.com/FCO/6pm

redis-cli not working on linux

I have installed redis onn linux.
redis sever started correctly however when I try to start redis-cli I get this error
bash: redis-cli: command not found
file redis-cli output is
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, BuildID[sha1]=0x5fe1c6d3da13df88f2ea826ac762f088c29b81d5, not stripped
I don't know what's the reason
but when I run the using this command
/usr/local/bin/redis-cli it works
but when I run redis-cli from the /usr/local/bin/ folder I get the error
bash: redis-cli: command not found
Looks like some path issue
If you built from source and you're in the default redis-stable directory that contains the source, you should be able to start the cli by running:
./src/redis-cli
It seems like redis-cli is present, reading your answer. Check this with which redis-cli.
I've installed redis on several linux machines, normally it goes very smooth. I guess you've run into a special case.
Here's my thoughts:
It might be a dynamic linking issue.
So check the headers with dump -H -X64 redis-cli.
In the headers, you can see which shared objects it is trying to find. There might be a shared object from another package in the way, for example a 32-bit only one. Ugly, and wrong, but it happens.
Use the ldd runtime dependency checker to see what those headers actually result in on your system. Install it when not present. Then simply run ldd redis-cli.
Now you've figured out what's wrong, you can do several things.
1) Remove the conflicting package, if possible.
2) Use the LIBENV environment variable, to set the search path for shared objects, prior to starting the process
3) Use the -blibpath linker option at compile/link time to alter the header, giving it a different search path. The -bnolibpath could also help you.
4) Patch the header afterwards. There are tools for this. This is generally not the preferred way to go.
Hope this helps, TW
Edit:
Although make, make test, and make install were always fine, the server install script install_server.sh was always a bit buggy. This has just been fixed in 2.8.8. I recommend using the latest version.
Edit 2:
The OP's problem turned out to have nothing to do with dynamic linking, it was a simple PATH issue. I leave the answer as is, for historical purposes.
This maybe happening because the executable isn't in path. In order to solve this, you can try copying redis-cli on the /usr/local/bin/ folder with this command:
sudo cp /src/redis-cli /usr/local/bin/