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

Fix "error: unrecognized arguments" #6936

Closed
wants to merge 1 commit into from

Conversation

drew2a
Copy link
Contributor

@drew2a drew2a commented Jun 14, 2022

This PR fixes #6929

@drew2a drew2a requested a review from kozlovsky June 14, 2022 12:30
@drew2a drew2a marked this pull request as ready for review June 14, 2022 12:30
@drew2a drew2a requested a review from a team June 14, 2022 12:30
@drew2a
Copy link
Contributor Author

drew2a commented Jun 14, 2022

@kozlovsky could you please confirm that it works on built windows?

Copy link
Contributor

@kozlovsky kozlovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is indeed working; I can confirm it on Windows. But I don't think this is the proper way to handle the issue. The proposed fix just ignores arguments that ArgsParser does not understand, and it may be error-prone. Like, if later GUI starts specifying new options when running Core, any typo in an argument will remain unnoticed, as Core will silently ignore unknown arguments.

I debugged the problem and found the reason for the error. It is in this line of CoreManager:

self.core_process.start(sys.executable, core_args)

There is a difference in arguments between a python script and a compiled executable. For script, arguments can look like

["myscript.py", "arg1", "arg2"]

and sys.executable is something like C:/Python39/python.exe.

For the same code in the compiled executable, arguments will be

["myscript.exe", "arg1", "arg2"]

and sys.executable is myscript.exe.

That means that when Tribler executes self.core_process.start(sys.executable, core_args) from the compiled binary, it runs tribler.exe with arguments ["tribler.exe", "some.torrent", "--core"], because tribler.exe comes both from sys.executable and from sys.argv[0]. The proper fix, in my opinion, is to remove duplicate "tribler.exe" from the argument list when running a code from compiled binary.

So, the reason for the error is that when compiled, GUI runs Core with arguments:

tribler.exe tribler.exe some.torrent --core

And the proposed fix ignores the last positional argument, interpreting the arguments as

tribler.exe tribler.exe --core

where the second "tribler.exe" is interpreted as a torrent file name, while the proper fix should ignore the first positional argument and not the last one. To remove the duplicate binary, we can do something like the following.

@drew2a
Copy link
Contributor Author

drew2a commented Jun 15, 2022

The proper fix is here: #6937

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

Successfully merging this pull request may close these issues.

2 participants