# Julia print commands not working in emacs org-mode

**URL:** <https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944>\
**Category:** General Usage\
**Created:** [November 7, 2017, 8:34pm UTC](https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944 "2017-11-07T20:34:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shuvomoy\_Das\_Gupta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuvomoy_das_gupta/32/10069_2.png) [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Post date:** [November 7, 2017, 8:34pm UTC](https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944/1 "2017-11-07T20:34:55Z")

</div>

Dear All,

I am trying to run julia in emacs org-mode by following the instructions at [https://github.com/JuliaEditorSupport/julia-emacs](https://github.com/JuliaEditorSupport/julia-emacs). Everything seems to be working except print commands.

If I have the following source block:

```julia
#+BEGIN_SRC julia
a=[1;2;3];
b=[3;4;5];
c=a+b;
print(c)
#+END_SRC

```

Then I get the following error:

```julia
ERROR: MethodError: no method matching start(::Void)
Closest candidates are:
  start(!Matched::SimpleVector) at essentials.jl:258
  start(!Matched::Base.MethodList) at reflection.jl:560
  start(!Matched::ExponentialBackOff) at error.jl:107
  ...
Stacktrace:
 [1] #writedlm#18(::Array{Any,1}, ::Function, ::IOStream, ::Void, ::Char) at ./datafmt.jl:673
 [2] #20 at ./datafmt.jl:683 [inlined]
 [3] open(::Base.DataFmt.##20#21{Array{Any,1},Void,Char}, ::String, ::String) at ./iostream.jl:152
 [4] #writecsv#23(::Array{Any,1}, ::Function, ::String, ::Void) at ./datafmt.jl:705
 [5] writecsv(::String, ::Void) at ./datafmt.jl:705

```

I am using emacs 25.3.2 on ubuntu 16.04, julia 0.6. I will appreciate any help. If I take away commands associated with print or println, everything works.

I will appreciate any suggestion.

Best Regards,  
Shuvomoy

---

<div class="post-metadata">

**Author:** ![garrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrison/32/209519_2.png) [@garrison](https://discourse.julialang.org/u/garrison)\
**Post date:** [November 9, 2017, 11:38pm UTC](https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944/2 "2017-11-09T23:38:28Z")

</div>

I am trying to reproduce. I have julia-mode installed, but when I put the code in an orgmode file and press `C-c C-c`, I get the error `No org-babel-execute function for julia!`. Did you find this in a separate package, perhaps [ob-julia](https://github.com/gjkerns/ob-julia)?

---

<div class="post-metadata">

**Author:** ![Shuvomoy\_Das\_Gupta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuvomoy_das_gupta/32/10069_2.png) [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Post date:** [November 10, 2017, 1:54am UTC](https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944/3 "2017-11-10T01:54:45Z")

</div>

Thanks for your response.

I did the following. After installing julia-mode I enabled Julia in the init file:

```
(add-to-list 'load-path "path_to_where_julia-mode.el_file_is_located")
(require 'julia-mode)
(setq inferior-julia-program-name "path_to_where_julia_is_located/julia")

```

Now in the init file I found the part which looks like the following:

```
(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
...

```

and added the line

```
(julia . t)

```

somewhere in the list of enabled languages. Let me know if that gets rid of the issue.

Thanks,  
Shuvomoy

---

<div class="post-metadata">

**Author:** ![garrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrison/32/209519_2.png) [@garrison](https://discourse.julialang.org/u/garrison)\
**Post date:** [November 10, 2017, 2:58am UTC](https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944/4 "2017-11-10T02:58:32Z")

</div>

I was able to reproduce the issue.

But it works for me if I modify the first line to say `#+BEGIN_SRC julia :results output`.

The [default setting is](http://orgmode.org/worg/org-contrib/babel/intro.html#results) `:results value`.

EDIT: This, of course, does not fully explain why your code fails, but it is a step toward understanding what the underlying issue is…

---

<div class="post-metadata">

**Author:** ![garrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrison/32/209519_2.png) [@garrison](https://discourse.julialang.org/u/garrison)\
**Post date:** [November 10, 2017, 3:37am UTC](https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944/5 "2017-11-10T03:37:52Z")

</div>

OK, it turns out that for `:results value` the following code is actually what is being executed if you study `ob-julia.el`:

```julia
writecsv("/tmp/babel-2072Vgu/julia-2072RSg", begin
    a=[1;2;3]
    b=[3;4;5]
    c=a+b
    print(c)
end)

```

The return value of `print`, which is `nothing`, is passed to `writecsv` which thus fails. And everything written to STDOUT is ignored as far as babel is concerned.

EDIT: See [here](https://github.com/gjkerns/ob-julia/blob/master/ob-julia-doc.org#evaluation-inside-the-org-buffer) for an explanation of why `writecsv` is called. I am not convinced this is the optimal function to call; really there should be a function (I think) that takes any julia value and writes it in the format orgmode expects, without using csv as an intermediary…

---

<div class="post-metadata">

**Author:** ![garrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrison/32/209519_2.png) [@garrison](https://discourse.julialang.org/u/garrison)\
**Post date:** [November 10, 2017, 4:03am UTC](https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944/6 "2017-11-10T04:03:34Z")

</div>

See also: [https://github.com/gjkerns/ob-julia/issues/2](https://github.com/gjkerns/ob-julia/issues/2)

---

<div class="post-metadata">

**Author:** ![Shuvomoy\_Das\_Gupta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuvomoy_das_gupta/32/10069_2.png) [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Post date:** [November 10, 2017, 4:42am UTC](https://discourse.julialang.org/t/julia-print-commands-not-working-in-emacs-org-mode/6944/7 "2017-11-10T04:42:20Z")

</div>

I see. Okay, I guess I will just use

`:results output`

for now when I need to have a print statement.

Many Thanks,  
Shuvomoy
