Skip to content

Commit

Permalink
dot files: move ~/.juliarc.jl to ~/.julia/config/startup.jl
Browse files Browse the repository at this point in the history
also rename `/etc/julia/juliarc.jl` to `/etc/julia/startup.jl`
  • Loading branch information
StefanKarpinski committed Feb 23, 2018
1 parent 74ec1f9 commit 88ad3ce
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 58 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Here is the standard procedure:
2. Start a Julia REPL session. Then issue the following commands:

```julia
using Revise # if you aren't launching it in your .juliarc.jl
using Revise # if you aren't launching it in your `.julia/config/startup.jl`
Revise.track(Base)
```

Expand Down
6 changes: 3 additions & 3 deletions DISTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ and other environment variables you can pass when calling `make` and
`make install`. See Make.inc for their list. `DESTDIR` can also be used
to force the installation into a temporary directory.

By default, Julia loads `$prefix/etc/julia/juliarc.jl` as an
By default, Julia loads `$prefix/etc/julia/startup.jl` as an
installation-wide initialization file. This file can be used by
distribution managers to set up custom paths or initialization code.
For Linux distribution packages, if `$prefix` is
set to `/usr`, there is no `/usr/etc` to look into. This requires
the path to Julia's private `etc` directory to be changed. This can
be done via the `sysconfdir` make variable when building. Simply
pass `sysconfdir=/etc` to `make` when building and Julia will first
check `/etc/julia/juliarc.jl` before trying
`$prefix/etc/julia/juliarc.jl`.
check `/etc/julia/startup.jl` before trying
`$prefix/etc/julia/startup.jl`.

OS X
----
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ endif
julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia/test $(build_defaultpkgdir)
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/deps

julia-base: julia-deps $(build_sysconfdir)/julia/juliarc.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl
julia-base: julia-deps $(build_sysconfdir)/julia/startup.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/base

julia-libccalltest: julia-deps
Expand Down Expand Up @@ -157,8 +157,8 @@ $(build_man1dir)/julia.1: $(JULIAHOME)/doc/man/julia.1 | $(build_man1dir)
@mkdir -p $(build_man1dir)
@cp $< $@

$(build_sysconfdir)/julia/juliarc.jl: $(JULIAHOME)/etc/juliarc.jl | $(build_sysconfdir)/julia
@echo Creating usr/etc/julia/juliarc.jl
$(build_sysconfdir)/julia/startup.jl: $(JULIAHOME)/etc/startup.jl | $(build_sysconfdir)/julia
@echo Creating usr/etc/julia/startup.jl
@cp $< $@

$(build_datarootdir)/julia/julia-config.jl : $(JULIAHOME)/contrib/julia-config.jl | $(build_datarootdir)/julia
Expand Down Expand Up @@ -426,11 +426,11 @@ ifeq ($(OS), Linux)
# Copy over any bundled ca certs we picked up from the system during buildi
-cp $(build_datarootdir)/julia/cert.pem $(DESTDIR)$(datarootdir)/julia/
endif
# Copy in juliarc.jl files per-platform for binary distributions as well
# Copy in startup.jl files per-platform for binary distributions as well
# Note that we don't install to sysconfdir: we always install to $(DESTDIR)$(prefix)/etc.
# If you want to make a distribution with a hardcoded path, you take care of installation
ifeq ($(OS), Darwin)
-cat $(JULIAHOME)/contrib/mac/juliarc.jl >> $(DESTDIR)$(prefix)/etc/julia/juliarc.jl
-cat $(JULIAHOME)/contrib/mac/startup.jl >> $(DESTDIR)$(prefix)/etc/julia/startup.jl
endif

