how to install lua liberec on mac os? - macos

how to install lua liberec on mac os?
I do not know how to do this
main.lua
local luajson = require "lunajson"
local file = io.open("main.json", "r")
local data = file:read("*all")
file:close()
local tbl = luajson.decode(data)
print(tbl["name"])
main.json
{
"name": "Timofey"
}
terminal:
lua: main.lua:1: module 'lunajson' not found:
no field package.preload['lunajson']
no file '/usr/local/share/lua/5.4/lunajson.lua'
no file '/usr/local/share/lua/5.4/lunajson/init.lua'
no file '/usr/local/lib/lua/5.4/lunajson.lua'
no file '/usr/local/lib/lua/5.4/lunajson/init.lua'
no file './lunajson.lua'
no file './lunajson/init.lua'
no file '/usr/local/lib/lua/5.4/lunajson.so'
no file '/usr/local/lib/lua/5.4/loadall.so'
no file './lunajson.so'
stack traceback:
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in ?
I tried restarting the mac, but it still gives an error

Use luarocks.
Install brew ( https://brew.sh/ )
Install luarocks:
brew install luarocks
Install your library:
luarocks install love2d
done

Related

R-INLA installation fails on R 4.1.1

I need to install R-INLA on R 4.1.1 (Windows 10). I cannot update the R version due to compatibility issues of the newer R installations with other tools I that use. I tried the line:
remotes::install_version("INLA", version="22.05.03",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/testing"), dep=TRUE)
As recommended on the INLA website for R 4.1. I get this message in return:
* installing *binary* package 'INLA' ...
cp: unknown option -- )
Try '/usr/bin/cp --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Program Files/R/R-4.1.1/library/INLA'
I have rtools40 installed and added to my path. I have installed the two suggested packages graph and Rgraphviz as recommended.
I have also tried:
devtools::install_github(repo = "https://github.com/hrue/r-inla", ref = "stable", subdir = "rinla", build = FALSE)
But no luck there either.
If I type where cp in the RStudio terminal, I get:
$ where cp
C:\Program Files\Git\usr\bin\cp.exe
C:\rtools40\usr\bin\cp.exe
But I am not sure if this has anything to do with R not finding cp.
Anyone has any advice?
I was having the same problem, and solved it for my Windows 10 machine:
Download the INLA_22.05.03.zip file at https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.1/
In RStudio, under the Tools menu, select Install Packages, and Install from: Package Archive File. Tell RStudio where the .zip file is located on your local machine. From there it installed fine for me.

Brew Formula install with multiple files

I've created a python tool and want to install it via brew. Creating the formula worked fine at first when i simply had one python file named myTool. Then i seperated the code into more files as it became larger and more complex.
How do i set up the install to bundle those files, because right now the imports are failing because the other files are not found.
My current install
def install
bin.install 'myTool'
end
The error shown when running the brew installed tool
from myModule import someFunc, someOtherFunc ModuleNotFoundError: No module named 'myModule'
The current setup only installs the angler file without any of the other python modules. This results in the ModuleNotFoundError error. Here is my suggestion:
def install
# Determines the python version being used
# e.g. If python3.10, xy = 3.10
xy = Language::Python.major_minor_version "python3"
# Where to install the python files
packages = libexec/"lib/python#{xy}/site-packages/angler"
# For each file present, install them in the right location
%w[angler anglerEnums.py anglerGen.py anglerHelperFunctions.py].each do |file|
packages.install file
end
# Create a symlink to the angler python file
bin.install_symlink packages/"angler"
end

octave package install not successful for windows

[Hello, I have a question that i cannot install the package for OCTAVE by the package from here : https://sourceforge.net/projects/octave/?source=typ_redirect
My system is windows. please help me.
pkg install nan-3.1.4.tar.gz
ls: /usr/local/: No such file or directory
][1]
You should install from https://www.gnu.org/software/octave/#install using the installer. It includes many octave-forge packages (including nan) so the only thing you need is to pkg load io

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

Can't run luarocks, tonumber is a nil value

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")

Resources