Skip to content

Conversation

@Mikaz-fr
Copy link
Contributor

@Mikaz-fr Mikaz-fr commented Mar 9, 2020

In clink.lua line 434 we use clink.find_files() to call each lua script from clink-completions folder:

local completions_dir = clink.get_env('CMDER_ROOT')..'/vendor/clink-completions/'
for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do

The find_file function is implemented in the Clink dll (https://github.com/mridgers/clink/blob/0.4.9/clink/dll/lua.c#L215) and make use of readdir() to list files present. But readdir() doesn't ensure any order for file being returned (see http://man7.org/linux/man-pages/man3/readdir.3.html). It seems that on Windows the order returned depends on the file creation order.

This means currently the order of execution for scripts inside clink-completions is not enforced, but .init.lua must be executed first since it's setting the path for require calls made after.
If for some reason somebody had their clink-completion folder content created in a different order (like it happened for me) then when Clink is started an error is printed: module '<NAME>' not found.
This can be tested by deleting and recreating .init.lua inside clink-completion folder after installation.

To avoid this issue I think it would be safer to always call .init.lua first before looping through the content of clink-completion. This is the change proposed with this pull request.

Note that I followed the Contributing Guidelines (https://github.com/cmderdev/cmder/blob/master/CONTRIBUTING.md) but it seems that the development branch to use for pull request is quite outdated compared to master. Let me know if I should have done differently.

AlphaGit and others added 2 commits July 24, 2017 23:15
(and some comments on the user-profile.cmd file)

Inspired by the comments from #193 and my personal need to use pageant instead of OpenSSH authentication agents (which is more Window user-friendly), I have used this approach which works as expected.

Keeping the spirit of the current scripts, I left it disabled, and with some comments explaining what they all do.
…nt, leading to .init.lua not being run first lua path being broken
@Mikaz-fr
Copy link
Contributor Author

Mikaz-fr commented Mar 9, 2020

Not sure why 4243c5c is coming with this pull request, my changes have nothing to do with init.bat (I just branched from development branch directly).

@daxgames
Copy link
Member

daxgames commented Mar 9, 2020

@Mikaz-fr Branch from master. We do not use development any longer. Sorry for the confusion.

@Mikaz-fr
Copy link
Contributor Author

Mikaz-fr commented Mar 9, 2020

I understand, would you update the Contributing guidelines ?
Should I make a new pull request on master and close this one ?

@Mikaz-fr
Copy link
Contributor Author

Mikaz-fr commented Mar 9, 2020

Closing this one, I've opened #2278 on master instead.

@Mikaz-fr Mikaz-fr closed this Mar 9, 2020
@Mikaz-fr Mikaz-fr deleted the clink_path_fix branch March 9, 2020 15:44
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

Successfully merging this pull request may close these issues.

3 participants