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

luacheck requires a real path to a directory? #208

Open
Totktonada opened this issue Nov 11, 2020 · 3 comments
Open

luacheck requires a real path to a directory? #208

Totktonada opened this issue Nov 11, 2020 · 3 comments

Comments

@Totktonada
Copy link

I found that under the following circumstances I need to pass a real directory path (with resolved symlinks) to the luacheck executable in order to don't miss warnings:

  1. .luacheckrc in a project root have include_files with some globs.
  2. The current directory is non-real path to the project root.
  3. The argument to luacheck is the same non-real path.

How to reproduce:

$ mkdir -p "${HOME}"/tmp/test-luacheck/aaa  # project root
$ cd "${HOME}"/tmp/test-luacheck/aaa
$ echo 'foo = 42' > foo.lua
$ echo "include_files = {'**/*.lua'}" > .luacheckrc
$ luacheck --config .luacheckrc "${HOME}"/tmp/test-luacheck/aaa
Checking /home/alex/tmp/test-luacheck/aaa/foo.lua 1 warning

    /home/alex/tmp/test-luacheck/aaa/foo.lua:1:1: setting non-standard global variable foo

Total: 1 warning / 0 errors in 1 file
$ cd ..
$ ln -s aaa bbb
$ cd bbb
$ luacheck --config .luacheckrc "${HOME}"/tmp/test-luacheck/bbb
Total: 0 warnings / 0 errors in 0 files
$ cd .. && tree
.
├── aaa
│   └── foo.lua
└── bbb -> aaa

2 directories, 1 file

I step into this problem, because I use symlinks to ease access to directories that I use often. I'm not sure this is broad approach, but I hope it is valid. At least, it seems, it does not contradict with the current luacheck documentation.

(I'm aware about the status of the repository, but I think that issues should be filed here until the repository will be properly migrated: otherwise we'll have several issue numerations.)

@Totktonada
Copy link
Author

I also found that even if I pass the real path, but the current working directory is different, the files are missed:

$ pwd
/home/alex/tmp/test-luacheck
$ mkdir ccc
$ cd ccc
$ luacheck --config ../aaa/.luacheckrc /home/alex/tmp/test-luacheck/aaa
Total: 0 warnings / 0 errors in 0 files

Totktonada added a commit to tarantool/tarantool that referenced this issue Nov 11, 2020
Now `make luacheck` gracefully handles different cases: in-source and
out-of-source build (within the source tree or outside), current working
directory as a real path or with symlink components.

As result of looking into those problems I filed the issue [1] against
luacheck. It seems, there are problems around absolute paths with
symlinks components.

[1]: mpeterv/luacheck#208
Totktonada added a commit to tarantool/tarantool that referenced this issue Dec 1, 2020
Now `make luacheck` gracefully handles different cases: in-source and
out-of-source build (within the source tree or outside), current working
directory as a real path or with symlink components.

As result of looking into those problems I filed the issue [1] against
luacheck. It seems, there are problems around absolute paths with
symlinks components.

[1]: mpeterv/luacheck#208
@ligurio
Copy link

ligurio commented Dec 8, 2020

I suggest to resolve specified path using readlink, it works:

Total: 1 warning / 0 errors in 1 file
sergeyb@pony:~/sources/MRG/ttt$ luacheck --config .luacheckrc /home/sergeyb/sources/MRG/ttt
Total: 0 warnings / 0 errors in 0 files
sergeyb@pony:~/sources/MRG/ttt$ luacheck --config .luacheckrc $(readlink /home/sergeyb/sources/MRG/ttt)
Checking /home/sergeyb/sources/MRG/tt/test.lua    1 warning

    /home/sergeyb/sources/MRG/tt/test.lua:1:1: setting non-standard global variable a

Total: 1 warning / 0 errors in 1 file
sergeyb@pony:~/sources/MRG/ttt$ 

@Totktonada
Copy link
Author

@ligurio It seems it works only when .luacheckrc can be found by upward directories traversal. See #208 (comment).

ligurio pushed a commit to tarantool/tarantool that referenced this issue Dec 16, 2020
Now `make luacheck` gracefully handles different cases: in-source and
out-of-source build (within the source tree or outside), current working
directory as a real path or with symlink components.

As result of looking into those problems I filed the issue [1] against
luacheck. It seems, there are problems around absolute paths with
symlinks components.

[1]: mpeterv/luacheck#208
Totktonada added a commit to tarantool/tarantool that referenced this issue Feb 18, 2021
Now `make luacheck` gracefully handles different cases: in-source and
out-of-source build (within the source tree or outside), current working
directory as a real path or with symlink components.

