emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* passing LC_ALL environment variable to org export call
@ 2014-09-26  9:14 Johannes Rainer
  2014-09-26 13:56 ` Rasmus
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Rainer @ 2014-09-26  9:14 UTC (permalink / raw)
  To: emacs-orgmode

dear all,

I stumbled across a strange problem. I’m using org-mode to perform analyses in R and I have one block of R-code in which I use mclapply to perform parallel calculations. evaluating this code block using C-c C-c works fine, but I get a segfault error when I export the org file.

This has to do something with the LC_ALL environment variable as I can reproduce the same error above in R in a terminal after “unset LC_ALL”.

Is there a way to pass environment variables to the export call?

thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: passing LC_ALL environment variable to org export call
  2014-09-26  9:14 passing LC_ALL environment variable to org export call Johannes Rainer
@ 2014-09-26 13:56 ` Rasmus
  2014-09-29 10:54   ` Johannes Rainer
  0 siblings, 1 reply; 5+ messages in thread
From: Rasmus @ 2014-09-26 13:56 UTC (permalink / raw)
  To: emacs-orgmode

Hi Johannes,

Johannes Rainer <johannes.rainer@gmail.com> writes:

> I stumbled across a strange problem. I’m using org-mode to perform
> analyses in R and I have one block of R-code in which I use mclapply
> to perform parallel calculations. evaluating this code block using C-c
> C-c works fine, but I get a segfault error when I export the org file.
>
> This has to do something with the LC_ALL environment variable as I can
> reproduce the same error above in R in a terminal after “unset
> LC_ALL”.
>
> Is there a way to pass environment variables to the export call?

Check the two functions `getenv' and `setenv' and the variable
`org-export-async-init-file'.  You should be able to cook something
up.

It sound like there's an issue with your system-setup.  I'd look into
that before.

Hope it helps,
Rasmus

-- 
Lasciate ogni speranza, voi che leggete questo.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: passing LC_ALL environment variable to org export call
  2014-09-26 13:56 ` Rasmus
@ 2014-09-29 10:54   ` Johannes Rainer
  2014-09-29 12:06     ` Rasmus
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Rainer @ 2014-09-29 10:54 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

hi Rasmus,

thanks for your hint. I checked Sys.getenv before and after the failing code, but LC_ALL was always properly set. I’m afraid my problem relates to some Mac LLVM and GCC gfortran compiler thing, since I’m using a R version compiled against the Mac Accelerate framework (vecLib)… it is just so strange that I only get the error in Emacs org-mode upon exporting the org file, but not, if I evaluate each code chunk separately.

to set all environment variables I’m using the “exec-path-from-shell” extension, so, all environment settings from the shell are available in Emacs.


 
On 26 Sep 2014, at 15:56, Rasmus <rasmus@gmx.us> wrote:

> Hi Johannes,
> 
> Johannes Rainer <johannes.rainer@gmail.com> writes:
> 
>> I stumbled across a strange problem. I’m using org-mode to perform
>> analyses in R and I have one block of R-code in which I use mclapply
>> to perform parallel calculations. evaluating this code block using C-c
>> C-c works fine, but I get a segfault error when I export the org file.
>> 
>> This has to do something with the LC_ALL environment variable as I can
>> reproduce the same error above in R in a terminal after “unset
>> LC_ALL”.
>> 
>> Is there a way to pass environment variables to the export call?
> 
> Check the two functions `getenv' and `setenv' and the variable
> `org-export-async-init-file'.  You should be able to cook something
> up.
> 
> It sound like there's an issue with your system-setup.  I'd look into
> that before.
> 
> Hope it helps,
> Rasmus
> 
> -- 
> Lasciate ogni speranza, voi che leggete questo.
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: passing LC_ALL environment variable to org export call
  2014-09-29 10:54   ` Johannes Rainer
@ 2014-09-29 12:06     ` Rasmus
  2014-09-29 12:51       ` Johannes Rainer
  0 siblings, 1 reply; 5+ messages in thread
From: Rasmus @ 2014-09-29 12:06 UTC (permalink / raw)
  To: emacs-orgmode

