torch / distro

Torch installation in a self-contained folder
BSD 3-Clause "New" or "Revised" License
556 stars 484 forks source link

attempt to call global 'unpack' (a nil value) #163

Closed jinfengr closed 8 years ago

jinfengr commented 8 years ago

I installed the torch with: TORCH_LUA_VERSION=LUA52 ./install.sh

Then I installed nngraph with: luarocks install nngraph

Then I entered into torch terminal: require 'nngraph' require 'nn' unpack()

Then I met the exception: [string "_RESULT={unpack()}"]:1: attempt to call global 'unpack' (a nil value)

Previously I didn't met this exception after installing torch. I am wondering if it's caused by any new commit... Could you please take a look at it?

Thanks.

soumith commented 8 years ago

lua 5.2 does not have unpack. it has table.unpack

jinfengr commented 8 years ago

Does lua 5.1 have unpack?

soumith commented 8 years ago

yes, but it's best to stick to Lua 5.2 and do this: unpack = table.unpack

jinfengr commented 8 years ago

I see, thanks.

kirhgoff commented 6 years ago

I see this problem with lua 5.3 on Mac OS:

→ rep.lua                                                                                                             [e61612a]
/usr/local/bin/lua5.3: /usr/local/share/lua/5.3/repl/init.lua:404: attempt to call a nil value (global 'unpack')
stack traceback:
    /usr/local/share/lua/5.3/repl/init.lua:404: in function 'repl.loadplugin'
    /usr/local/lib/luarocks/rocks-5.3/luarepl/0.8-1/bin/rep.lua:24: in main chunk
    [C]: in ?
djebel-amila commented 5 years ago

yes, but it's best to stick to Lua 5.2 and do this: unpack = table.unpack

Hi soumith. Sorry, I’m new to lua. When you say “do this”, can you explain where I should add this declaration?

xshang93 commented 3 years ago

yes, but it's best to stick to Lua 5.2 and do this: unpack = table.unpack

Hi soumith. Sorry, I’m new to lua. When you say “do this”, can you explain where I should add this declaration?

Hi djebel-amila, did you figure this out? I tried local unpack = unpack or table.unpack in bash but it didn't allow me to use "local". I'm also new to this