-
Notifications
You must be signed in to change notification settings - Fork 427
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
Improve error on archive unpack error #574
Conversation
Would be nice if luarocks could also say something like |
The tests fail because find_base_dir can be called on urls using non-basic protocols, and unpack fails on them. |
In particular, when installing a rock, fail with a message related to extraction error or unrecognized archive extension instead of 'Directory <name> not found inside archive <name>.<ext>'.
daeaf57
to
778ab80
Compare
@@ -192,8 +192,7 @@ function tools.unpack_archive(archive) | |||
-- Ignore .lua and .c files; they don't need to be extracted. | |||
return true | |||
else | |||
local ext = archive:match(".*(%..*)") | |||
return false, "Unrecognized filename extension "..(ext or "") | |||
return false, "Couldn't extract archive "..archive..": unrecognized extension" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should keep saying "filename extension"; "extension" is vague.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
But the guide already points to git:// first, no? The right thing to do, in |
Also, which tests fail? |
Right, I looked at rockspec format page, it could pronounce it a bit better that fields such as
But
new-version and write-rockspec tests that run corresponding commands on scm rockspecs, I've fixed it. |
Return `Couldn't extract archive <file>: unrecognized filename extension` instead of `Unrecognized extension <ext>`, so that it's clear that the file is being interpreted as an archive.
778ab80
to
998fe0b
Compare
Sure, a plain "https://github.com/user/project" can't be detected, but I notice that users assume that the .git extension is a way of telling LuaRocks that the URL is a Git repo. |
@hishamhm that could work, but what would the standard way of doing things be, 'git+https://foo.com/bar' or 'https://foo.com/bar.git'? Or do you want to remove the first one? |
I'd keep them both. I guess Git users would naturally grativate towards the latter (it's the default URL Github gives you for copy-pasting), but we'd still have to handle foo:// protocols for the other SCMs. |
Ok, that could be helpful. We'll have two ways for doing one thing, but that's fine as one of them is more general than the other. Sorry for derailing this with my suggestions, can this PR be merged? |
Sure! |
Currently fetch ignores archive unpack errors and simply checks if expected source directory exists. This may be a workaround to support an undocumented feature that allows to use an url pointing directly to a
.lua
or.c
file, butfs.unpack_archive
already ignores such files.With this PR unpack errors are detected earlier, and use a different message for unrecognized archive extension, which is a common error that happens when wrongly using
https://
in place ofgit+https://
:Directory <name> not found inside archive <name>.git
becomes
Couldn't extract archive <name>.git: unrecognized extension
.