As result of looking into those problems I filed the issue [1] against
luacheck. It seems, there are problems around absolute paths with
symlinks components.

[1]: mpeterv/luacheck#208
Totktonada added a commit to tarantool/tarantool that referenced this issue Mar 5, 2021
Now `make luacheck` gracefully handles different cases[^1]: in-source
and out-of-source build (within the source tree or outside), current
working directory as a real path or with symlink components.

As result of looking into those problems I filed the issue [1] against
luacheck. It seems, there are problems around absolute paths with
symlinks components.

[^1]: We have the similar problems with LuaJIT's luacheck rule. They
      will be fixed in a separate patch.

[1]: mpeterv/luacheck#208

Reviewed-by: Sergey Bronnikov <[email protected]>
Reviewed-by: Igor Munkin <[email protected]>
Totktonada added a commit to tarantool/tarantool that referenced this issue Mar 5, 2021
Now `make luacheck` gracefully handles different cases[^1]: in-source
and out-of-source build (within the source tree or outside), current
working directory as a real path or with symlink components.

As result of looking into those problems I filed the issue [1] against
luacheck. It seems, there are problems around absolute paths with
symlinks components.

[^1]: We have the similar problems with LuaJIT's luacheck rule. They
      will be fixed in a separate patch.

[1]: mpeterv/luacheck#208

Reviewed-by: Sergey Bronnikov <[email protected]>
Reviewed-by: Igor Munkin <[email protected]>
Totktonada added a commit to tarantool/tarantool that referenced this issue Mar 5, 2021
Now `make luacheck` gracefully handles different cases[^1]: in-source
and out-of-source build (within the source tree or outside), current
working directory as a real path or with symlink components.

As result of looking into those problems I filed the issue [1] against
luacheck. It seems, there are problems around absolute paths with
symlinks components.

[^1]: We have the similar problems with LuaJIT's luacheck rule. They
      will be fixed in a separate patch.

[1]: mpeterv/luacheck#208

Reviewed-by: Sergey Bronnikov <[email protected]>
Reviewed-by: Igor Munkin <[email protected]>
(cherry picked from commit af44846)
Totktonada added a commit to tarantool/tarantool that referenced this issue Mar 5, 2021
Now `make luacheck` gracefully handles different cases[^1]: in-source
and out-of-source build (within the source tree or outside), current
working directory as a real path or with symlink components.

As result of looking into those problems I filed the issue [1] against
luacheck. It seems, there are problems around absolute paths with
symlinks components.

[^1]: We have the similar problems with LuaJIT's luacheck rule. They
      will be fixed in a separate patch.

[1]: mpeterv/luacheck#208

Reviewed-by: Sergey Bronnikov <[email protected]>
Reviewed-by: Igor Munkin <[email protected]>
(cherry picked from commit af44846)
igormunkin added a commit to tarantool/luajit that referenced this issue Mar 5, 2021
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is the dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
igormunkin added a commit to tarantool/luajit that referenced this issue Mar 5, 2021
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is the dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
igormunkin added a commit to tarantool/luajit that referenced this issue Mar 9, 2021
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is a dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Reviewed-by: Alexander Turenko <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
igormunkin added a commit to tarantool/luajit that referenced this issue Mar 10, 2021
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is a dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Reviewed-by: Alexander Turenko <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
(cherry picked from commit 00f82a6)
igormunkin added a commit to tarantool/luajit that referenced this issue Mar 10, 2021
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is a dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Reviewed-by: Alexander Turenko <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
(cherry picked from commit 00f82a6)
igormunkin added a commit to tarantool/luajit that referenced this issue Mar 10, 2021
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is a dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Reviewed-by: Alexander Turenko <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
(cherry picked from commit 00f82a6)
igormunkin added a commit to tarantool/luajit that referenced this issue Mar 10, 2021
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is a dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Reviewed-by: Alexander Turenko <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
igormunkin added a commit to tarantool/luajit that referenced this issue Jun 16, 2022
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is a dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Reviewed-by: Alexander Turenko <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
igormunkin added a commit to tarantool/luajit that referenced this issue Jun 16, 2022
Unfortunately, luacheck doesn't handle the working directory or one used
in options if it is not a real path. As a result of this patch both
PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR are resolved prior to be used
within luacheck target custom command.

The issue has been already fixed in Tarantool repo after applying
af448464d15f60b87f1c9ef41a7816911c889459 ('tools: fix luacheck
invocation in different cases'), and this patch is necessary, since
<LuaJIT-luacheck> is a dependency for Tarantool <luacheck> target.

Relates to mpeterv/luacheck#208

Reported-by: Alexander Turenko <[email protected]>
Reviewed-by: Alexander Turenko <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
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

2 participants