Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LuaRocks 2.0.7 bug: /usr/local/share/lua/5.1//luarocks/fs/lua.lua:582: bad argument #2 to 'chmod' (bad mode) #53

Closed
vladfedin opened this issue Dec 28, 2011 · 15 comments

Comments

@vladfedin
Copy link

Got some strange bug while making rockspec:

user@ubuntu:~/projects/pk-hb/server/lib/pk-tools$ sudo luarocks make rockspec/pk-tools.pk-ensure-nginx-site-enabled-scm-1.rockspec 

Error: LuaRocks 2.0.7 bug (please report at luarocks-developers@lists.sourceforge.net).
/usr/local/share/lua/5.1//luarocks/fs/lua.lua:582: bad argument #2 to 'chmod' (bad mode)
stack traceback:
    [C]: in function 'chmod'
    /usr/local/share/lua/5.1//luarocks/fs/lua.lua:582: in function 'chmod'
    /usr/local/share/lua/5.1//luarocks/fs/lua.lua:258: in function </usr/local/share/lua/5.1//luarocks/fs/lua.lua:238>
    (tail call): ?
    /usr/local/share/lua/5.1//luarocks/rep.lua:176: in function 'move_fn'
    /usr/local/share/lua/5.1//luarocks/rep.lua:234: in function 'action'
    /usr/local/share/lua/5.1//luarocks/rep.lua:47: in function </usr/local/share/lua/5.1//luarocks/rep.lua:40>
    (tail call): ?
    (tail call): ?
    /usr/local/share/lua/5.1//luarocks/rep.lua:247: in function 'deploy_files'
    /usr/local/share/lua/5.1//luarocks/build.lua:229: in function </usr/local/share/lua/5.1//luarocks/build.lua:108>
    (tail call): ?
    (tail call): ?
    [C]: in function 'xpcall'
    /usr/local/share/lua/5.1//luarocks/command_line.lua:151: in function 'run_command'
    /usr/local/bin/luarocks:23: in main chunk
    [C]: ?
@hishamhm
Copy link
Member

After some digging, I think I found it. Looks like you're using LuaPosix and, to my surprise, it doesn't support octal mode setting. I've just pushed a change to use the textual notation. This should be more "portable".

Please confirm if this fixes your issue.

@vladfedin
Copy link
Author

Thanks for fast response, though now I got something new:

user@ubuntu:~/projects/pk-hb/server/lib/pk-tools$ sudo luarocks make rockspec/pk-tools.pk-ensure-nginx-site-enabled-scm-1.rockspec 

Error: LuaRocks 2.0.7 bug (please report at luarocks-developers@lists.sourceforge.net).
/usr/local/share/lua/5.1//luarocks/dir.lua:12: assertion failed!
stack traceback:
    [C]: in function 'assert'
    /usr/local/share/lua/5.1//luarocks/dir.lua:12: in function 'base_name'
    /usr/local/share/lua/5.1//luarocks/build.lua:59: in function 'install_files'
    /usr/local/share/lua/5.1//luarocks/build.lua:206: in function 
    (tail call): ?
    (tail call): ?
    [C]: in function 'xpcall'
    /usr/local/share/lua/5.1//luarocks/command_line.lua:151: in function 'run_command'
    /usr/local/bin/luarocks:23: in main chunk
    [C]: ?

@hishamhm
Copy link
Member

hishamhm commented Jan 5, 2012

I committed a fix for that. Please let me know how things go. If things run smoothly I'll pack a release in the coming days.

@vladfedin
Copy link
Author

Thanks alot, new code worked for me!

@amrhassan
Copy link

I'm getting this error in luarocks 2.2.0

/usr/bin/lua: /usr/share/lua/5.2/luarocks/fs/lua.lua:740: bad argument #2 to 'chmod' (bad mode)
stack traceback:
    [C]: in function 'error'
    /home/amr/.luarocks/share/lua/5.2/posix/_argcheck.lua:20: in function 'argerror'
    /home/amr/.luarocks/share/lua/5.2/posix/compat.lua:150: in function </home/amr/.luarocks/share/lua/5.2/posix/compat.lua:146>
    (...tail calls...)
    /usr/share/lua/5.2/luarocks/fs/lua.lua:740: in function 'chmod'
    /usr/share/lua/5.2/luarocks/tools/tar.lua:136: in function 'untar'
    csagent.lua:78: in function 'download_jumpscripts'
    csagent.lua:113: in main chunk
    [C]: in ?

@ignacio
Copy link
Contributor

ignacio commented Jan 19, 2015

Can you run the luarocks command again, with --verbose flag, and paste the results here?

@amrhassan
Copy link

This actually happens while using luarocks as a Lua module in my application, not while running the luarocks executable. It's during calling luarocks.tools.tar.untar() which I passed two strings.

@ignacio
Copy link
Contributor

ignacio commented Jan 19, 2015

Ok, can you add

util.printerr("file: ".. tostring(file) .. " mode: " .. tostring(mode))

before line 740?

The first argument seems to require a valid path. Let's check that too.

Also, which version of LuaPosix are you using?

@amrhassan
Copy link

I'm using luarocks 2.2.0, and LuaPosix 33.2.1. The first argument is indeed a valid file path.

file: /tmp/csagent-1421841817/jumpscripts/luajumpscripts/jumpscale/test/lua_echo.lua mode: ---------rw-r--r--
/usr/bin/lua: /usr/share/lua/5.2/luarocks/fs/lua.lua:741: bad argument #2 to 'chmod' (bad mode)
stack traceback:
    [C]: in function 'error'
    /home/amr/.luarocks/share/lua/5.2/posix/_argcheck.lua:20: in function 'argerror'
    /home/amr/.luarocks/share/lua/5.2/posix/compat.lua:150: in function </home/amr/.luarocks/share/lua/5.2/posix/compat.lua:146>
    (...tail calls...)
    /usr/share/lua/5.2/luarocks/fs/lua.lua:741: in function 'chmod'
    /usr/share/lua/5.2/luarocks/tools/tar.lua:136: in function 'untar'
    csagent.lua:70: in function 'download_jumpscripts'
    csagent.lua:143: in function 'main'
    csagent.lua:167: in main chunk
    [C]: in ?

@ignacio
Copy link
Contributor

ignacio commented Jan 21, 2015

Try that in a script:

local posix = require "posix"

local file = "/tmp/csagent-1421841817/jumpscripts/luajumpscripts/jumpscale/test/lua_echo.lua"
local mode = "---------rw-r--r--"
print( posix.chmod(file, mode) )

According to http://luaposix.github.io/luaposix/modules/posix.html#chmod it seems that your mode string is not valid. All those dashes at the start are valid?

Also, which version of LuaPosix (not LuaRocks) are you using?

@amrhassan
Copy link

LuaPosix 33.2.1 (latest atm), but I'm not calling posix.chmod(). It's LuaRocks's tar.untar() function that calls it on files that got extracted from the tar archive. Is it a problem with how the permissions are stored in that specific tar archive?

@ignacio
Copy link
Contributor

ignacio commented Jan 21, 2015

Do you have a tar file that works so we can compare them and see if that's
indeed the problem?

@hishamhm
Copy link
Member

We have code in lua.lua that converts octal notation to rwx notation because of an old LuaPosix bug. Looks like tar is giving out lots of zeros in its mode string ("000644").

hishamhm added a commit that referenced this issue Jan 21, 2015
an octal mode string that's too long. Fixes #53.
@hishamhm
Copy link
Member

I pushed a fix for that, @amrhassan, please take a look.

@amrhassan
Copy link

That seems to fix it. Thank you @hishamhm :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants