aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-10-05 03:18:26 -0300
committerHisham <hisham@gobolinux.org>2016-10-05 03:18:26 -0300
commit34963cbc145f9ea1521c24919a9c2c38ee24a7d8 (patch)
tree34b8d7ab83741db5d1030e490b947a59fbbf64d1
parent87f2b81d3bf95e9c3bd99b1c09a8260c90a07d3b (diff)
downloadluarocks-34963cbc145f9ea1521c24919a9c2c38ee24a7d8.tar.gz
luarocks-34963cbc145f9ea1521c24919a9c2c38ee24a7d8.tar.bz2
luarocks-34963cbc145f9ea1521c24919a9c2c38ee24a7d8.zip
Simulate module() for older wrappers.
Older versions of LuaRocks (e.g. 2.1.0) install script wrappers that assume that `luarocks.loader` is available in the global namespace (this is from the module() era). This workaround detects this (because site_config.lua files written by these old versions use module(), and therefore create a `luarocks` global. To reproduce this issue, make a clean install of LuaRocks 2.1.0, then run `luarocks install luarocks`. Installation succeds, but running `luarocks` produces `attempt to index field 'loader' (a nil value)`. Bug reported by @tomasguisasola.
-rw-r--r--src/luarocks/loader.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/luarocks/loader.lua b/src/luarocks/loader.lua
index 26280e94..06a0cfda 100644
--- a/src/luarocks/loader.lua
+++ b/src/luarocks/loader.lua
@@ -22,6 +22,11 @@ local manif_core = require("luarocks.manif_core")
22local deps = require("luarocks.deps") 22local deps = require("luarocks.deps")
23local util = require("luarocks.util") 23local util = require("luarocks.util")
24 24
25-- Workaround for wrappers produced by older versions of LuaRocks
26if luarocks then
27 luarocks.loader = loader
28end
29
25loader.context = {} 30loader.context = {}
26 31
27-- Contains a table when rocks trees are loaded, 32-- Contains a table when rocks trees are loaded,