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

Wrong shebang? #346

Open
Dolgorbie opened this issue Feb 22, 2020 · 6 comments
Open

Wrong shebang? #346

Dolgorbie opened this issue Feb 22, 2020 · 6 comments

Comments

@Dolgorbie
Copy link

I have two Mac PCs whose version is 10.14.
I installed Jedi on one of my Macs a years ago
and installed Jedi on the other some days ago.
The older emacs-jedi system works well, but the newer doesn't.

I found a defference between them in ~/.emacs.d/.python-environments/default/bin/jediepcserver.
The shebang of that of correctly working system is:
#!/Users/username/.emacs.d/.python-environments/default/bin/python3.7
But that of broken is:
#!/usr/local/opt/python/bin/python3.7

I rewrote second shebang to first shebang.
Then the broken jedi worked.

@immerrr
Copy link
Collaborator

immerrr commented Feb 22, 2020

That shebang is overwritten by whatever python is used to install the jediepcserver script.

In the repo the shebang is neither of the two values:

#!/usr/bin/env python

Do you have any way of knowing how was the newer jediepcserver installed?

@Dolgorbie
Copy link
Author

I used the following emacs command:
M-x jedi:install-server

@iharsuvorau
Copy link

Have the same problem. @Dolgorbie suggestion solved the problem.

@immerrr
Copy link
Collaborator

immerrr commented Mar 15, 2020

@iharsuvorau @Dolgorbie could you share what are your jedi:environment-root, python-environment-default-root-name and python-environment-directory? jedi:show-setup-info command shows those and some other configuration parameters that could be useful.

Also, when you say it doesn't work, could you please share what's the problem?

And finally, would be interesting to see what's your jedi:show-version-info situation.

Thank you!

@iharsuvorau
Copy link

@immerrr sure, thank you for debugging. Here is it:

Output of jedi:show-setup-info:

;; Emacs Lisp version:
(:emacs-version "26.3" :jedi-version "0.2.8" :python-environment-version "0.0.2alpha0")
;; Python version:
nil
;; EPC error:
(:get-epc-error
 (wrong-type-argument epc:manager nil))
;; Command line:
(:virtualenv "/usr/local/bin/virtualenv" :virtualenv-version "virtualenv 20.0.10 from /usr/local/lib/python3.7/site-packages/virtualenv/__init__.py\n")
;; Customization:
((jedi:complete-on-dot . t)
 (jedi:doc-display-buffer . display-buffer)
 (jedi:doc-hook view-mode)
 (jedi:doc-mode . rst-mode)
 (jedi:environment-root)
 (jedi:environment-virtualenv)
 (jedi:get-in-function-call-delay . 1000)
 (jedi:get-in-function-call-timeout . 3000)
 (jedi:goto-definition-config
  (nil nil nil)
  (t nil nil)
  (nil definition nil)
  (t definition nil)
  (nil nil t)
  (t nil t)
  (nil definition t)
  (t definition t))
 (jedi:goto-definition-hook)
 (jedi:goto-definition-marker-ring-length . 16)
 (jedi:imenu-create-index-function . jedi:create-nested-imenu-index)
 (jedi:import-python-el-settings . t)
 (jedi:install-imenu)
 (jedi:install-python-jedi-dev-command "pip" "install" "--upgrade" "git+https://github.com/davidhalter/jedi.git@master#egg=jedi")
 (jedi:key-complete .
		    [C-tab])
 (jedi:key-goto-definition .
			   [67108910])
 (jedi:key-goto-definition-pop-marker .
				      [67108908])
 (jedi:key-related-names . "�r")
 (jedi:key-show-doc . "�d")
 (jedi:server-args)
 (jedi:server-command "/Users/ihar/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py")
 (jedi:setup-keys)
 (jedi:tooltip-method pos-tip popup)
 (jedi:use-shortcuts)
 (python-environment-default-root-name . "default")
 (python-environment-directory . "~/.emacs.d/.python-environments")
 (python-environment-virtualenv "virtualenv" "--system-site-packages" "--quiet"))

I have the following errors:

================================
Failed to start Jedi EPC server.
================================

*** EPC Error ***
Server may raise an error. Use "M-x epc:pop-to-last-server-process-buffer RET" to see full traceback:
Traceback (most recent call last):
  File "/Users/ihar/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py", line 39, in <module>
    import jedi
ImportError: No module named jedi


*** EPC Server Output (last 10 lines) ***
Traceback (most recent call last):
  File "/Users/ihar/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py", line 39, in <module>
    import jedi
ImportError: No module named jedi


*** EPC Server Config ***
Server arguments: ("/Users/ihar/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py")
Actual command: /Users/ihar/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py
VIRTUAL_ENV envvar: nil

*** jedi-mode is disabled in #<buffer *jedi:show-setup-info*> ***
Fix the problem and re-enable it.

*** You may need to run "M-x jedi:install-server". ***
This could solve the problem especially if you haven't run the command yet
since Jedi.el installation or update and if the server complains about

and at the same time in the minibuffer:

jedi:epc--start-epc: Wrong type argument: epc:manager, nil

Running M-x jedi:install-server doesn't influence the situation, that's how the server was installed.

Running jedi:show-version-info throws the same error: couldn't start the server.

@immerrr
Copy link
Collaborator

immerrr commented Apr 29, 2020

Could someone affected by this try the snippet below and show what does it say in *Messages* buffer?

It'll install jedi to a different venv and trace the execution.

(defvar trace-indent 0)

(defun trace-function (fn-name orig-fun &rest args)
  (cl-incf trace-indent)
  (unwind-protect
      (let ((trace-prefix (make-string (* 2 trace-indent) (string-to-char "="))))
        (message "======%s %s called with args %S" trace-prefix fn-name args)
        (let ((res (apply orig-fun args)))
          (message "======%s %s returned %S" trace-prefix fn-name res)
          res))
    (cl-decf trace-indent)))


(defun remove-advices (fn-sym)
  (advice-mapc (lambda (func props) (advice-remove fn-sym func)) fn-sym))

(defun remove-single-advice (fn-sym func-to-remove)
  (advice-mapc (lambda (func props)
                 (when (equal func func-to-remove)
                   (advice-remove fn-sym func)))
               fn-sym))

(defun add-trace-function (fn-sym)
  (lexical-let*
      ((fn-sym fn-sym)
       (trace-fn (lambda (&rest args)
                   (apply #'trace-function
                          (format "Function %S" fn-sym)
                          args))))
    (advice-add fn-sym :around trace-fn)
    (list fn-sym trace-fn)))

(defun trace-jedi-install-server-block ()
  (let* ((jedi:environment-root "jedi-trace-install-server-block")
         (funcs-to-advise '(python-environment--blocking-process
                            python-environment-run-block
                            python-environment--deferred-process
                            call-process
                            deferred-process
                            jedi:install-server-block
                            jedi:install-server))
         advices)
    (unwind-protect
        (progn
          (mapc (lambda (fn-sym) (push (add-trace-function fn-sym) advices))
                funcs-to-advise)
          (when (python-environment-exists-p jedi:environment-root)
            (delete-directory (python-environment-root-path jedi:environment-root) 'recursive))
          (jedi:install-server-block))
      (mapc (lambda (advice-info) (apply #'remove-single-advice advice-info))
            advices))))

(trace-jedi-install-server-block)

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

No branches or pull requests

3 participants