Lua 环境搭建 - 基于mac

参考文章:https://www.jianshu.com/p/b70d41a2c2b7

image.png

这里的 lua 版本是:5.4


image.png

最后选择装5.3 brew install [email protected]
并且安装 Lua 模块管理工具:LuaRocks brew install luarocks

image.png
image.png

Intelli + 使用 EmmyLua 插件配置调试环境

写了个简单的lua文件

local mime = require "mime"
-- mime.unb64
local unb64 = require "mime".unb64
local inspect = require "inspect"

local b64map = { ['-'] = '+', ['_'] = '/' };
local function unb64url(s)
    return (unb64(s:gsub("[-_]", b64map) .. "=="));
end

local der_key = {};
local e = "AQAB"

table.insert(der_key, unb64url(e));

print(inspect(der_key))

运行之后报错

lua hello.lua
/usr/local/bin/lua: hello.lua:7: module 'mime' not found:
    no field package.preload['mime']
    no file '/usr/local/share/lua/5.3/mime.lua'
    no file '/usr/local/share/lua/5.3/mime/init.lua'
    no file '/usr/local/lib/lua/5.3/mime.lua'
    no file '/usr/local/lib/lua/5.3/mime/init.lua'
    no file './mime.lua'
    no file './mime/init.lua'
    no file '/usr/local/lib/lua/5.3/mime.so'
    no file '/usr/local/lib/lua/5.3/loadall.so'
    no file './mime.so'
stack traceback:
    [C]: in function 'require'
    hello.lua:7: in main chunk
    [C]: in ?

然后安装 luarocks install luasocket之后再运行, 报错

lua hello.lua
/usr/local/bin/lua: hello.lua:10: module 'inspect' not found:
    no field package.preload['inspect']
    no file '/usr/local/share/lua/5.3/inspect.lua'
    no file '/usr/local/share/lua/5.3/inspect/init.lua'
    no file '/usr/local/lib/lua/5.3/inspect.lua'
    no file '/usr/local/lib/lua/5.3/inspect/init.lua'
    no file './inspect.lua'
    no file './inspect/init.lua'
    no file '/usr/local/lib/lua/5.3/inspect.so'
    no file '/usr/local/lib/lua/5.3/loadall.so'
    no file './inspect.so'
stack traceback:
    [C]: in function 'require'
    hello.lua:10: in main chunk
    [C]: in ?

删掉 inspect,没有报错,但是table里面的东西打印不出来,所以还是想用inspect这个包.
http://luarocks.org/modules/kikito/inspect
luarocks install inspect

image.png

之后再运行代码,可以成功。

安装 crypto


image.png

image.png

和Openssl相关,搭建环境遇到了困难,hold.

你可能感兴趣的:(Lua 环境搭建 - 基于mac)