Been away from Julia for about 9 months. Coming back I upgraded fro m 1.7.3 to 1.8.5; had issues with environment variables but eventally got over them. However, my file in ~/.julia/config/startup.jl is not being run. I edited the install directory’s etc/startup.jl and added (nothing there beforehand)
include(“/home/martin/.julia/config/startup.jl”)
This is being run, but I get the error
> julia
ERROR: LoadError: syntax: invalid character "“" near column 9
Stacktrace:
[1] top-level scope
@ /home/Dropbox/Julia/julia-1.8.5/etc/julia/startup.jl:3
in expression starting at /home/Dropbox/Julia/julia-1.8.5/etc/julia/startup.jl:3
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.8.5 (2023-01-08)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia>
Column 9 is the first "" character. I might say this is typical of julia error messages. I tried running from the repl and I get the same error message.
julia> include(“/home/martin/.julia/config/startup.jl”)
ERROR: syntax: invalid character ““” near column 9
Stacktrace:
[1] top-level scope
@ none:1
julia>
I have verified the path is correct and /home/martin/.julia/config/startup.jl exists. This is an example of why julia will never really be popular; if one gets stuck just trying to start it with almost no information on what is going wrong? Just not clean! especially as compared to Python (albeit the new Python Codon module from MIT has similar issues). Just one more grype; the window I am typing in only shows two lines at a time; again, just not clean!
Even weirder, after doing hundreds of blind trial and errors, I still don’t have ~.julia/config/startup.jl running at startup, but all of a suddent, the previous error message about column 9 went away and including include(“/home/martin/.julia/config/startup.jl”) into the julia base directory under etc started working without the error message. I have no idea why the error went away and why ~.julia/config/startup.jl is not being run automatically at startup. At least now after hours of work, I’ve gotten to the point where I can start the repl and load a startup file. Is this something a new user is expected to figure out? Or does the community not want new users? For me it has been real difficult and I still have no idea why startup.jl is not being loaded automatically, and even worst, I have no idea about to debug it?
No, I have tried a couple of different startup.jl files (shown below). I have not changed them, and I can now load them; they just don’t load automatically.
startup.jl: original and now loading:
import Pkg
println(“In ~/.julia/config/startup.jl”)
let
pkgs = [“Revise”, “Debugger”, “PyPlot”, “BenchmarkTools”, “Random”, “PyCall”,
“Statistics”, “MAT”, “Printf”, “Random”]
for pkg in pkgs
if Base.find_package(pkg) === nothing
Pkg.add(pkg)
end
end
end
using Debugger, PyPlot, Printf
try
using Revise
catch e @warn “Error initializing Revise” exception=(e, catch_backtrace())
end
print(“\nHello, startup.jl from ~/.julia/config has just been run\n”)
println(“Setup successful”)
The other one I tryed, which again, I can now load is:
using Random
ENV[“JULIA_EDITOR”] = “vim”
println(“Setup successful”)
The error message has nothing to do with the contents of my startup.jl file
Sorry about the bad formatting; the window only has two lines showing, and the placement of “Blockquote” is not showing. Without the Blockquote’s the indentation is lost; sigh! Below is just another attempt to just try and figure out the "Blockquote"s. If it doesn’t work, I’ll forget it.
Blockquote
import Pkg
println(“In ~/.julia/config/startup.jl”)
let
pkgs = [“Revise”, “Debugger”, “PyPlot”, “BenchmarkTools”, “Random”, “PyCall”,
“Statistics”, “MAT”, “Printf”, “Random”]
for pkg in pkgs
if Base.find_package(pkg) === nothing
Pkg.add(pkg)
end
end
end
using Debugger, PyPlot, Printf
try
using Revise
catch e @warn “Error initializing Revise” exception=(e, catch_backtrace())
end
print(“\nHello, startup.jl from ~/.julia/config has just been run\n”)
println(“Setup successful”)
No need to block quote - use triple back ticks ``` around the code blocks in your post.
The confusion around the different quotation marks can arise from posting code that’s not formatted as code, in which case quotation marks get replaced by the serif ones. If I understand you correctly you’re saying there’s no issue with the wrong quotation marks in your files but it’s hard for others to tell when the code isn’t formatted correctly on here.
In your first post the stack trace indicates a different location for the startup file than the path you indicated you placed it at. Maybe you keep changing a different file that is not actually loaded.
It is generally a good idea to provide as much information as possible. So the full Startup.jl file, propperly formatted, along with the full stacktrace, also properly formatted, would go a long ways to help us help you.
The hostile tone about “you” not wanting people to learn Julia also just makes it a little less tempting to help you. Everyone here (obviously) wants to make it as easy as possible to learn Julia.
Julia is installed in /home/Dropbox/Julia/julia-1.8.5/. The file /home/Dropbox/Julia/julia-1.8.5/etc/julia/startup.jl is in the install directory and intended for system wide start up commands, but is not intended to be used by individual users. The second file: ~/.julia/config/startup.jl is where users are supposed to place there startup commands. The first file is being run; the second one is not being run unless it is called from the first file. In addition, I was getting the error:
julia
ERROR: LoadError: syntax: invalid character ““” near column 9
Stacktrace:
[1] top-level scope
@ /home/Dropbox/Julia/julia-1.8.5/etc/julia/startup.jl:3
in expression starting at /home/Dropbox/Julia/julia-1.8.5/etc/julia/startup.jl:3
and had no idea why I was getting it. And then for some unknown reason, I stopped getting this error without any idea why?
I attempted to format the startup file a couple of times, but can not get the block quotes to work, and can’t find out how to get them to work. Can you give me a link on how to do this? I also have no idea how to get a stacktrace at startup? Can you give me a link on how to get a stacktrace at startup failure?
This is a pretty precise error—as it says, you have an invalid character in your startup file. It tells you the full path of the file, the line number on which the invalid character occurs, and what the invalid character is (a curly quote). It’s hard to imagine what else you could possibly want to diagnose the issue. This hasn’t become invalid since the last time you ran Julia, it has always been invalid, so you must have changed that file at some point, probably by opening it in some editor that isn’t meant to be used for programming and wants to change standard quotes to curly ones. That’s hardly the fault of Julia. I would suggest using a real programming editor.
The way I see people end up with curly quotes such as “ is that they are using an word processor such as Microsoft Word to open these text files. Another method is copy and pasting text from a website or from an email client. Somewhere in the tooling something is trying to introduce “cute” quotes. Seeing Dropbox in the path makes me suspect that a combination of these are at play here.
A basic text editor should do. A cross platform one common in the Julia community is Visual Studio Code ( https://code.visualstudio.com/ ). In Linux based systems, one could use nano (easy), vim (advanced) , or emacs (advanced) from the console.
The editor I use most often is sublime-text; I’m also happy with vi (or vim) or geany. I do not believe my editor changing the quotes was the reason. I see in one of the previous posts that in order to get block quotes, one types three back-quotes before and after the text. Thank you. I will now try use this to show my systemwide startup.jl
# This file should contain site-specific commands to be executed on Julia startup;
# Users may store their own personal commands in `~/.julia/config/startup.jl`.
# include(“/home/martin/.julia/config/startup.jl”)
include("/home/martin/.julia/config/startup.jl")
I hope this is working (can’t tell until I submit the reply). I’ll post my user startup in a separate reply. Please note that line 3 where the error was reported as occurring is a comment line. Line 4 is a line I added to run my user startup.jl. It should not be necessary but I can’t figure out why my startup.jl file is not being run. If someone can give advice on how to get Debugger running on the startup process, I’ll give it a try and attempt to get a stack trace. Please note, the error messages have now gone away, and I didn’t (or at least as far as I know) change anything. I still have the issue of ~/.julia/config/startup.jl not being run automatically and currently I have no idea how to debug that.