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

Error installing using straight.el #160

Closed
nanounanue opened this issue Jul 30, 2019 · 10 comments
Closed

Error installing using straight.el #160

nanounanue opened this issue Jul 30, 2019 · 10 comments
Labels
config Related to personal configuration issues

Comments

@nanounanue
Copy link

Recently I migrated from package.el to straight.el, but I am getting the following error:

Error (use-package): ob/:config: Cannot open load file: No such file or directory, simple-httpd

I am using the following code:

(use-package jupyter)

(use-feature ob
  :after org
  :demand t
  :custom
  (org-src-fontify-natively t)   ;; Pretty code blocks
  (org-src-tab-acts-natively t)
  (org-confirm-babel-evaluate nil)  ;; No quiero que me pregunte, si quiero ejecutar
  (org-confirm-elisp-link-function nil)
  (org-confirm-shell-link-function nil)
  (org-src-preserve-indentation t)
  :config
  (add-to-list 'org-src-lang-modes '("dot" . "graphviz-dot"))

  ;; Org-babel no muestra el stderr
  ;; http://kitchingroup.cheme.cmu.edu/blog/2015/01/04/Redirecting-stderr-in-org-mode-shell-blocks/
  (setq org-babel-default-header-args:sh
        '((:prologue . "exec 2>&1") (:epilogue . ":")))


  ;; Usamos sly
  (setq org-babel-lisp-eval-fn 'sly-eval)
  (org-babel-do-load-languages 'org-babel-load-languages
                               '((shell      . t)
                                 (awk        . t)
                                 (sed        . t)
                                 (js         . t)
                                 (emacs-lisp . t)
                                 (lisp       . t)
                                 (perl       . t)
                                 (R          . t)
                                 (scala      . t)
                                 (clojure    . t)
                                 (latex      . t)
                                 (C          . t)
                                 (fortran    . t)
                                 (stan       . t)
                                 (sqlite     . t)
                                 (sql        . t)
                                 (mongo      . t)
                                 (cypher     . t)
                                 (redis      . t)
                                 (blockdiag  . t)
                                 (calc       . t)
                                 (python     . t)
                                 (ruby       . t)
                                 (dot        . t)
                                 (css        . t)
                                 (plantuml   . t)
                                 ;; (yaml       . t)
                                 (jupyter    . t)
                                 ))
  :hook (org-babel-after-execute . org-display-inline-images))

If I remove the line (jupyter .t) it doesn't throws an error.

Given the error I added the following:

(use-package websocket
  :config
  (require 'websocket))

(use-package zmq
  :config
  (require 'zmq))

(use-package simple-httpd
  :config
  (require 'simple-httpd))

But still no luck

@nnicandro
Copy link
Collaborator

This seems more of an issue of your usage of straight.el. I would suggest you post your issue over there.

I looked briefly at the straight.el documentation did you try what is mentioned here, specifically the :straight t bit?

@dangom
Copy link
Contributor

dangom commented Jul 30, 2019

@nanounanue I would suspect this has something to do with your config. I'm on straight + jupyter and things work at my end.

Try changing your jupyter declaration to:

(use-package jupyter
:demand t
:after ob  ;; or maybe `:after org` would be sufficient
:config
  (add-to-list 'org-babel-load-languages '(jupyter . t))
  (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages))

And also, generally use-package declarations replace the need for calling require, so the following would be redundant:

(use-package simple-httpd
  :config
  (require 'simple-httpd))

From my understanding, by the time :config comes around, simple-httpd has already been required, so the statement doesn't add anything.

@nanounanue
Copy link
Author

@dzop thank you, I will check the documentation again. I tried your suggestion and it fails.

@dangom thank you, for clarify the require thing. I am still struggling through that. I will delete all my org-mode configuration and then try again.

@nnicandro nnicandro added the config Related to personal configuration issues label Aug 1, 2019
@nanounanue
Copy link
Author

@dangom I am still having the same problems, could you share with me your .emacs configuration

@dangom
Copy link
Contributor

dangom commented Aug 5, 2019

most of my org config is here. My jupyter and python configs add the following:

 (use-package python
  :config
  (setq python-indent-guess-indent-offset nil
        python-indent-guess-indent-offset-verbose nil
        python-shell-interpreter "/Users/user/anaconda3/bin/pythonw3"
        python-shell-interpreter-args "-m IPython --simple-prompt -i"
        flycheck-python-flake8-executable "/Users/user/anaconda3/bin/flake8"
        flycheck-python-pylint-executable "/Users/user/anaconda3/bin/pylint")
  :bind
  ;; Start a new kernel or move to an existing one, like in Spacemacs.
  ;; Note that this function will be defined when jupyter is initialized.
  ("M-RET '" . jupyter-run-repl-or-pop-to-buffer-dwim))

;; Package `anaconda-mode' seems to play well with Jupyter and adds the missing
;; eldoc and jump-to-definition functionalities without depending on the old
;; Python comint REPL. Its keybindings also don't interfere with emacs-jupyter,
;; which is nice.
(use-package anaconda-mode
  :hook ((python-mode . anaconda-mode)
         (python-mode . anaconda-eldoc-mode)))

(use-package pytest
  :commands (pytest-one
             pytest-pdb-one
             pytest-all
             pytest-pdb-all
             pytest-module
             pytest-pdb-module)
  :config (add-to-list 'pytest-project-root-files "setup.cfg")
  (setq pytest-cmd-flags  "-v")
  :bind (:map python-mode-map
              ("C-c a" . pytest-all)
              ("C-c m" . pytest-module)
              ("C-c ." . pytest-one)
              ("C-c d" . pytest-directory)))

(use-package pip-requirements)

(use-package py-isort
  :commands py-isort-buffer)

(use-package blacken
  :after python
  :demand t
  :commands blacken-buffer
  :bind (:map python-mode-map
              ("C-c =" . blacken-buffer)))

(use-package zmq) ; Required by jupyter.

(use-package jupyter
  :demand t

  :after ob

  :init
  (defun jupyter-run-repl-or-pop-to-buffer-dwim ()
    "If a buffer is already associated with a jupyter buffer,
then pop to it. Otherwise start a jupyter kernel."
    (interactive)
    (if (bound-and-true-p jupyter-current-client)
        (jupyter-repl-pop-to-buffer)
      (call-interactively #'jupyter-run-repl)))

  ;; * eldoc integration
  (defun scimax-jupyter-signature ()
    "Try to return a function signature for the thing at point."
    (when (and (eql major-mode 'org-mode)
               (string= (or (get-text-property (point) 'lang) "") "jupyter-python"))
      (save-window-excursion
     ;;; Essentially copied from (jupyter-inspect-at-point).
        (jupyter-org-with-src-block-client
         (cl-destructuring-bind (code pos)
             (jupyter-code-context 'inspect)
           (jupyter-inspect code pos nil 0)))
        (when (get-buffer "*Help*")
          (with-current-buffer "*Help*"
            (goto-char (point-min))
            (prog1
                (cond
                 ((re-search-forward "Signature:" nil t 1)
                  (buffer-substring (line-beginning-position) (line-end-position)))
                 ((re-search-forward "Docstring:" nil t 1)
                  (forward-line)
                  (buffer-substring (line-beginning-position) (line-end-position)))
                 (t
                  nil))
              ;; get rid of this so we don't accidentally show old results later
              (with-current-buffer "*Help*"
                (toggle-read-only)
                (erase-buffer))))))))

  (defun scimax-jupyter-eldoc-advice (orig-func &rest args)
    "Advice function to get eldoc signatures in blocks in org-mode."
    (or (scimax-jupyter-signature) (apply orig-func args)))


  (defun scimax-jupyter-turn-on-eldoc ()
    "Turn on eldoc signatures."
    (interactive)
    (advice-add 'org-eldoc-documentation-function :around #'scimax-jupyter-eldoc-advice))

  :config

  (add-to-list 'org-babel-load-languages '(jupyter . t))
  (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)

  (scimax-jupyter-turn-on-eldoc)

  ;; More readable repl traceback for Spacemacs Theme.
  (set-face-attribute 'jupyter-repl-traceback nil :background "wheat1")

  (jupyter-org-define-key (kbd "RET") #'newline-and-indent)

  :bind (:map jupyter-repl-mode-map
              ;; Use only C-n and C-p to move through candidates.
              ;; This unshadows C-n and C-p to move through lines in the REPL.
              ("C-n" . nil)
              ("C-p" . nil)))

;; Feature `jupyter-repl' is part of emacs-jupyter.
(use-feature jupyter-repl
  :hook (jupyter-repl-mode . smartparens-mode))

(use-feature ob
  :demand t
  :after (:all jupyter python)
  :config
  ;; Set better default settings for org-babel.
  (setf (alist-get :async org-babel-default-header-args:jupyter-python) "yes")
  (setf (alist-get :session org-babel-default-header-args:jupyter-python) "py3")
  ;; Julia not setup yet and not loaded in org-babel-do-load-languages.
  ;; (setf (alist-get :async org-babel-default-header-args:jupyter-julia) "yes")
  )

@nanounanue
Copy link
Author

@dangom Thank you so much. I already tried your configuration, and If I execute it from emacs (using C-x C-e or something similar) it works well, but if I launch a new emacs I am getting:

Loading package jupyter...
eval-buffer: Cannot open load file: No such file or directory, simple-httpd

And if I try to open an org-mode file (like an empty test.org):

Loading package jupyter...
File mode specification error: (file-missing Cannot open load file No such file or directory simple-httpd)

@dangom
Copy link
Contributor

dangom commented Aug 8, 2019

This must be something related to your config or the way you are using straight. I cannot reproduce. I'd suggest nuking your .emacs.d and starting emacs again. Perhaps when you switched from package to straight something went off.

@nanounanue
Copy link
Author

nanounanue commented Aug 8, 2019 via email

@nanounanue
Copy link
Author

I finally solved it!

In order to get to the root of the problem, I recreated from scratch my emacs configuration. But basically the problem was twofold:

NOTE: I am still using straight.el

  1. simple-httpd is transformed to emacs-webserver by straight.el, so, I needed to add this:
(straight-use-package '(simple-httpd :type git :host github :repo "skeeto/emacs-web-server" :local-repo "simple-httpd"))

(use-package zmq)

(use-package jupyter
  :after ob
  :demand t
  :requires (zmq simple-httpd)
   ...
  1. Sometimes straight,el was using org-mode 9.1, so I updated my emacs to have a org-mode 9.2 that also solved a lot of issues.

Thanks @dzop and @dangom for your useful tips and advices and your time!

@nnicandro
Copy link
Collaborator

simple-httpd is transformed to emacs-webserver by straight.el

That is confusing since the name of the package on MELPA is still simple-httpd. I wonder why straight.el opts for using the GitHub repo name instead of the package name for the local repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Related to personal configuration issues
Projects
None yet
Development

No branches or pull requests

3 participants