English 中文(简体)
当地布道包(布卢布)不可行
原标题:local luarocks package install (luarepl) does not work
  • 时间:2017-11-13 15:09:00
  •  标签:
  • lua
  • luarocks

I m new to luarocks and I just tried to install luarepl. The installation apparently went fine:

$ luarocks install luarepl
Installing https://luarocks.org/luarepl-0.8-1.rockspec...
Using https://luarocks.org/luarepl-0.8-1.rockspec... switching to  build  mode
Updating manifest for /Users/me/.luarocks/lib/luarocks/rocks-5.1
luarepl 0.8-1 is now built and installed in /Users/me/.luarocks (license: MIT/X11)

但是,如果我试图启动可执行的任务,安装似乎被打破:

$ ~/.luarocks/bin/rep.lua
/usr/local/bin/lua5.1: ...cks/lib/luarocks/rocks-5.1/luarepl/0.8-1/bin/rep.lua:23: module  repl.console  not found:
    no field package.preload[ repl.console ]
    no file  ./repl/console.lua 
    no file  /usr/local/share/lua/5.1/repl/console.lua 
    no file  /usr/local/share/lua/5.1/repl/console/init.lua 
    no file  /usr/local/lib/lua/5.1/repl/console.lua 
    no file  /usr/local/lib/lua/5.1/repl/console/init.lua 
    no file  ./repl/console.so 
    no file  /usr/local/lib/lua/5.1/repl/console.so 
    no file  /usr/local/lib/lua/5.1/loadall.so 
    no file  ./repl.so 
    no file  /usr/local/lib/lua/5.1/repl.so 
    no file  /usr/local/lib/lua/5.1/loadall.so 
stack traceback:
    [C]: in function  require 
    ...cks/lib/luarocks/rocks-5.1/luarepl/0.8-1/bin/rep.lua:23: in main chunk
    [C]: ?

我看看着~子:

$ cd ~ ; find .luarocks
.luarocks
.luarocks/bin
.luarocks/bin/rep.lua
.luarocks/config.lua
.luarocks/lib
.luarocks/lib/luarocks
.luarocks/lib/luarocks/rocks-5.1
.luarocks/lib/luarocks/rocks-5.1/luarepl
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/bin
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/bin/rep.lua
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/doc
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/doc/COPYING
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/doc/IDEAS.md
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/doc/plugins.md
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/doc/README.md
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/doc/Roadmap.md
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/luarepl-0.8-1.rockspec
.luarocks/lib/luarocks/rocks-5.1/luarepl/0.8-1/rock_manifest
.luarocks/lib/luarocks/rocks-5.1/manifest
.luarocks/share
.luarocks/share/lua
.luarocks/share/lua/5.1
.luarocks/share/lua/5.1/repl
.luarocks/share/lua/5.1/repl/console.lua
.luarocks/share/lua/5.1/repl/init.lua
.luarocks/share/lua/5.1/repl/plugins
.luarocks/share/lua/5.1/repl/plugins/autoreturn.lua
.luarocks/share/lua/5.1/repl/plugins/completion.lua
.luarocks/share/lua/5.1/repl/plugins/example.lua
.luarocks/share/lua/5.1/repl/plugins/filename_completion.lua
.luarocks/share/lua/5.1/repl/plugins/history.lua
.luarocks/share/lua/5.1/repl/plugins/keep_last_eval.lua
.luarocks/share/lua/5.1/repl/plugins/linenoise.lua
.luarocks/share/lua/5.1/repl/plugins/pretty_print.lua
.luarocks/share/lua/5.1/repl/plugins/rcfile.lua
.luarocks/share/lua/5.1/repl/plugins/rlwrap.lua
.luarocks/share/lua/5.1/repl/plugins/semicolon_suppress_output.lua
.luarocks/share/lua/5.1/repl/sync.lua
.luarocks/share/lua/5.1/repl/utils.lua

and I can find that stuff. I tried adding a line to config.lua to load packages from local installation to no avail:

$ cat ~/.luarocks/config.lua
local_by_default=true

(移除无效)

我是否错过了某些明显的步骤?

CONFIGURATION
    Lua version: 5.1
    Configuration files:
        System: /usr/local/etc/luarocks51/config-5.1.lua (ok)
        User  : /Users/me/.luarocks/config.lua (ok)

    Rocks trees in use:
        /Users/me/.luarocks ("user")
        /usr/local ("system")

it seems that the user rock tree is not in the package path:

$ lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> print(package.path)
./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua

为什么?

最佳回答

https://github.com/luarocks/luarocks/wiki/Using-LuaRocks”rel=“noreferer”https://github.com/luarocks/luarocks/wiki/Using-LuaRocks:

大多数罗拉茨设施将有两个岩石树:

  • "system" rock tree (used by default)
  • "user" rock tree

为了能够使用该单元,我们需要确保卢阿能够发现该单元。 lua file when weîrequire("dkjson”)。 你们能够利用卢阿环境检查你们的卢阿道路。

print(package.path)
print(package.cpath)

这些变量可在Lua以外使用<代码”进行预先配置。 LUA_PATH和LUA_CPATH环境变量。

如果你在其拖欠的名录中安装了Lua和LuaRocks(在Lino和MacOSX上安装了/usr/ local),那么“系统”树就是/usr/ local,它将不停地工作。 但是,卢阿没有发现“用户”树(用于安装没有行政特权的岩石)。 为此,我们需要把这些环境变量混为一谈。

旋涡为做到这一点提供了半自动的方法。 如果是:

luarocks path --bin

它将印刷适合你建立环境平台的指挥。 在典型的“独特终端”环境中,你可以这样作:

eval $(luarocks path --bin)

并暂时对你的伤口适用这些变化。 为了永久确定这些变量,你必须把环境变量与贵重组合混为一谈(例如,如果你身为巴什的话,将上述线添加到你的原体档案中)。

问题回答

在bashrc或 zshrc中,eval$ (luarocks path -bin)的问题是,如果你在项目一级使用“rocks”,你可能会遇到一个问题:

如果在另一个名录中启动终端系统(这是相当常见的),因为通常在<代码>~上启动。 <代码>。 档案将评估道路,但你在项目树中的“石块”不会包括在内。

我只是通过创建run.sh档案来处理这一局势。

#!/bin/bash

eval "$(luarocks path --bin)"
lua src/main.lua

页: 1





相关问题
Wrapping a Lua object for use in C++ with SWIG

Currently I know how to have C++ objects instantiated and passed around in Lua using SWIG bindings, what I need is the reverse. I am using Lua & C++ & SWIG. I have interfaces in C++ and ...

Can t lua_resume after async_wait?

I have some lua script that have some long running task like getting a web page so I make it yield then the C code handle get page job async, so the thread free to do other job and after a specify ...

How to remove a lua table entry by its key?

I have a lua table that I use as a hashmap, ie with string keys : local map = { foo = 1, bar = 2 } I would like to "pop" an element of this table identified by its key. There is a table.remove() ...

Lua plain string.gsub

I ve hit s small block with string parsing. I have a string like: footage/down/temp/cars_[100]_upper/cars_[100]_upper.exr and I m having difficulty using gsub to delete a portion of the string. ...

why do i get "attempt to call global require (a nil value)"?

I have 3 lua files, Init.lua, FreeCamera.lua and Camera.lua , init.lua calls require "Core.Camera.FreeCamera" Free Camera: module(...) require "Core.Camera.Camera" local M = {} FreeCamera = M M ...

热门标签