diff options
author | Hisham <hisham@gobolinux.org> | 2016-10-05 03:18:26 -0300 |
---|---|---|
committer | Hisham <hisham@gobolinux.org> | 2016-10-05 03:18:26 -0300 |
commit | 34963cbc145f9ea1521c24919a9c2c38ee24a7d8 (patch) | |
tree | 34b8d7ab83741db5d1030e490b947a59fbbf64d1 | |
parent | 87f2b81d3bf95e9c3bd99b1c09a8260c90a07d3b (diff) | |
download | luarocks-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.lua | 5 |
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") | |||
22 | local deps = require("luarocks.deps") | 22 | local deps = require("luarocks.deps") |
23 | local util = require("luarocks.util") | 23 | local util = require("luarocks.util") |
24 | 24 | ||
25 | -- Workaround for wrappers produced by older versions of LuaRocks | ||
26 | if luarocks then | ||
27 | luarocks.loader = loader | ||
28 | end | ||
29 | |||
25 | loader.context = {} | 30 | loader.context = {} |
26 | 31 | ||
27 | -- Contains a table when rocks trees are loaded, | 32 | -- Contains a table when rocks trees are loaded, |