Johannes Rainer <johannes.rainer@gmail.com> writes:

> thanks for your hint. I checked Sys.getenv before and after the
> failing code, but LC_ALL was always properly set. I’m afraid my
> problem relates to some Mac LLVM and GCC gfortran compiler thing,
> since I’m using a R version compiled against the Mac Accelerate
> framework (vecLib)… it is just so strange that I only get the error in
> Emacs org-mode upon exporting the org file, but not, if I evaluate
> each code chunk separately.

But are you using .C, .Fortran or Rcpp in your code-block?  If not,
why would your compilers matter?  (I'm not an expert on R internals,
so my comment may be naïve).

As a short turn solution try to add this to the top of your file

#+PROPERTY: session *R*

These days you might even get away with just 

#+PROPERTY: session

I'm not sure.  This should run your code from the same session.

[This should be equivalent to adding :session to babel blocks, but
 check the manual if it ain't working]

> to set all environment variables I’m using the “exec-path-from-shell”
> extension, so, all environment settings from the shell are available
> in Emacs.

Are you exporting async or "normally"?  If async, do you get the error
when exporting "normally"?

—Rasmus

-- 
Hvor meget poesi tror De kommer ud af et glas isvand?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: passing LC_ALL environment variable to org export call
  2014-09-29 12:06     ` Rasmus
@ 2014-09-29 12:51       ` Johannes Rainer
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Rainer @ 2014-09-29 12:51 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode


On 29 Sep 2014, at 14:06, Rasmus <rasmus@gmx.us> wrote:

> Johannes Rainer <johannes.rainer@gmail.com> writes:
> 
>> thanks for your hint. I checked Sys.getenv before and after the
>> failing code, but LC_ALL was always properly set. I’m afraid my
>> problem relates to some Mac LLVM and GCC gfortran compiler thing,
>> since I’m using a R version compiled against the Mac Accelerate
>> framework (vecLib)… it is just so strange that I only get the error in
>> Emacs org-mode upon exporting the org file, but not, if I evaluate
>> each code chunk separately.
> 
> But are you using .C, .Fortran or Rcpp in your code-block?  If not,
> why would your compilers matter?  (I'm not an expert on R internals,
> so my comment may be naïve).
> 

no I’m not using .C in the code-block, the code block contains only R-code, however, one of the R functions is using (like most R functions) either C or fortran code to do the actual calculation. I suspect the loess function in R causing the problem and that this function uses some code from the optimized BLAS (i.e. library for numeric calculation) library from Apple (i.e. the Accelerate, or vecLib framework). 
So, if I run the code (exporting the org buffer to latex) in parallel processing mode I get a segfault. the same without parallel processing is fine. Strangely enough, the code block evaluated (C-c C-c) in parallel processing mode runs also fine. also, if I tangle the R-code and run the R-code in R it also works fine. It just doesn’t with org-mode export...

so, in the end I give up. I think there is some very mystic thing going on. I also tried to understand what the difference between org-mode export and org-mode eval is... without success. I thought that the R-process is somehow started differently, but that doesn’t seem to be the case.


> As a short turn solution try to add this to the top of your file
> 
> #+PROPERTY: session *R*
> 
> These days you might even get away with just 
> 
> #+PROPERTY: session
> 
> I'm not sure.  This should run your code from the same session.
> 
> [This should be equivalent to adding :session to babel blocks, but
> check the manual if it ain't working]
> 
>> to set all environment variables I’m using the “exec-path-from-shell”
>> extension, so, all environment settings from the shell are available
>> in Emacs.
> 
> Are you exporting async or "normally"?  If async, do you get the error
> when exporting "normally"?
> 
> —Rasmus
> 
> -- 
> Hvor meget poesi tror De kommer ud af et glas isvand?
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-29 12:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-26  9:14 passing LC_ALL environment variable to org export call Johannes Rainer
2014-09-26 13:56 ` Rasmus
2014-09-29 10:54   ` Johannes Rainer
2014-09-29 12:06     ` Rasmus
2014-09-29 12:51       ` Johannes Rainer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).