Ideas for troubleshooting emacs error: “apply: Spawning child process: exec format error”

做~自己de王妃 提交于 2019-12-08 07:54:36

问题


I'm trying to use rdebug with emacs and cygwin and I'm running into trouble. Whenever I do a M-x rdebug and give it the appropriate script to run, it stops with the error

 "apply: Spawning child process: exec format error"

From some googling, it seems like this could happen if I'm trying to launch a cygwin executable via the windows command prompt or vice versa. It could also happen if the path to the executable is a unix style link.

I'm trying to figure out the place where rdebug is being exec'd from to check which of these is the problem and how to fix it.

I've tried the following so far, but no joy: * Use edebug on rdebug and it's callees: That got me into gud-common-init and I quickly lost my way trying to find out where the exec call is happening. * Try switching the shell from cygwin to windows and back to see if there is any difference: no difference at all.

Note that I can run rdebug from my windows shell as well as from my cygwin shell (invoked via M-x shell). I'm guessing the /usr/bin/rdebug and /usr/bin/rdebug.bat have something to do with this.

Any ideas to fix this or to debug this issue would be really great.

Some progress

I managed to figure out that I can replicate the same problem with attempting to execute rdebug using comint-run (M-x comint-run ENTER rdebug ENTER). From some debugging and wading thru' the code, it looks like emacs is calling start-file-process (similar to the comint-run) to start the rdebug process.

I also have the following while loading up cygwin:

;;; Use `bash' as the default shell in Emacs.
(setq exec-path (cons  cygwin-bin exec-path))
(setq shell-file-name (concat cygwin-bin "/bash.exe")) ; Subprocesses invoked via the shell.
(setenv "SHELL" shell-file-name)
(setenv "PATH" (concat 
        (getenv "PATH") 
        (concat ";" (substring data-directory 0 2) "\\cygwin\\bin")) )
(setq explicit-shell-file-name shell-file-name) ; Interactive shell
(setq explicit-shell-args '("--login" "-i"))
(setq w32-quote-process-args ?\") ;; " 

More progress

Temporarily renaming rdebug.bat revealed that comint-run was invoking rdebug.bat via a dos shell. I'd like rdebug to be invoked via a bash shell when I invoke comint-run. Any ideas on how to specify which shell comint-run uses?


回答1:


I have the same problem and found the following simple workaround.

After entering M-x rdebug, it prompts the command to be executed. The following command is displayed as default setting:

Run rdebug (like this): rdebug --emacs 3 hanoi.rb

Modifying this command to:

Run rdebug (like this): ruby /usr/bin/rdebug --emacs 3 hanoi.rb

will be able to workaround the reported problem.



来源:https://stackoverflow.com/questions/2261071/ideas-for-troubleshooting-emacs-error-apply-spawning-child-process-exec-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!