syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.67k stars 4.89k forks source link

Spacemacs and Cygwin #14232

Closed kevin-q2 closed 8 months ago

kevin-q2 commented 3 years ago

I'm trying to set up Spacemacs so that it works from within Cygwin but I get this warning when starting the program:

Warning (initialization): An error occurred while loading ‘c:/cygwin64/home/user/.emacs.d/init.el’:

File is missing: Searching for program, No such file or directory, /bin/bash

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

Cygwin is on my path and I think I have the HOME variable set correctly. So I'm not sure what I'm doing wrong. Is it possible I cloned spacemacs into the wrong directory?

lebensterben commented 3 years ago

what's in your . spacemacs

kevin-q2 commented 3 years ago

what's in your . spacemacs

It's exactly the same as the one cloned from the repository. Haven't changed anything

lebensterben commented 3 years ago

do you have bash installed

kevin-q2 commented 3 years ago

Yes bash is in the bin folder within cygwin

lebensterben commented 3 years ago

Yes bash is in the bin folder within cygwin

@KevinQ152 Without configs from spacemacs, could Emacs start correctly? Also, are you on develop branch?

kevin-q2 commented 3 years ago

Yes emacs works fine and no I am on the normal branch

lebensterben commented 3 years ago

Yes emacs works fine and no I am on the normal branch

@KevinQ152 Can you try the develop branch

kevin-q2 commented 3 years ago

Hmm that didn't work either. I found this post on reddit where the person said they fixed the same issue by hardcoding the shell name into the init file. But I'm not sure how I would do that. Any ideas?

https://www.reddit.com/r/spacemacs/comments/66o5u6/when_i_start_spacemacs_in_win_7_with_cygwin/

lebensterben commented 3 years ago

Hmm that didn't work either. I found this post on reddit where the person said they fixed the same issue by hardcoding the shell name into the init file. But I'm not sure how I would do that. Any ideas? ...

@KevinQ152 I did a search on the source code but cannot find things that mentioned "bash" or "/bin/bash" in core

kevin-q2 commented 3 years ago

It does seem to be working fine when I use it from the windows command prompt. But I still get the error in cygwin. So I'll keep looking

lebensterben commented 3 years ago

Have you tried --debug-init ?

kevin-q2 commented 3 years ago

Yes this is the error I got:

Debugger entered--Lisp error: (file-missing "Searching for program" "No such file or directory" "/bin/bash")
  call-process("/bin/bash" nil t nil "-c" "c:/WINDOWS/system32/timeout.exe --help")
  apply(call-process "/bin/bash" nil t nil ("-c" "c:/WINDOWS/system32/timeout.exe --help"))
  process-file("/bin/bash" nil t nil "-c" "c:/WINDOWS/system32/timeout.exe --help")
  shell-command-to-string("c:/WINDOWS/system32/timeout.exe --help")
  (string-match-p "^ *-k" (shell-command-to-string (concat prog " --help")))
  (and prog (string-match-p "^ *-k" (shell-command-to-string (concat prog " --help"))))
  (if (and prog (string-match-p "^ *-k" (shell-command-to-string (concat prog " --help")))) (progn prog))
  (when (and prog (string-match-p "^ *-k" (shell-command-to-string (concat prog " --help")))) prog)
  (let ((prog (or (executable-find "timeout") (executable-find "gtimeout")))) (when (and prog (string-match-p "^ *-k" (shell-command-to-string (concat prog " --help")))) prog))
  eval((let ((prog (or (executable-find "timeout") (executable-find "gtimeout")))) (when (and prog (string-match-p "^ *-k" (shell-command-to-string (concat prog " --help")))) prog)))
  custom-initialize-reset(quelpa-build-timeout-executable (let ((prog (or (executable-find "timeout") (executable-find "gtimeout")))) (when (and prog (string-match-p "^ *-k" (shell-command-to-string (concat prog " --help")))) prog)))
  custom-declare-variable(quelpa-build-timeout-executable (let ((prog (or (executable-find "timeout") (executable-find "gtimeout")))) (when (and prog (string-match-p "^ *-k" (shell-command-to-string (concat prog " --help")))) prog)) "Path to a GNU coreutils \"timeout\" command if available.\nThis must be a version which supports the \"-k\" option." :type (file :must-match t))
  eval-buffer(#<buffer  *load*-768927> nil "c:/cygwin64/home/user/.emacs.d/core/libs/quelpa.el" nil t)  ; Reading at buffer position 15355
  load-with-code-conversion("c:/cygwin64/home/user/.emacs.d/core/libs/quelpa.el" "c:/cygwin64/home/user/.emacs.d/core/libs/quelpa.el" nil t)
  require(quelpa)
  configuration-layer//configure-quelpa()
  (let ((display-buffer-alist (quote (("\\(\\*Compile-Log\\*\\)\\|\\(\\*Warnings\\*\\)" (display-buffer-in-side-window) (inhibit-same-window . t) (side . bottom) (window-height . 0.2)))))) (configuration-layer//configure-quelpa) (let* ((upkg-names (configuration-layer//get-uninstalled-packages packages)) (not-inst-count (length upkg-names)) installed-count) (if upkg-names (progn (spacemacs-buffer/set-mode-line "Installing packages..." t) (let ((delayed-warnings-backup delayed-warnings-list)) (spacemacs-buffer/append (format "Found %s new package(s) to install...\n" not-inst-count)) (configuration-layer/retrieve-package-archives) (setq installed-count 0) (spacemacs//redisplay) (let ((--dolist-tail-- upkg-names) pkg-name) (while --dolist-tail-- (setq pkg-name ...) (let ... ...) (setq --dolist-tail-- ...))) (let ((--dolist-tail-- upkg-names) pkg-name) (while --dolist-tail-- (setq pkg-name ...) (let ... ...) (setq --dolist-tail-- ...))) (spacemacs-buffer/append "\n") (if init-file-debug nil (setq delayed-warnings-list delayed-warnings-backup)))))))
  configuration-layer//install-packages((ace-jump-helm-line ace-link ace-window aggressive-indent async auto-compile auto-highlight-symbol avy bind-key bind-map centered-cursor-mode clean-aindent-mode column-enforce-mode define-word desktop devdocs diminish dired-quick-sort dotenv-mode dumb-jump editorconfig elisp-slime-nav emr eval-sexp-fu evil evil-anzu evil-args evil-cleverparens evil-easymotion evil-ediff evil-escape evil-exchange evil-goggles evil-iedit-state evil-indent-plus evil-lion evil-lisp-state evil-matchit evil-mc evil-nerd-commenter evil-numbers evil-surround evil-textobj-line evil-tutor evil-unimpaired evil-visual-mark-mode evil-visualstar expand-region eyebrowse fancy-battery ...))
  (let ((packages (append (configuration-layer//filter-distant-packages configuration-layer--used-packages t (quote (not (oref pkg :lazy-install)))) (if (eq (quote all) dotspacemacs-install-packages) (progn (let (all-other-packages) (let ... ...) (configuration-layer//filter-distant-packages all-other-packages nil))))))) (configuration-layer//install-packages packages) (if (and (or (eq (quote used) dotspacemacs-install-packages) (eq (quote used-only) dotspacemacs-install-packages)) (not configuration-layer-force-distribution) (not configuration-layer-exclude-all-layers)) (progn (configuration-layer/delete-orphan-packages packages))))
  (progn (let ((packages (append (configuration-layer//filter-distant-packages configuration-layer--used-packages t (quote (not ...))) (if (eq (quote all) dotspacemacs-install-packages) (progn (let ... ... ...)))))) (configuration-layer//install-packages packages) (if (and (or (eq (quote used) dotspacemacs-install-packages) (eq (quote used-only) dotspacemacs-install-packages)) (not configuration-layer-force-distribution) (not configuration-layer-exclude-all-layers)) (progn (configuration-layer/delete-orphan-packages packages)))))
  (if spacemacs-sync-packages (progn (let ((packages (append (configuration-layer//filter-distant-packages configuration-layer--used-packages t (quote ...)) (if (eq ... dotspacemacs-install-packages) (progn ...))))) (configuration-layer//install-packages packages) (if (and (or (eq (quote used) dotspacemacs-install-packages) (eq (quote used-only) dotspacemacs-install-packages)) (not configuration-layer-force-distribution) (not configuration-layer-exclude-all-layers)) (progn (configuration-layer/delete-orphan-packages packages))))))
  configuration-layer//load()
  (cond (changed-since-last-dump-p (configuration-layer//load) (if (spacemacs/emacs-with-pdumper-set-p) (progn (configuration-layer/message "Layer list has changed since last dump.") (configuration-layer//dump-emacs)))) (spacemacs-force-dump (configuration-layer//load) (if (spacemacs/emacs-with-pdumper-set-p) (progn (configuration-layer/message (concat "--force-dump passed on the command line or configuration has " "been reloaded, forcing a redump.")) (configuration-layer//dump-emacs)))) ((spacemacs-is-dumping-p) (configuration-layer//load)) ((and (spacemacs/emacs-with-pdumper-set-p) (spacemacs-run-from-dump-p)) (configuration-layer/message "Running from a dumped file. Skipping the loading process!")) (t (configuration-layer//load) (if (spacemacs/emacs-with-pdumper-set-p) (progn (configuration-layer/message (concat "Layer list has not changed since last time. " "Skipping dumping process!"))))))
  configuration-layer/load()
  (let ((file-name-handler-alist nil)) (require (quote core-spacemacs)) (spacemacs/dump-restore-load-path) (configuration-layer/load-lock-file) (spacemacs/init) (configuration-layer/stable-elpa-init) (configuration-layer/load) (spacemacs-buffer/display-startup-note) (spacemacs/setup-startup-hook) (spacemacs/dump-eval-delayed-functions) (if (and dotspacemacs-enable-server (not (spacemacs-is-dumping-p))) (progn (require (quote server)) (if dotspacemacs-server-socket-dir (progn (setq server-socket-dir dotspacemacs-server-socket-dir))) (if (server-running-p) nil (message "Starting a server...") (server-start)))))
  (if (not (version<= spacemacs-emacs-min-version emacs-version)) (error (concat "Your version of Emacs (%s) is too old. " "Spacemacs requires Emacs version %s or above.") emacs-version spacemacs-emacs-min-version) (let ((file-name-handler-alist nil)) (require (quote core-spacemacs)) (spacemacs/dump-restore-load-path) (configuration-layer/load-lock-file) (spacemacs/init) (configuration-layer/stable-elpa-init) (configuration-layer/load) (spacemacs-buffer/display-startup-note) (spacemacs/setup-startup-hook) (spacemacs/dump-eval-delayed-functions) (if (and dotspacemacs-enable-server (not (spacemacs-is-dumping-p))) (progn (require (quote server)) (if dotspacemacs-server-socket-dir (progn (setq server-socket-dir dotspacemacs-server-socket-dir))) (if (server-running-p) nil (message "Starting a server...") (server-start))))))
  eval-buffer(#<buffer  *load*> nil "c:/cygwin64/home/user/.emacs.d/init.el" nil t)  ; Reading at buffer position 1880
  load-with-code-conversion("c:/cygwin64/home/user/.emacs.d/init.el" "c:/cygwin64/home/user/.emacs.d/init.el" t t)
  load("c:/cygwin64/home/user/.emacs.d/init" t t)
  #f(compiled-function () #<bytecode 0x1000baab9>)()
  command-line()
  normal-top-level()
alexey0308 commented 3 years ago

Do you run emacs from within a cygwin shell? I.e. by typing in the cygwin shell emacs & If it does not help, try to set

(setq shell-file-name "bash")
(setq explicit-shell-file-name shell-file-name)

See https://stackoverflow.com/a/235344

smile13241324 commented 3 years ago

You should also make sure that emacs can see bash, i.e. when you start vanilla emacs are you able to call bash from within emacs? If you can its an issue in your spacemacs.env file, where env variables are stored for fixed use in Spacemacs. This file is automatically created when spacemacs is called the first time but must sometimes be corrected manually in case wrong settings have been added. Maybe the path in there is not up-to-date.

Apart from this I have also run through the emacs in cygwin phase but gave up on it as it proved to be too unstable and slow for my use. My current setup on windows is running emacs in Docker sending the screen through an ssh tunnel to a local X server which is run in cygwin, this setup works much more stable than a pure cygwin solution.

wpmcbee commented 3 years ago

I believe the two PRs I submitted will fix most of this issue. There may still be a problem if Emacs is started in daemon mode, since it appears that spacemacs/load-spacemacs-env neither creates nor reads spacemacs.env in that case.

ttamttam commented 3 years ago

I believe the two PRs I submitted will fix most of this issue. There may still be a problem if Emacs is started in daemon mode, since it appears that spacemacs/load-spacemacs-env neither creates nor reads spacemacs.env in that case.

Unfortunately, it seems that they did not fix this problem. I observe the same behavior than the original poster, when trying to start emacs from one cygwin shell, with a freshly cloned .emacs.d (with your patches applied).

The solution proposed by @alexey0308 just above (adding those two incantations at the beginning of init.el) solves the problem though.

Best regards

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!