6

I removed my .emacs and .emacs.d, then created a new .emacs consisting of only the essential to use R and a shell with org-babel to make sure my configs weren't causing this:

(require 'org-install)
(org-babel-do-load-languages
 'org-babel-load-languages
 '(
   (sh . t)
   (R . t)
   ))

When I try to run the following snippet:

#+begin_src R :results output verbatim
(any R code)
#+end_src

It runs just fine. However, if I add :session or :session name to the #+begin_src header, Emacs freezes. I can't move the cursor nor do anything. I can see both R and Emacs on htop, none using any CPU. The only way to get out is to send SIGTERM to Emacs.

When running the snippet with C-c the minibuffer says:

ESS (*R*, R (newest)) starting data directory? pwd (I say yes)
Cannot read history file pwd/.Rhistory

This is normal, I get it on other computers where Emacs doesn't freeze. Then hangs forever on

ess-tracebug mode enabled

Also normal. Except the hanging forever part.

A similar issue occurs with sh snippets:

#+begin_src sh :results output verbatim
echo
#+end_src

Works fine. So with :session. However, with :session name it hangs forever just like R. All the minibuffer says is

Wrote /tmp/babel-XXXXX

And then hangs forever on

executing sh code block...

All packages (emacs, ess, org-mode) are the latest version from Debian stable repos. I have other computers with the same setup that work just fine. emacs --version returns GNU Emacs 24.4.1. The same happened in previous versions, and I also tried downloading Emacs 24.5.1 from a GNU mirror and compiling it. The exact same thing happens. I'm completely lost as to what could be causing this.

P.S.:

Also tried downloading latest stable ess and org-mode from the respective websites and installing and configuring for the compiled emacs. Added

(add-to-list 'load-path "/path/to/emacs-24.5/b/share/emacs/site-lisp/ess")
(load "ess-site") 

To .emacs as per ess' README

  • A bug report like this might have better luck on the Org mailing list than on this general emacs SE site. – mankoff Jan 21 '16 at 14:05
2
mv ~/.Rprofile{,.bak}
mv .RData{,bak}

I think the issue is a nonstandard options('prompt'). I (re)moved ~/.Rpofile and the .RData file for the working directory of the session and no longer had the blocking/endless waiting/frozen issue.

prompt as an issue also showed up when octave's default prompt changed: https://stackoverflow.com/questions/27742075/emacs-freezes-when-running-an-octave-code-block-within-org-mode

setting my prompt is now pretty complicated

.First <- function(...){
    updatePrompt <- function(...) {
      # Emacs Speaks Stats, use default prompt
      if(options('STERM')=='iESS') 
           options(prompt="> "); 
      # Rstudio -- time but no colors
      else if( any(grepl("RStudio", .libPaths())) )
           options(prompt=format(Sys.time(), "\n# %X\n#> "))
      # command line R
      else 
            options(prompt=format(Sys.time(),
                            "\n\e[38;5;197m# \e[38;5;27m%X\e[0;0m\n "))
      return(TRUE)
    }

    # add prompt if we're in interactive mode
    if(interactive()) { 
     addTaskCallback(updatePrompt)
     updatePrompt()
    }
 }

https://github.com/LabNeuroCogDevel/dotfiles/blob/master/Rprofile/.Rprofile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.