emacs-traad icon indicating copy to clipboard operation
emacs-traad copied to clipboard

How to start with traad?

Open p-enel opened this issue 6 years ago • 7 comments
trafficstars

I'm not familiar with emacs and rope, I might miss some basic steps to make traad work properly: After installing traad in emacs and from pip, if I call traad-install-server I get the following message: Opening directory: No such file or directory, /home/pier/.virtualenvs What am I missing?

p-enel avatar Mar 24 '19 16:03 p-enel

This is likely virtualenvwrapper.el attempting to create a new virtual environment. It determines where to create it based on the venv-location variable, which by default contains ~/.virtualenvs. You might just try creating that directory and trying again.

I've stopped development of traad and this emacs extension, so I won't be able to provide much assistance, I'm afraid.

On Sun, Mar 24, 2019 at 5:20 PM Pierre Enel [email protected] wrote:

I'm not familiar with emacs and rope, I might miss some basic steps to make traad work properly: After installing traad in emacs and from pip, if I call traad-install-server I get the following message: Opening directory: No such file or directory, /home/pier/.virtualenvs What am I missing?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/abingham/emacs-traad/issues/33, or mute the thread https://github.com/notifications/unsubscribe-auth/AAE1eO2MSrwuVFiJt-oh2dTMZ6B-Fl91ks5vZ6XhgaJpZM4cFl_5 .

abingham avatar Mar 25 '19 07:03 abingham

I ran into the same problem. That is pretty much the issue. I have a (dirty) patch for this which I probably should have pushed upstream, I can open a pull request if you like.

jcaw avatar Mar 25 '19 12:03 jcaw

I created the folder when I saw this message, but I get another error: Invalid virtualenv traad specified! I'd love to be able to use your patch @jcaw

p-enel avatar Mar 25 '19 15:03 p-enel

Here we go. This is loaded after Traad, before any Traad functions are invoked.

;; Monkey-patch TRAAD so it creates the ".virtualenvs" folder if
;; it doesn't already exist.
(defun spacemacs/traad-install-server-monkeypatch (&rest args)
  "Applies monkeypatches to `traad'. Best run before `traad-install-server'."
  (let ((virtualenv-folder "~/.virtualenvs"))
    (unless (file-directory-p virtualenv-folder)
      (make-directory virtualenv-folder))))
(advice-add 'traad-install-server :before 'spacemacs/traad-install-server-monkeypatch)

After that, run M-x traad-install-server. It should create the ~/.virtaulenvs folder, then create a virtual environment for Traad, and install Traad in that environment.

As I say though, this is a dirty fix. It relies on using the default settings for virtualenvs. It needs cleaning up for general use.

jcaw avatar Mar 25 '19 22:03 jcaw

I created the folder when I saw this message, but I get another error: Invalid virtualenv traad specified!

Just tested the patched version in a fresh arch Vbox, I ran into the same problem. Digging in, virtualenv wasn't installed.

Here's how it was failing. This is the installation command for traad:

(defun traad-install-server ()
  "Install traad.

This installs the server into the `traad-environment-name'
virtual environment, creating the virtualenv if necessary.

By default, then, it installs traad into
`PYTHON-ENVIRONMENT_DIRECTORY/traad`.

To install Traad for a different version of Python than the
default, ensure the virtual environment exists (and is running
that version of Python) before calling `traad-install-server'."
  (interactive)
  (ignore-errors
    (venv-mkvirtualenv traad-environment-name))
  (venv-with-virtualenv-shell-command
   traad-environment-name
   traad--install-server-command))

So, it seems to be failing to create the virtualenv. This is why it fails silently:

  (ignore-errors
    (venv-mkvirtualenv traad-environment-name))

Isolating this line:

(venv-mkvirtualenv traad-environment-name)

We can expose the error. In my case:

(error "There doesn’t appear to be a virtualenv executable on\n    your exec path. Ensure that you have virtualenv installed and\n    that the exec-path variable is set such that virtualenv can\n    be found. A common cause of problems like this is GUI Emacs\n    not having environment variables set up like the shell. Check\n    out https://github.com/purcell/exec-path-from-shell for a\n    robust solution to this problem.")

I can patch this too if you guys like.

jcaw avatar Mar 25 '19 22:03 jcaw

Thanks for digging in the code. Indeed I didn't have virtualenv installed on my machine either. After installing it the server seemed to install properly. Maybe an error message indicating that virtualenv is not installed would do.

I noticed an environment with python 2 was installed and I am working with python 3, I don't know if it's an issue or not in this case. Anyway, I tried a few functions which all failed probably because of a server issue: traad-rename returns Contacting host: 127.0.0.1:38361 Supported protocol version detected: 3

traad-popup-doc returns Contacting host: 127.0.0.1:38361 REQUEST [error] Error (error) while connecting to http://127.0.0.1:38361/code_assist/doc.

p-enel avatar Mar 26 '19 16:03 p-enel

I remember having the first issue before. Is traad up-to-date in both Emacs and Python?

On Windows, I sometimes had to call the first function of a session twice - the first seemed to boot the server without working properly. Never dug into what caused that.

I've never been able to get the documentation functions working reliably. I use other packages for that.

jcaw avatar Mar 30 '19 13:03 jcaw