spacemacs icon indicating copy to clipboard operation
spacemacs copied to clipboard

Spacemacs and Cygwin

Open kevin-q2 opened this issue 4 years ago • 16 comments

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?

kevin-q2 avatar Dec 22 '20 18:12 kevin-q2

what's in your . spacemacs

lebensterben avatar Dec 22 '20 18:12 lebensterben

what's in your . spacemacs

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

kevin-q2 avatar Dec 22 '20 20:12 kevin-q2

do you have bash installed

lebensterben avatar Dec 22 '20 20:12 lebensterben

Yes bash is in the bin folder within cygwin

kevin-q2 avatar Dec 22 '20 20:12 kevin-q2

Yes bash is in the bin folder within cygwin

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

lebensterben avatar Dec 22 '20 21:12 lebensterben

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

kevin-q2 avatar Dec 22 '20 21:12 kevin-q2

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

@KevinQ152 Can you try the develop branch

lebensterben avatar Dec 22 '20 22:12 lebensterben

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/

kevin-q2 avatar Dec 22 '20 22:12 kevin-q2

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

lebensterben avatar Dec 22 '20 22:12 lebensterben

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

kevin-q2 avatar Dec 22 '20 22:12 kevin-q2

Have you tried --debug-init ?

lebensterben avatar Dec 22 '20 22:12 lebensterben

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()

kevin-q2 avatar Dec 22 '20 22:12 kevin-q2

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

alexey0308 avatar Dec 28 '20 10:12 alexey0308

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.

smile13241324 avatar Feb 21 '21 23:02 smile13241324

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.

wpmcbee avatar Mar 01 '21 02:03 wpmcbee

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

ttamttam avatar May 21 '21 17:05 ttamttam

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!

github-actions[bot] avatar May 29 '23 11:05 github-actions[bot]