ifeq ($(OS), WINNT)
Expand Down
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ This section lists changes that do not have deprecation warnings.
of the socket. Previously the address of the remote endpoint was being
returned ([#21825]).

* Using `ARGS` within the ~/.juliarc.jl or within a .jl file loaded with `--load` will no
* The `~/.juliarc.jl` file has been moved to `~/.julia/config/startup.jl` and
`/etc/julia/juliarc.jl` file has been renamed to `/etc/julia/startup.jl` ([#26161]).

* Using `ARGS` within `startup.jl` files or within a .jl file loaded with `--load` will no
longer contain the script name as the first argument. Instead, the script name will be
assigned to `PROGRAM_FILE`. ([#22092])

Expand Down Expand Up @@ -801,7 +804,7 @@ Deprecated or removed
* Calling `write` on non-isbits arrays is deprecated in favor of explicit loops or
`serialize` ([#6466]).

* The default `juliarc.jl` file on Windows has been removed. Now must explicitly include the
* The default `startup.jl` file on Windows has been removed. Now must explicitly include the
full path if you need access to executables or libraries in the `Sys.BINDIR` directory, e.g.
`joinpath(Sys.BINDIR, "7z.exe")` for `7z.exe` ([#21540]).

Expand Down
2 changes: 1 addition & 1 deletion README.windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The 64-bit (x86_64) binary will only run on 64-bit Windows and will otherwise re

3. Julia's home directory is the location pointed to by the Windows environment
variable `%HOME%`: this directory is for instance where the startup file
`.juliarc.jl` resides. `%HOMEDRIVE%\%HOMEPATH%` is used as a fallback if
`.julia/config/startup.jl` resides. `%HOMEDRIVE%\%HOMEPATH%` is used as a fallback if
`%HOME%` is not defined.

## Source distribution
Expand Down
24 changes: 12 additions & 12 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ function exec_options(opts)
invokelatest(Main.Distributed.process_opts, opts)
end

# load ~/.juliarc file
startup && load_juliarc()
# load ~/.julia/config/startup.jl file
startup && load_julia_startup()

if repl || is_interactive
# load interactive-only libraries
Expand Down Expand Up @@ -345,16 +345,16 @@ function exec_options(opts)
nothing
end

function load_juliarc()
# If the user built us with a specific Base.SYSCONFDIR, check that location first for a juliarc.jl file
function load_julia_startup()
# If the user built us with a specific Base.SYSCONFDIR, check that location first for a startup.jl file
# If it is not found, then continue on to the relative path based on Sys.BINDIR
if !isempty(Base.SYSCONFDIR) && isfile(joinpath(Sys.BINDIR, Base.SYSCONFDIR, "julia", "juliarc.jl"))
include(Main, abspath(Sys.BINDIR, Base.SYSCONFDIR, "julia", "juliarc.jl"))
if !isempty(Base.SYSCONFDIR) && isfile(joinpath(Sys.BINDIR, Base.SYSCONFDIR, "julia", "startup.jl"))
include(Main, abspath(Sys.BINDIR, Base.SYSCONFDIR, "julia", "startup.jl"))
else
include_ifexists(Main, abspath(Sys.BINDIR, "..", "etc", "julia", "juliarc.jl"))
include_ifexists(Main, abspath(Sys.BINDIR, "..", "etc", "julia", "startup.jl"))
end
include_ifexists(Main, abspath(homedir(), ".juliarc.jl"))
nothing
include_ifexists(Main, abspath(homedir(), ".julia", "config", "startup.jl"))
return nothing
end

const repl_hooks = []
Expand All @@ -364,8 +364,8 @@ const repl_hooks = []
Register a one-argument function to be called before the REPL interface is initialized in
interactive sessions; this is useful to customize the interface. The argument of `f` is the
REPL object. This function should be called from within the `.juliarc.jl` initialization
file.
REPL object. This function should be called from within the `.julia/config/startup.jl`
initialization file.
"""
atreplinit(f::Function) = (pushfirst!(repl_hooks, f); nothing)

Expand Down Expand Up @@ -400,7 +400,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil
active_repl = REPL.LineEditREPL(term, have_color, true)
active_repl.history_file = history_file
end
# Make sure any displays pushed in .juliarc.jl ends up above the
# Make sure any displays pushed in .julia/config/startup.jl ends up above the
# REPLDisplay
pushdisplay(REPL.REPLDisplay(active_repl))
_atreplinit(active_repl)
Expand Down
6 changes: 3 additions & 3 deletions doc/man/julia.1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Set location of julia executable

.TP
--startup-file={yes|no}
Load ~/.juliarc.jl
Load ~/.julia/config/startup.jl

.TP
--handle-signals={yes|no}
Expand Down Expand Up @@ -189,12 +189,12 @@ Count executions of source lines (omitting setting is equivalent to 'user')
Count bytes allocated by each source line

.SH FILES
.I ~/.juliarc.jl
.I ~/.julia/config/startup.jl
.RS
Per user startup file.
.RE

.I /etc/julia/juliarc.jl
.I /etc/julia/startup.jl
.RS
System-wide startup file.
.RE
Expand Down
12 changes: 6 additions & 6 deletions doc/src/manual/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ usual way of the operating system, or in a portable way from within Julia.
Suppose you want to set the environment variable `JULIA_EDITOR` to
`vim`, then either type `ENV["JULIA_EDITOR"] = "vim"` for instance in the REPL
to make this change on a case by case basis, or add the same to the user
configuration file `.juliarc.jl` in the user's home directory to have
configuration file `~/.julia/config/startup.jl` in the user's home directory to have
a permanent effect. The current value of the same environment variable is
determined by evaluating `ENV["JULIA_EDITOR"]`.

Expand Down Expand Up @@ -42,14 +42,14 @@ determines the directory in which Julia initially searches for source files (via
`Base.find_source_file()`).

Likewise, the global variable `Base.SYSCONFDIR` determines a relative path to the
configuration file directory. Then Julia searches for a `juliarc.jl` file at
configuration file directory. Then Julia searches for a `startup.jl` file at

```
$JULIA_BINDIR/$SYSCONFDIR/julia/juliarc.jl
$JULIA_BINDIR/../etc/julia/juliarc.jl
$JULIA_BINDIR/$SYSCONFDIR/julia/startup.jl
$JULIA_BINDIR/../etc/julia/startup.jl
```

by default (via `Base.load_juliarc()`).
by default (via `Base.load_julia_startup()`).

For example, a Linux installation with a Julia executable located at
`/bin/julia`, a `DATAROOTDIR` of `../share`, and a `SYSCONFDIR` of `../etc` will
Expand All @@ -62,7 +62,7 @@ have `JULIA_BINDIR` set to `/bin`, a source-file search path of
and a global configuration search path of

```
/etc/julia/juliarc.jl
/etc/julia/startup.jl
```

### `JULIA_LOAD_PATH`
Expand Down
7 changes: 4 additions & 3 deletions doc/src/manual/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ takes the form `[count*][user@]host[:port] [bind_addr[:port]]` . `user` defaults
to 1. The optional `bind-to bind_addr[:port]` specifies the ip-address and port that other workers
should use to connect to this worker.

If you have code that you want executed whenever Julia is run, you can put it in `~/.juliarc.jl`:
If you have code that you want executed whenever Julia is run, you can put it in
`~/.julia/config/startup.jl`:

```
$ echo 'println("Greetings! 你好! 안녕하세요?")' > ~/.juliarc.jl
$ echo 'println("Greetings! 你好! 안녕하세요?")' > ~/.julia/config/startup.jl
$ julia
Greetings! 你好! 안녕하세요?
Expand All @@ -100,7 +101,7 @@ julia [switches] -- [programfile] [args...]
-J, --sysimage <file> Start up with the given system image file
-H, --home <dir> Set location of `julia` executable
--startup-file={yes|no} Load ~/.juliarc.jl
--startup-file={yes|no} Load `~/.julia/config/startup.jl`
--handle-signals={yes|no} Enable or disable Julia's default signal handlers
--sysimage-native-code={yes|no}
Use native code from system image if available
Expand Down
5 changes: 3 additions & 2 deletions doc/src/manual/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ The global variable [`LOAD_PATH`](@ref) contains the directories Julia searches
push!(LOAD_PATH, "/Path/To/My/Module/")
```

Putting this statement in the file `~/.juliarc.jl` will extend [`LOAD_PATH`](@ref) on every Julia startup.
Alternatively, the module load path can be extended by defining the environment variable `JULIA_LOAD_PATH`.
Putting this statement in the file `~/.julia/config/startup.jl` will extend [`LOAD_PATH`](@ref) on
every Julia startup. Alternatively, the module load path can be extended by defining the environment
variable `JULIA_LOAD_PATH`.

### Namespace miscellanea

Expand Down
6 changes: 3 additions & 3 deletions doc/src/manual/parallel-computing.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ julia> addprocs(2)
Module `Distributed` must be explicitly loaded on the master process before invoking [`addprocs`](@ref).
It is automatically made available on the worker processes.

Note that workers do not run a `.juliarc.jl` startup script, nor do they synchronize their global
state (such as global variables, new method definitions, and loaded modules) with any of the other
running processes.
Note that workers do not run a `~/.julia/config/startup.jl` startup script, nor do they synchronize
their global state (such as global variables, new method definitions, and loaded modules) with any
of the other running processes.

Other types of clusters can be supported by writing your own custom `ClusterManager`, as described
below in the [ClusterManagers](@ref) section.
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/workflow-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ which you can run on startup by issuing the command:
julia -L _init.jl
```

If you further add the following to your `.juliarc.jl` file
If you further add the following to your `~/.julia/config/startup.jl` file

```julia
isfile("_init.jl") && include(joinpath(pwd(), "_init.jl"))
Expand Down
2 changes: 0 additions & 2 deletions etc/juliarc.jl

This file was deleted.

2 changes: 2 additions & 0 deletions etc/startup.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 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`.
2 changes: 1 addition & 1 deletion src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static const char opts[] =
// startup options
" -J, --sysimage <file> Start up with the given system image file\n"
" -H, --home <dir> Set location of `julia` executable\n"
" --startup-file={yes|no} Load ~/.juliarc.jl\n"
" --startup-file={yes|no} Load `~/.julia/config/startup.jl`\n"
" --handle-signals={yes|no} Enable or disable Julia's default signal handlers\n"
" --sysimage-native-code={yes|no}\n"
" Use native code from system image if available\n"
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Distributed/src/managers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ end
Equivalent to `addprocs(Sys.CPU_CORES; kwargs...)`
Note that workers do not run a `.juliarc.jl` startup script, nor do they synchronize their
global state (such as global variables, new method definitions, and loaded modules) with any
Note that workers do not run a `.julia/config/startup.jl` startup script, nor do they synchronize
their global state (such as global variables, new method definitions, and loaded modules) with any
of the other running processes.
"""
addprocs(; kwargs...) = addprocs(Sys.CPU_CORES; kwargs...)
Expand Down
9 changes: 5 additions & 4 deletions stdlib/Pkg/test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,11 @@ temp_pkg_dir() do
mkpath(dirname(test_filename))
write(test_filename, content)

# Make a .juliarc.jl
# Make a ~/.julia/config/startup.jl
home = Pkg.dir(".home")
mkdir(home)
write(joinpath(home, ".juliarc.jl"), "const JULIA_RC_LOADED = true")
mkpath(joinpath(home, ".julia", "config"))
write(joinpath(home, ".julia", "config", "startup.jl"),
"const JULIA_RC_LOADED = true")

withenv((Sys.iswindows() ? "USERPROFILE" : "HOME") => home) do
code = "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build(\"$package\")"
Expand All @@ -585,7 +586,7 @@ temp_pkg_dir() do
@test contains(msg, "Main.JULIA_RC_LOADED defined false")

# Note: Since both the startup-file and "runtests.jl" are run in the Main
# module any global variables created in the .juliarc.jl can be referenced.
# module any global variables created in the startup file can be referenced.
msg = read(`$(Base.julia_cmd()) --startup-file=yes -e $code`, String)
@test contains(msg, "JULIA_RC_LOADED defined true")
@test contains(msg, "Main.JULIA_RC_LOADED defined true")
Expand Down
9 changes: 5 additions & 4 deletions stdlib/REPL/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Meta plus `x` can be written `"\\Mx"`. The values of the custom keymap must be `
that the input should be ignored) or functions that accept the signature `(PromptState, AbstractREPL, Char)`.
The `REPL.setup_interface` function must be called before the REPL is initialized, by registering
the operation with [`atreplinit`](@ref) . For example, to bind the up and down arrow keys to move through
history without prefix search, one could put the following code in `.juliarc.jl`:
history without prefix search, one could put the following code in `~/.julia/config/startup.jl`:

```julia
import REPL
Expand Down Expand Up @@ -324,7 +324,7 @@ fields if the function is type stable.

The colors used by Julia and the REPL can be customized, as well. To change the
color of the Julia prompt you can add something like the following to your
`.juliarc.jl` file, which is to be placed inside your home directory:
`~/.julia/config/startup.jl` file, which is to be placed inside your home directory:

```julia
function customize_colors(repl)
Expand All @@ -345,7 +345,7 @@ latter two, be sure that the `envcolors` field is also set to false.

It is also possible to apply boldface formatting by using
`Base.text_colors[:bold]` as a color. For instance, to print answers in
boldface font, one can use the following as a `.juliarc.jl`:
boldface font, one can use the following as a `~/.julia/config/startup.jl`:

```julia
function customize_colors(repl)
Expand All @@ -358,7 +358,8 @@ atreplinit(customize_colors)

You can also customize the color used to render warning and informational messages by
setting the appropriate environment variables. For instance, to render error, warning, and informational
messages respectively in magenta, yellow, and cyan you can add the following to your `.juliarc.jl` file:
messages respectively in magenta, yellow, and cyan you can add the following to your
`~/.julia/config/startup.jl` file:

```julia
ENV["JULIA_ERROR_COLOR"] = :magenta
Expand Down
8 changes: 5 additions & 3 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no`
write(testfile, """
println(ARGS)
""")
cp(testfile, joinpath(dir, ".juliarc.jl"))
mkpath(joinpath(dir, ".julia", "config"))
cp(testfile, joinpath(dir, ".julia", "config", "startup.jl"))

withenv((Sys.iswindows() ? "USERPROFILE" : "HOME") => dir) do
output = "[\"foo\", \"-bar\", \"--baz\"]"
Expand All @@ -304,7 +305,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no`
mktempdir() do dir
a = joinpath(dir, "a.jl")
b = joinpath(dir, "b.jl")
c = joinpath(dir, ".juliarc.jl")
c = joinpath(dir, ".julia", "config", "startup.jl")

write(a, """
println(@__FILE__)
Expand All @@ -315,6 +316,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no`
println(@__FILE__)
println(PROGRAM_FILE)
""")
mkpath(dirname(c))
cp(b, c)

readsplit(cmd) = split(readchomp(cmd), '\n')
Expand Down Expand Up @@ -416,7 +418,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes`
# --startup-file
let JL_OPTIONS_STARTUPFILE_ON = 1,
JL_OPTIONS_STARTUPFILE_OFF = 2
# `HOME=$tmpdir` to avoid errors in the user .juliarc.jl, which hangs the tests. Issue #17642
# `HOME=$tmpdir` to avoid errors in the user startup.jl, which hangs the tests. Issue #17642
mktempdir() do tmpdir
withenv("HOME"=>tmpdir) do
@test parse(Int,readchomp(`$exename -E "Base.JLOptions().startupfile" --startup-file=yes`)) == JL_OPTIONS_STARTUPFILE_ON
Expand Down

0 comments on commit 88ad3ce

Please sign in to comment.