Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:result value error #1

Closed
fkgruber opened this issue Oct 12, 2020 · 12 comments
Closed

:result value error #1

fkgruber opened this issue Oct 12, 2020 · 12 comments
Labels
windows Windows-specific bugs or questions

Comments

@fkgruber
Copy link

Hi Frederic,

I know you are still working on this but I gave it a try anyways. The :results output works well with ess-julia but could not get it to work with :results value. I get the error:

ERROR: LoadError: UndefVarError: @pipe not defined
in expression starting at none:1
@frederic-santos
Copy link
Owner

Thanks for the report!

It looks like the Julia init file is not loaded at the start of your Julia session. I've tested on another (Linux) computer from a blank install and everything is fine for me.

  1. Can you confirm that you've downloaded the whole repo, including ob-ess-julia-startup.jl?
  2. Are you on Windows (or Mac)? In this case, this might have something to do with this part of the code. Maybe the dir path is not correctly expanded for Windows users... I'll give it a try on Windows soon.

@fkgruber
Copy link
Author

I'm on windows.

I only downloaded one file. I tried downloading the whole directory now and using the following in my configuration:

(add-to-list 'load-path "~/elisp/ob-ess-julia/ob-ess-julia-master")
(require 'ob-ess-julia)
(setq org-src-lang-modes
      (append org-src-lang-modes '(("ess-julia" . ess-julia))))

;; Shortcuts for Julia code block headers.
;; Shortcut for "normal" session evaluation with verbatim outpuevalt:
(add-to-list 'org-structure-template-alist
	     '("j" . "src ess-julia :results output :session *julia* :exports both"))
;; Shortcut for inline graphical output within a session:
(add-to-list 'org-structure-template-alist
	     '("jfig" . "src ess-julia :results output graphics file :file FILENAME.png :session *julia* :exports both"))
;; Shortcut for well-formatted org table output within a session:
(add-to-list 'org-structure-template-alist
	     '("jtab" . "src ess-julia :results value table :session *julia* :exports both :colnames yes"))

But It is still not reading the init file.

I then tried copying the content of your init file to
~/.julia/config/startup.jl and now it works!

This if my startup.jl:

# Check that required packages are installed:
if Base.find_package("CSV") == nothing || Base.find_package("DelimitedFiles") == nothing || Base.find_package("Pipe") == nothing
    using Pkg
    Pkg.add("CSV")
    Pkg.add("DelimitedFiles")
    Pkg.add("Pipe")
end

# Load required packages:
using CSV
using DelimitedFiles
using Pipe

# Perso function to write Julia objects into CSV files:
function ob_ess_julia_csv_write(filename, bodycode, has_header)
    CSV.write(filename, bodycode, delim = "\t", writeheader = has_header);
end

function ob_ess_julia_write(bodycode::Any, filename::Any, has_header::Any)
    try
        ob_ess_julia_csv_write(filename, bodycode, has_header);
    catch err
        if isa(err, ArgumentError) | isa(err, MethodError)
            writedlm(filename, bodycode)
        end
    end
end


println("In startup script")
using Base: stdin, stdout, stderr
using REPL.Terminals: TTYTerminal
using REPL: BasicREPL, run_repl
using DelimitedFiles
run_repl(BasicREPL(TTYTerminal("emacs",stdin,stdout,stderr)))
println("Finished initial startup")

The last lines are needed in windows otherwise the shell does not show anything

Thanks for the report!

It looks like the Julia init file is not loaded at the start of your Julia session. I've tested on another (Linux) computer from a blank install and everything is fine for me.

  1. Can you confirm that you've downloaded the whole repo, including ob-ess-julia-startup.jl?
  2. Are you on Windows (or Mac)? In this case, this might have something to do with this part of the code. Maybe the dir path is not correctly expanded for Windows users... I'll give it a try on Windows soon.

@frederic-santos
Copy link
Owner

Thank you for investigating and for those useful comments.

The last lines are needed in windows otherwise the shell does not show anything

I had no idea of that, but this is fixed in commit 1ce85d7. Thanks. However,

But It is still not reading the init file.

I could not reproduce this problem. I tried on a Windows 10 computer: the init file was correctly detected and there was no problem for me.
Just in case, I updated config info in commit 5edd114.

@frederic-santos frederic-santos added the windows Windows-specific bugs or questions label Oct 14, 2020
@fkgruber
Copy link
Author

thanks!

@fkgruber
Copy link
Author

Hi Frederic,
I was trying on a Mac and I'm running into the same issue that it is not loading the startup.

THis is what I'm using on my init:

;; Load ob-julia and dependencies
(use-package julia-mode
  :ensure t)
(add-to-list 'load-path "~/elisp/ob-ess-julia/")
(require 'ob-ess-julia)
;; Add ess-julia into supported languages:
(org-babel-do-load-languages 'org-babel-load-languages
                             (append org-babel-load-languages
                                     '((ess-julia . t))))
;; Link this language to ess-julia-mode (although it should be done by default):
(setq org-src-lang-modes
      (append org-src-lang-modes '(("ess-julia" . ess-julia))))

I have a clone of your repository in ob-ess-julia.
Am I missing some configuration? or do I need to move the startup file somewhere? How does it know to load up the startup file from this location?

thanks
FKG

@frederic-santos
Copy link
Owner

frederic-santos commented Oct 21, 2020

Hi again,
Had you still the same issue on Windows, or could it be fixed with this new elisp config?

I have unfortunately no way to test that on a Mac. However, since I could not reproduce that issue on Windows, I'm a bit confused.
In my code:

  1. Here, the path to ob-ess-julia-startup.jl is built. It's simply defined as being the same folder in which ob-ess-julia.el can be found.
  2. And then Julia is started with the additional instruction of loading this Julia startup file.

There may be some OS-specific subtlety I'm not aware of...
When you start Emacs and do C-h v ob-ess-julia-startup, what is the value of this variable?

@fkgruber
Copy link
Author

fkgruber commented Oct 21, 2020

Hi Frederic,
I see what the problem is now. I have been starting julia with M-x julia. That won't load that startup file.

However, if I try to run a block in orgmode pointing to a new session then it tries to run run-ess-julia which does not exists:
set-buffer: Symbol’s function definition is void: run-ess-julia

What is run-ess-julia defined?

thanks
FKG

@frederic-santos
Copy link
Owner

I have been starting julia with M-x julia. That won't load that startup file.

Oh, yes! Actually, Julia sessions should be started automatically with a C-c C-c on a code block. It won't work if the Julia process is started manually, indeed. That's something I should have said in the documentation, you're right.

it tries to run run-ess-julia which does not exists

This is strange: this function is defined in ESS. It should have been recognized. I added another declare-function statement, just in case, in commit 9dd1904.

@fkgruber
Copy link
Author

I'm using ess-version: 18.10.2. I wonder if julia-mode is overwriting some of the julia related code in ess.

@fkgruber
Copy link
Author

this version does not defined that function:
https://github.com/emacs-ess/ESS/blob/ess-18.10/lisp/ess-julia.el

run-ess-julia is only defined on the development version
18.10.3snapshot
https://github.com/emacs-ess/ESS/blob/master/lisp/ess-julia.el

@fkgruber
Copy link
Author

I updated to the development version of ess and now everything works.

thanks
Fred

@frederic-santos
Copy link
Owner

Thanks, good to know that everything is okay now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
windows Windows-specific bugs or questions
Projects
None yet
Development

No branches or pull requests

2 participants