vim-erlang / vim-erlang-tags

Generate Vim tags for Erlang files
https://vim-erlang.github.io
Other
61 stars 23 forks source link

Error detected while processing function VimErlangTags #40

Closed halturin closed 4 years ago

halturin commented 4 years ago

Ive got this error on ErlangTags command

vim-erlang-tag failed with: escript: exception error: "Some process takes to long"^@  in function  vim_erlang_tags_erl__escript__1598__5
38296__489312__4:'-create_tags/1-fun-0-'/1 (/home/taras/.vim/plugged/vim-erlang-tags/plugin/../bin/vim_erlang_tags.erl, line 292)^@  in
call from lists:foreach/2 (lists.erl, line 1338)^@  in call from vim_erlang_tags_erl__escript__1598__538296__489312__4:create_tags/1 (/h
ome/taras/.vim/plugged/vim-erlang-tags/plugin/../bin/vim_erlang_tags.erl, line 288)^@  in call from vim_erlang_tags_erl__escript__1598__
538296__489312__4:run/1 (/home/taras/.vim/plugged/vim-erlang-tags/plugin/../bin/vim_erlang_tags.erl, line 139)^@  in call from escript:r
un/2 (escript.erl, line 758)^@  in call from escript:start/1 (escript.erl, line 277)^@  in call from init:start_em/1 ^@  in call from in
it:do_boot/3 ^@

is there any way to fix it? am i doing something wrong?

PS: Debian 10

hcs42 commented 4 years ago

Hi,

halturin commented 4 years ago

Hi, thanks for getting back.

Here is the result on my side.

  1. yes
  2. yes, the same directory, the same result
  3. no, pretty small (https://github.com/halturin/mx)
  4. attached output.log.gz
  5. changed the timeout to 60000 and got memory leak. just killed by ctrl-C image
hcs42 commented 4 years ago

According to output.log.gz, the current directory contains more than 16000 Erlang source files, which is too much to be indexed. You probably don't actually want to run vim-erlang-tags on all of these files. My suggestion is to run vim-erlang-tags from the command line and specifying the directories that contain the source files you actually want to index. E.g.:

$ ../bin/vim_erlang_tags.erl src

or

$ ../bin/vim_erlang_tags.erl src deps
halturin commented 4 years ago

not sure about 16K files. find . -type f -name "*.erl" | wc -l shows only 177 including vendored dependencies image

hcs42 commented 4 years ago

Hm, that's interesting...

The output.log file that you sent starts with the following:

In create_tags, To explore: ["_build/default/lib/goldrush/src/glc.erl",
                            ...16358 files...
                             "test/mx_tests.erl"]

Then it contains log entries about starting to process all those files.

Are those 16k Erlang source files that are in output.log not actually there in your file system?

halturin commented 4 years ago

i found the reason. there is a symlink to itself in rel directory image its just a recursion.

hcs42 commented 4 years ago

@halturin Would you test my modification that doesn't follow symbolic links by default?

halturin commented 4 years ago

dont you think it would be better to have some set of directories that should be ignored?

PS: is there any chance to have an index for the OTP library within the project' dir? as it has been done in vscode

hcs42 commented 4 years ago

dont you think it would be better to have some set of directories that should be ignored?

You can set directories to be ignored. If you use the vim_erlang_tags.erl script, you can use the --ignore option. If you use the :ErlangTags command, you can do this with the erlang_tags_ignore variable.

Adding a set of default directories to ignore would not be trivial, because that depends on which build system is used by the user (rebar2? rebar3? Erlang.mk? Custom makefiles? Nothing?), and even on the users preference (some people might want to generate the tags for the dependencies in _build, while other don't). I think it's better to keep vim-erlang-tags as a simple tool that everyone can use in their preferred way.

PS: is there any chance to have an index for the OTP library within the project' dir? as it has been done in vscode

Just like you can create tags for your own project, you can create an index for the Erlang/OTP source code. I suggest using the vim_erlang_tags.erl script for that, and updating your vimrc to add the new tag file to its list of tag files:

set tags+=/path/to/tags

I'm not familiar with how VS Code handles Erlang tags. In any case, deciding where to find the source files in outside the scope of this project. Regarding the concrete example, we don't know whether a user has Erlang source on their machine at all. They might have the Erlang source code multiple times. Deciding when to generate source file is also outside the scope of this project.

hcs42 commented 4 years ago

I pushed the symlink fix into master.

halturin commented 4 years ago

I think we can close this issue. dont you mind?

hcs42 commented 4 years ago

Yes, I think so.