-
Notifications
You must be signed in to change notification settings - Fork 128
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: Find jsonrpc by header file #260
Conversation
This method is more robust, though I submitted an alternative PR that avoids avoidable TOCTOU and adds necessary |
See my comment #262 (comment). |
As noted in #262 (comment), EDIT: I gather the issue was with |
I've updated the code. This is much more robust now. :)
Okay, I've done some tests and I think is the bug from Emacs itself. 🤔 At least, |
I would suggest squashing the commits, as it is very hard to follow with the formatting changes going on and then reverting, EDIT: |
FYI, I don't have the push permission so I don't have the control over this.
Thanks for the suggestion! Updated! 👍 |
Are you speaking about squashing the commits? You can always squash commits on your local repo and force push to your own github repo, the PR will update. |
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.
If this package version check returns nil
then this fails. There are corners cases where this can still happen, (like not having the .el file or it's compressed to .el.gz). Probing package version is ultimately a hack and would best be avoided.
If this were installed as a bonafide package then this would be unnecessary.
However, at the least, if the version check returns nil, probably should assume the dependency is installed.
Suggest something like:
(old-jsonrpc
(when-let
((jsonrpc-version (copilot--jsonrpc-version))) (version< jsonrpc-version "1.0.23")))
Yeah, that's why I go for package descriptor as my first attempt. But what makes you think this is a hack? 🤔 And out of curiosity, when will
Thanks for the suggestion. I am keen to keep this PR like this for now because I have another PR in #247, and it will overwrite some of the logic here. Therefore, I will improve this after #247 gets merged. |
Doing a version check using mechanisms outside of a package manager is unfortunately a hack. This is partly due to how packaging in emacs works. It is unfortunately the situation. How this is supposed to work is that copilot.el would be a proper package and dependencies would be handled for it. Failing that, probing for the specific feature in question (ie trap if the instance creation fails) would be more ideal, though I am aware that takes more effort. I have nearly 400 packages in my setup and I have not seen one resort to package-buffer-info or similar outside of tools like el-get, etc.
So it is perfectly fine to have your el files compressed, and emacs works seamlessly. https://www.gnu.org/software/emacs/manual/html_node/emacs/Compressed-Files.html
Exactly, but having compressed sources are compatible with correctly installed packages. So I am saying for features like these in general that are mostly intended as an imperfect fallback, if the check fails, it should soft fail optimistically. So someone that has their sources compressed or some non-typical thing, yeah they are on their own as far as versions, but at least it doesn't just break. |
Yes, you are right. Any improvements are welcome since I don't have a better solution.
👍
Thanks for the information. It's very helpful. I'll make improvements after other PRs have merged, and feel free to open PRs for this. |
Ok, after getting some time to examine the actual problem leading to this I think this can be handled with a trap on invalid-slot-name. PR #264. |
I think you have the better solution. Close this one now! :) |
It seems like
(package-get-descriptor 'jsonrpc)
will return the the latest version on ELPA. Uselocate-library
instead.