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

Poetry-mode runtime error. env: unknown option --u #44

Open
anoduck opened this issue Mar 30, 2023 · 11 comments
Open

Poetry-mode runtime error. env: unknown option --u #44

anoduck opened this issue Mar 30, 2023 · 11 comments

Comments

@anoduck
Copy link

anoduck commented Mar 30, 2023

It would be nice if you could define the poetry executable for this package, and/or how it is called. The full output of the error is:

env: unknown option -- u
usage: env [-i] [name=value ...] [utility [argument ...]]

This error arose from OpenBSD not using the gnu implementation of env, in which for gnu the -u flag is valid. Where as for the nongnu derivative of env, -u is not valid.

Adding an alias to my shell and see if that clears up the issue.

@yukiteruamano
Copy link
Contributor

yukiteruamano commented Aug 6, 2023

Hi!

Same error detected here, relevant bits here:

(let* ((prog (or (concat "env -i VIRTUAL_ENV " (executable-find "poetry"))
                     (poetry-error "Could not find 'poetry' executable")))

Working in a fix for this (and learning lisp in the process).

Edit: related with this commit: 93c9b24.

@yukiteruamano
Copy link
Contributor

It would be nice if you could define the poetry executable for this package, and/or how it is called. The full output of the error is:

env: unknown option -- u
usage: env [-i] [name=value ...] [utility [argument ...]]

This error arose from OpenBSD not using the gnu implementation of env, in which for gnu the -u flag is valid. Where as for the nongnu derivative of env, -u is not valid.

Adding an alias to my shell and see if that clears up the issue.

PR #48 is up, test the new code and verify if work correctly in your system. In my case, all is OK.

@anoduck
Copy link
Author

anoduck commented Aug 6, 2023

@yukiteruamano elisp is difficult, there is little doubt to that.

Whew...that was sketchy there for a minute. I haven't had to autoload a package in a while.

Still receiving the same error. poetry-error: [my project] Could not find ’poetry’ executable

If it helps, because OpenBSD is a bitch, you have to keep your distribution files pristine or bad things will happen. Also, since there is no package for poetry yet, this mean you have to perform a --user install. Which will place poetry in either ~/.local/bin/poetry or ~/.local/pipx/bin/poetry if using pipx. Both use the shell configuration file to add the bin folders to $PATH, which is why Emacs is experiencing difficulty resolving the path.

Where is your poetry bin file located? If it is the same as those mentioned above. Then I will need to work out why it is not finding it.

@yukiteruamano
Copy link
Contributor

yukiteruamano commented Aug 6, 2023

@yukiteruamano elisp is difficult, there is little doubt to that.

Whew...that was sketchy there for a minute. I haven't had to autoload a package in a while.

Still receiving the same error. poetry-error: [my project] Could not find ’poetry’ executable

If it helps, because OpenBSD is a bitch, you have to keep your distribution files pristine or bad things will happen. Also, since there is no package for poetry yet, this mean you have to perform a --user install. Which will place poetry in either ~/.local/bin/poetry or ~/.local/pipx/bin/poetry if using pipx. Both use the shell configuration file to add the bin folders to $PATH, which is why Emacs is experiencing difficulty resolving the path.

Where is your poetry bin file located? If it is the same as those mentioned above. Then I will need to work out why it is not finding it.

Hi!

Using OpenBSD 7.3-release here, my poetry bin is in $HOME/.local/bin/poetry

Doom Emacs updated and not problem with this change, detect Poetry VIRTUAL_ENV and don't show errors. Tested with waifu2x python version.

Edit: screencap.

@anoduck
Copy link
Author

anoduck commented Aug 8, 2023

@yukiteruamano Well, that sucks. I am cleaning up my configuration after updating to 29.1, and going over any python variables. Will see if anything is uncovered.

Have you tried vanilla emacs?

@anoduck
Copy link
Author

anoduck commented Aug 8, 2023

@yukiteruamano I really really really (that is three) appreciate you taking over maintaining this project. It plays such a vital role in development of python applications.

I know enough (or once did) ELisp to walk through the function of locating the poetry binary, which is what I will do, and see if I can get it to talk to me about hangups. In the meantime, I have enabled debugging and will post the debug output below.

 signal(error ("[erome scraper] Could not find ’poetry’ executable"))
  error("[%s] %s" "erome scraper" "Could not find ’poetry’ executable")
  poetry-error("Could not find 'poetry' executable")
  (or (cond ((eq system-type 'gnu/linux) (concat "env -u VIRTUAL_ENV " (executable-find "poetry"))) ((eq system-type 'berkeley-unix) (executable-find "poetry"))) (poetry-error "Could not find 'poetry' executable"))
  (let* ((prog (or (cond ((eq system-type 'gnu/linux) (concat "env -u VIRTUAL_ENV " (executable-find "poetry"))) ((eq system-type 'berkeley-unix) (executable-find "poetry"))) (poetry-error "Could not find 'poetry' executable"))) (args (if (or (string= command "run") (string= command "config") (string= command "env") (string= command "init")) (cl-concatenate 'list (list (symbol-name command)) args) (cl-concatenate 'list (list (symbol-name command) "-n" "--ansi") args)))) (let ((compilation-buffer-name-function #'(lambda (_mode) (poetry-buffer-name))) (compilation-ask-about-save nil) (compilation-save-buffers-predicate #'(lambda nil nil))) (let ((wconfig (current-window-configuration))) (unwind-protect (progn (compile (concat prog " " (string-join args " ")))) (set-window-configuration wconfig))) (save-current-buffer (set-buffer (poetry-buffer-name)) (add-hook 'after-change-functions #'(lambda (beg end _len) (ansi-color-apply-on-region beg end)) nil t) (set (make-local-variable 'compilation-finish-functions) (append compilation-finish-functions (list #'poetry--clean-compilation-buffer #'poetry--indicate-compilation-end #'poetry--run-next-call-from-queue)))) (setq poetry-process (get-buffer-process (get-buffer (poetry-buffer-name)))) (if blocking (progn (while (eq (process-status poetry-process) 'run) (sleep-for 0.1)))) (if output (save-current-buffer (set-buffer (poetry-buffer-name)) (let ((new-name (poetry-buffer-name "output"))) (if (get-buffer new-name) (progn (kill-buffer new-name))) (poetry-display-buffer (rename-buffer new-name)) new-name)) (poetry-buffer-name))))
  (let ((default-directory (or project (poetry-find-project-root) default-directory))) (if (member command '(new init config)) nil (poetry-ensure-in-project)) (let* ((prog (or (cond ((eq system-type ...) (concat "env -u VIRTUAL_ENV " ...)) ((eq system-type ...) (executable-find "poetry"))) (poetry-error "Could not find 'poetry' executable"))) (args (if (or (string= command "run") (string= command "config") (string= command "env") (string= command "init")) (cl-concatenate 'list (list (symbol-name command)) args) (cl-concatenate 'list (list (symbol-name command) "-n" "--ansi") args)))) (let ((compilation-buffer-name-function #'(lambda (_mode) (poetry-buffer-name))) (compilation-ask-about-save nil) (compilation-save-buffers-predicate #'(lambda nil nil))) (let ((wconfig (current-window-configuration))) (unwind-protect (progn (compile (concat prog " " ...))) (set-window-configuration wconfig))) (save-current-buffer (set-buffer (poetry-buffer-name)) (add-hook 'after-change-functions #'(lambda (beg end _len) (ansi-color-apply-on-region beg end)) nil t) (set (make-local-variable 'compilation-finish-functions) (append compilation-finish-functions (list #'poetry--clean-compilation-buffer #'poetry--indicate-compilation-end #'poetry--run-next-call-from-queue)))) (setq poetry-process (get-buffer-process (get-buffer (poetry-buffer-name)))) (if blocking (progn (while (eq (process-status poetry-process) 'run) (sleep-for 0.1)))) (if output (save-current-buffer (set-buffer (poetry-buffer-name)) (let ((new-name ...)) (if (get-buffer new-name) (progn ...)) (poetry-display-buffer (rename-buffer new-name)) new-name)) (poetry-buffer-name)))))
  poetry-do-call(show nil nil nil t)
  (if (poetry--busy-p) (add-to-list 'poetry-call-queue (list command args (or project (poetry-find-project-root)) output blocking) t) (poetry-do-call command args project output blocking))
  poetry-call(show nil nil nil t)
  (let ((compbufname (poetry-call 'show nil nil nil t))) (save-current-buffer (set-buffer compbufname) (let (packs) (while (re-search-forward "^\\(.+\\)$" nil t) (setq packs (cons (match-string 1) packs))) packs)))
  poetry-show-get-packages()
  (completing-read "Package: " (poetry-show-get-packages))
  (list (completing-read "Package: " (poetry-show-get-packages)))
  call-interactively(poetry-show nil nil)
  command-execute(poetry-show)

@yukiteruamano
Copy link
Contributor

My knowledge of Elisp is minimal, in fact, I am a new Emacs user, so the experience is not much.

However, let me reproduce this on other Emacs installations (Spacemacs, to be precise)

@anoduck
Copy link
Author

anoduck commented Aug 11, 2023

@yukiteruamano I got it sorted...finally...I think... My (exec-path) is all buggered up, somehow. Thankfully, it works.

It Works!

@anoduck anoduck closed this as completed Aug 17, 2023
@anoduck
Copy link
Author

anoduck commented Dec 23, 2023

The error has returned, and it does not appear the previous method of designating a different means to activate poetry is no longer working.

The block of code begins on line 683, and is as follows.

(let* ((prog
	(or
	 (cond ((eq system-type 'gnu/linux)
                (concat "env -u VIRTUAL_ENV " (executable-find "poetry" t)))
               ((eq system-type 'berkeley-unix)
                (executable-find "poetry" t)))
         (poetry-error "Could not find 'poetry' executable")))
       (args (if (or (string= command "run")
                     (string= command "config")
                     (string= command "env")
                     (string= command "init"))
                 (cl-concatenate 'list (list (symbol-name command))
                                 args)
               (cl-concatenate 'list (list
                                      (symbol-name command)
                                      "-n" "--ansi")
                               args))))
  )

I am not sure if an update kicked out previous errors or what. Let me know how I can assists.

@anoduck anoduck reopened this Dec 23, 2023
@cybniv
Copy link
Owner

cybniv commented Jan 3, 2024

@anoduck What's your value of system-type variable?

You can check in your Emacs with describe-variable function.

@anoduck
Copy link
Author

anoduck commented Jan 4, 2024

@anoduck What's your value of system-type variable?

You can check in your Emacs with describe-variable function.

Fascinating stuff...

(describe-variable 'system-type)
#("system-type is a variable defined in ‘C source code’.

Its value is ‘berkeley-unix’

The value is a symbol indicating the type of operating system you are using.
Special values:
  ‘gnu’          compiled for a GNU Hurd system.
  ‘gnu/linux’    compiled for a GNU/Linux system.
  ‘gnu/kfreebsd’ compiled for a GNU system with a FreeBSD kernel.
  ‘darwin’       compiled for Darwin (GNU-Darwin, macOS, ...).
  ‘ms-dos’       compiled as an MS-DOS application.
  ‘windows-nt’   compiled as a native W32 application.
  ‘cygwin’       compiled using the Cygwin library.
  ‘haiku’        compiled for a Haiku system.
Anything else (in Emacs 26, the possibilities are: aix, berkeley-unix,
hpux, usg-unix-v) indicates some sort of Unix system.

  Probably introduced at or before Emacs version 19.31.

" 38 51 (help-args (system-type C-source) category help-variable-def-button button (t)) 786 791 (button (t) category help-news-button help-args ("/usr/local/share/emacs/29.1/etc/NEWS.19" 22544)))

Emacs is beautiful, isn't it?

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