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

Faulty auto install #17

Open
fapdash opened this issue Feb 21, 2023 · 7 comments
Open

Faulty auto install #17

fapdash opened this issue Feb 21, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@fapdash
Copy link

fapdash commented Feb 21, 2023

This is my config:

(use-package codeium
  :load-path "~/.emacs.d/lisp/codeium.el"
  :init
  (add-hook 'prog-mode-hook
             (lambda ()
               (setq-local completion-at-point-functions '(codeium-completion-at-point))))

  :defer t
  :config
  (setq use-dialog-box nil) ;; do not use popup boxes

  ;; get codeium status in the modeline
  (setq codeium-mode-line-enable
        (lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
  (add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
  ;; alternatively for a more extensive mode-line
  ;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t)

  ;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
  (setq codeium-api-enabled
        (lambda (api)
          (memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))

  ;; You can overwrite all the codeium configs!
  ;; for example, we recommend limiting the string sent to codeium for better performance
  (defun my-codeium/document/text ()
    (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max))))
  ;; if you change the text, you should also change the cursor_offset
  ;; warning: this is measured by UTF-8 encoded bytes
  (defun my-codeium/document/cursor_offset ()
    (codeium-utf8-byte-length
     (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point))))
  (setq codeium/document/text 'my-codeium/document/text)
  (setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset))

This somehow doesn't load codeium, I had to explicitly require it:

(require 'codeium)

Afterwards I ran M-x codeium-init and M-x codeium-install. I never was asked for an API key or was redirected to a URL.
I don't get any completions anymore. Editing a file is incredibly slow, my input is delayed very noticeably.

This error gets printed into *codeium-log* several times per second:

/snap/emacs/1808/usr/bin/emacs: /home/fap/.emacs.d/codeium/codeium_language_server: No such file or directory

Process codeium exited abnormally with code 127

But the file exists:

$ file ~/.emacs.d/codeium/codeium_language_server 
/home/fap/.emacs.d/codeium/codeium_language_server: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, interpreter /ld-linux-x86-64.so.2, missing section headers

Output of codeium-diagnose:

codeium state: default
command: 
/home/fap/.emacs.d/codeium/codeium_language_server --api_server_host server.codeium.com --api_server_port 443 --manager_dir /tmp/codeium_hquefa

GetCompletions
http://localhost/exa.language_server_pb.LanguageServerService/GetCompletions
codeium/metadata/ide_name	"emacs"
codeium/metadata/extension_version	"1.1.38"
codeium/metadata/ide_version	"28.2"
codeium/metadata/request_id	6
codeium/metadata/api_key	nil
codeium/document/text	"re t\n  :after geiser-mode\n  :config (add-hook 'geiser-mode-hook #'macrostep-geiser-setup))\n\n(use-pac..."
codeium/document/cursor_offset	3000
codeium/document/editor_language	"emacs-lisp-mode"
codeium/document/language	60
codeium/document/line_ending	"\n"
codeium/editor_options/tab_size	4
codeium/editor_options/insert_spaces	t

Heartbeat
http://localhost/exa.language_server_pb.LanguageServerService/Heartbeat
codeium/metadata/ide_name	"emacs"
codeium/metadata/extension_version	"1.1.38"
codeium/metadata/ide_version	"28.2"
codeium/metadata/request_id	nil
codeium/metadata/api_key	nil

CancelRequest
http://localhost/exa.language_server_pb.LanguageServerService/CancelRequest
codeium/metadata/ide_name	"emacs"
codeium/metadata/extension_version	"1.1.38"
codeium/metadata/ide_version	"28.2"
codeium/metadata/request_id	nil
codeium/request_id	nil
codeium/metadata/api_key	nil

GetAuthToken
http://localhost/exa.language_server_pb.LanguageServerService/GetAuthToken

RegisterUser
http://localhost/exa.language_server_pb.LanguageServerService/RegisterUser
codeium/firebase_id_token	nil

auth-redirect
http://localhost/auth

AcceptCompletion
http://localhost/exa.language_server_pb.LanguageServerService/AcceptCompletion
codeium/metadata/ide_name	"emacs"
codeium/metadata/extension_version	"1.1.38"
codeium/metadata/ide_version	"28.2"
codeium/metadata/request_id	nil
codeium/completion_id	nil
codeium/metadata/api_key	nil

Emacs Version:

GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2023-01-30

Let me know if you need any other information.

@fortenforge
Copy link
Contributor

This error might mean that the package was unable to successfully set the language server binary as executable. O

Can you try executing the file?

~/.emacs.d/codeium/codeium_language_server 

@fapdash
Copy link
Author

fapdash commented Feb 22, 2023

I don't know how it happens but somehow Emacs botches the language server file. The file exists but bash also claims that there is no such file when I tell it to execute the file. Permissions are set correctly.

File downloaded by Emacs:

$ ~/.emacs.d/codeium/codeium_language_server
bash: /home/fap/.emacs.d/codeium/codeium_language_server: No such file or directory

$ file ~/.emacs.d/codeium/codeium_language_server
/home/fap/.emacs.d/codeium/codeium_language_server: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, interpreter /ld-linux-x86-64.so.2, missing section headers

~$ ls -lh ~/.emacs.d/codeium/codeium_language_server
-rwxr--r-- 1 fap fap 50M Feb 21 10:20 /home/fap/.emacs.d/codeium/codeium_language_server

Manually downloaded language server file:

$ ls -lh language_server_linux_x64
-rwxrwxr-x 1 fap fap 51M Feb 22 10:53 language_server_linux_x64

$ file language_server_linux_x64
language_server_linux_x64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, Go BuildID=redacted, BuildID[md5/uuid]=2d79362e1058d0c0a41609019c05f0f9, stripped

After replacing the language server file with the file I manually downloaded the problem went away.

So what is causing this / which step is failing? It looks like the downloaded file is corrupt.

I modified the codeium.el code to remove the decompression step:

(defun codeium-install-process-url-res (state url url-buf filename)
	(make-directory (file-name-directory filename) t)
	(with-temp-file filename
		(set-buffer-multibyte nil)
		(url-insert-buffer-contents url-buf url))
	(chmod filename #o744)
	(kill-buffer url-buf)
	(message "successfully installed codeium local language server"))

Expected

$ file language_server_linux_x64.gz 
language_server_linux_x64.gz: gzip compressed data, was "language_server_linux_x64", last modified: Thu Feb 16 23:23:24 2023, max compression, from Unix, original size modulo 2^32 52498072

Decompression with gzip works fine for this file.

Actual

$ file codeium_language_server
codeium_language_server: gzip compressed data, was "language_server_linux_x64", last modified: Sat Feb 11 02:29:49 2023, max compression, from Unix, original size modulo 2^32 51448632

$ mv codeium_language_server codeium_language_server.gz

$ gzip -d codeium_language_server.gz

gzip: codeium_language_server.gz: invalid compressed data--format violated

@Alan-Chen99
Copy link
Contributor

Is this fetched from the same version? (at the url of codeium-download-url)

@Alan-Chen99
Copy link
Contributor

Alan-Chen99 commented Feb 22, 2023

This somehow doesn't load codeium, I had to explicitly require it:

This has to do with :defer of use-package, basically it only loads a fake function (an autoload) for the entrypoints, the fake function will load the library and run the function. I should probably remove it from readme

@fapdash
Copy link
Author

fapdash commented Feb 23, 2023

Is this fetched from the same version? (at the url of codeium-download-url)

Yes, the file is downloaded from https://github.com/Exafunction/codeium/releases/download/language-server-v1.1.38/language_server_linux_x64.gz and codeium-download-url is set to the same url.

@fortenforge
Copy link
Contributor

Is this a one-time issue where the download just got interrupted or does this happen every time? (For example if you deleted the language server binary and retried M-x codeium-install?

@Alan-Chen99
Copy link
Contributor

Try url-insert instead of url-insert-buffer-contents and bind file-name-handler-alist to nil around the with-temp-file?

@Alan-Chen99 Alan-Chen99 changed the title Not working - codeium_language_server: No such file or directory Faulty auto install Feb 26, 2023
@Alan-Chen99 Alan-Chen99 added the bug Something isn't working label Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants