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
Failed bootstrap when using proxychains-ng (Ubuntu 20.04). #786
Comments
Please include the output of |
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2021-05-16
How to obtain it? |
It should be in the *Messages* buffer, it would also be helpful to see the contents of the *straight-process* buffer if it exists. |
See below:
No this buffer at all. |
If you have your init file uploaded somewhere I can take a look at it for you. |
You can also try evaluating the following in your *scratch* buffer: (straight-bug-report) It will install straight in a clean, temporary environment. When it's done, the *straight-bug-report-process* buffer should pop up and you can copy the results here. |
Sorry for my poor understanding on Emacs. I try to input the above command in scratch buffer, and then
Do you mean that this will re-load the settings in |
With point after that expression run |
Can you link to your |
It looks like you're trying to use package.el alongside straight.el, which is not recommended. See: https://github.com/raxod502/straight.el#getting-started Note you'll want to follow the instructions about early-init.el, too, since you're on Emacs 28. What I would do is start with a minimal init file with just the straight bootstrap code and see if that works. |
The starting point of this issue is that I noticed the following snippet code: (use-package mathpix.el
:straight (:host github :repo "jethrokuan/mathpix.el")
:custom ((mathpix-app-id "app-id")
(mathpix-app-key "app-key"))
:bind
("C-x m" . mathpix-screenshot)) I'm currently mainly work with use-package which loads packages from (M)ELPA with As you can see, the above initialization code calls straight to install package from GitHub repo directly. If I don't use |
use-package's Straight replaces package.el. Generally you'd want to structure your init file something like this: ;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; Install use-package via straight
(straight-use-package 'use-package)
;; Setting this to `t' makes it so that you don't need to include the :straight
;; keyword in use-package declarations unless you want to add/extend the package
;; installation recipe.
(setq straight-use-package-by-default t) ; straight's equivalent of `use-package-always-ensure'.
;; For package listed in recipe repositories (such as MELPA), you can just do:
;; (use-package foo)
;; This expands to:
;; (progn
;; (straight-use-package 'foo)
;; (require 'foo nil nil))
;; For packages that aren't listed in a recipe repository, but are available at a forge (e.g. github):
(use-package mathpix.el :straight (:host github :repo "jethrokaun/mathpix.el"))
;; Which expands to:
;; (progn
;; (straight-use-package
;; '(mathpix\.el :host github :repo "jethrokaun/mathpix.el"))
;; (require 'mathpix\.el nil nil)) Does that help? |
If so, what should I change/revise them to, in order to obtain the same effect? |
See above: (setq straight-use-package-by-default t) ; straight's equivalent of `use-package-always-ensure'. Then you only need to add the Here are some examples: Using package.el: (setq use-package-always-ensure nil)
(use-package foo :ensure t) Converted to use straight.el: (setq straight-use-package-by-default nil)
(use-package foo :straight t) But for convenience sake, you probably want to install by default. Using package.el: (setq use-package-always-ensure t)
(use-package foo) Converted to use straight.el: (setq straight-use-package-by-default t)
(use-package foo) Does that make sense? |
Wonderful explanations. I will try it according to your comments and give the necessary feedback. Another thing I don't understand is the notes described here: To use the MELPA repository, you'll need an Emacs with package.el and TLS support, ie. Emacs 24.1 or greater.
So, it seems that the the MELPA repository depends on |
You don't need to do any of that to use straight. Those are instructions geared toward using the built-in package manager, package.el. Straight has its own support for MELPA. Use the bootstrap code to install straight: (defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage)) Then start installing the packages you want from MELPA via
That's all you have to do. https://github.com/raxod502/straight.el/tree/develop#where-do-recipes-come-from |
Thank you again for your excellent and comprehensive answer. Once I have time, I will try as soon as possible. |
I tried with the following minimal version of
The testing command and the error info for this specific init-file are shown below:
|
Remove this: (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(package-initialize) package.el is not compatible with straight |
Still failed, see following:
Test the above init file with the following command:
And failed with the message below:
|
We need to be able to see the full error. (let ((backtrace-line-length 0))
;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)) |
See the following:
|
It looks like something is going wrong when we try to clone straight.el with git. Is there a *straight-process-buffer* after this error which you can switch to? |
I tried the following versions of git compiled by myself, and they all reported the same error
See below:
Do you mean the Debugger or Backtrace drop-down menus shown below:
I'm still not so clear what I should and can do. |
Try evaluating the following in your *scratch* buffer and copy the output (which should show up in the *Messages* buffer) here: (shell-command-to-string "git --version") Curious whether or not Emacs is able to locate the proper version of git. |
Thank you. So lets try to manually execute the git command that seems to fail. (call-process "git" nil "*git-command*" 'display "clone" "--origin" "origin" "--no-checkout" "https://github.com/raxod502/straight.el.git" "/tmp/werner/.emacs.d/straight/repos/straight.el/") This should clone straight into |
See below: This gives me some clues. In my case, I run Emacs by proxychains-ng with a locally set socks5 proxy:
The reason may be that |
Here's a related issue: #665 I don't think this is too similar, though, as users in that issue were running Windows.
I'm not sure if there's anything we can do on straight's end to remedy this. |
Some further tries and conclusions:
The installation progress will generate the following directory tree:
|
Some further tries with the following init file:
When using proxychains-ng, both the self compiled emacs and the system repo version of Emacs failed as shown below. Self compiled Emacs:
Emacs version comes with system repo:
If I don't wrap the transmission with |
Considering that I can use both |
Got it. The reason why git fails when using
This will cause some confliction when we call git from within Emacs started through
So, the dirty and quick workaround in my case is below: disable the git proxy settings when it's called in the Emacs. |
Nice work! Does it work for both versions of Emacs you have installed? |
Yes. As far as bootstrapping So the problem/fix is: how to disable the git proxy settings temporarily when it's called in Emacs started though Any hints to do the above job in Emacs way? |
Elisp has a concept of "advice" which can be used to alter the behavior of functions: https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html You could write advice that wraps around our commands, checks to see if the process being called is "git" and disables the proxy settings for that command only. What command do you use to disable the proxy settings? |
The following command is enough in this case:
After the above command is executed, Emacs will bootstrap
More specifically, the above-mentioned Emacs wrapper script has some content similar to the following:
|
You could do something like the following: (defun straight--process-call@disable-git-proxy
(fn &rest args)
"Disable proxy when calling git commands."
(let ((program
(car args)))
(when (string= program "git")
;;replace this with the command to unset the proxy
(message "unset proxy"))
(apply fn args)
(when (string= program "git")
;;replace this with the call to reset the proxy
(message "reset proxy"))))
(advice-add 'straight--process-call :around
(function straight--process-call@disable-git-proxy)) calling a shell command can be done via the (shell-command "git config --global --unset http.proxy") That way anytime straight starts a git process, your proxy will be disabled. |
I am absolutely a new hand of Lisp. Let me try to adapt the sample code above to my case:
I tried by adding the above code snippet at the beginning of my testing initialization file but meet the following error:
Based on my testing, this one can do the trick and be viewed as a brute, quick and dirty alternative to above more graceful solution.
If, in my case, the problem is handled from the wrapper script, the following is another alternative workaround:
|
I would recommend against advising You could also add something like: (shell-command "git config --global --unset http.proxy") To the beginning of your init file and then (shell-command "git config --global http.proxy socks5h://127.0.0.1:18888") At the end of the file. Though you'd probably want to wrap that using https://www.gnu.org/software/emacs/manual/html_node/elisp/Cleanups.html Looks like you've found the root of the problem and a number of possible solutions, so I'll consider this issue closed. Best of luck with it. |
I tried to run (shell-command "git config --global --unset http.proxy")
(defun straight--process-call@disable-git-proxy
(fn &rest args)
"Disable proxy when calling git commands."
(let ((program
(car args)))
(when (string= program "git")
;;replace this with the command to unset the proxy
(message "unset proxy"))
(apply fn args)
(when (string= program "git")
;;replace this with the call to reset the proxy
(message "reset proxy"))))
(advice-add 'straight--process-call :around
(function straight--process-call@disable-git-proxy))
;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(shell-command "git config --global http.proxy socks5h://127.0.0.1:18888") But I meet the following in
And the following in
|
Do you have the Try evaluating: (executable-find "find") |
Try removing the advice: (shell-command "git config --global --unset http.proxy")
;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t))
(shell-command "git config --global http.proxy socks5h://127.0.0.1:18888") |
You above suggested code works.
There is a redundant ending
The complete ; Use the following commands to test the automatic installation of flycheck package with use-package via straight.
;$ rm -fr ~/.emacs.d/straight/repos/flycheck/
;$ emacs -q --load ~/.emacs.d/init.el.straight
(shell-command "git config --global --unset http.proxy")
;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(use-package flycheck)
(shell-command "git config --global http.proxy socks5h://127.0.0.1:18888") PS. The more elegant and efficient method for solving this problem is setting the |
Perhaps we need to invest some effort into making the bootstrap process robustly report full error messages by default. This has been an issue for years due to how I designed the thing in the first place (where errors happen within a subprocess, thus get swallowed). |
Must the |
Same effect either way, since periods are allowed by default in symbol names. |
On Ubuntu 20.04, I'm using the git master version of Emacs compiled by me. Now, I try to use
straight.el
anduse-package
at the same time. According to the instruction here, I place the following bootstrap code in my~/.emacs.d/init.el
:When I try to start Emacs, I meet the following errors:
Any hints for solving this problem?
Regards,
HY
The text was updated successfully, but these errors were encountered: