diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 411df7e49943b..c29867b6c3540 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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) ``` diff --git a/DISTRIBUTING.md b/DISTRIBUTING.md index a159188e8f32c..4542456759eb1 100644 --- a/DISTRIBUTING.md +++ b/DISTRIBUTING.md @@ -81,7 +81,7 @@ 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 @@ -89,8 +89,8 @@ 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 ---- diff --git a/Makefile b/Makefile index 5a0fa8dd62270..33b8717d1b1a4 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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) diff --git a/NEWS.md b/NEWS.md index 180e10b3fc415..69dec3f635576 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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]) @@ -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]). diff --git a/README.windows.md b/README.windows.md index 92c2443b83914..be6fe2d7a5e65 100644 --- a/README.windows.md +++ b/README.windows.md @@ -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 diff --git a/base/client.jl b/base/client.jl index e663d61b44332..edf7aa379bc2c 100644 --- a/base/client.jl +++ b/base/client.jl @@ -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 @@ -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 = [] @@ -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) @@ -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) diff --git a/doc/man/julia.1 b/doc/man/julia.1 index 39e9c70573120..8c68a5a940548 100644 --- a/doc/man/julia.1 +++ b/doc/man/julia.1 @@ -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} @@ -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 diff --git a/doc/src/manual/environment-variables.md b/doc/src/manual/environment-variables.md index ebc4617eff8c1..28dbf152d5c22 100644 --- a/doc/src/manual/environment-variables.md +++ b/doc/src/manual/environment-variables.md @@ -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"]`. @@ -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 @@ -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` diff --git a/doc/src/manual/getting-started.md b/doc/src/manual/getting-started.md index 842cff0df38f1..6de2c96f669af 100644 --- a/doc/src/manual/getting-started.md +++ b/doc/src/manual/getting-started.md @@ -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! 你好! 안녕하세요? @@ -100,7 +101,7 @@ julia [switches] -- [programfile] [args...] -J, --sysimage Start up with the given system image file -H, --home 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 diff --git a/doc/src/manual/modules.md b/doc/src/manual/modules.md index 1442f898bcb53..2b5c1099e84ad 100644 --- a/doc/src/manual/modules.md +++ b/doc/src/manual/modules.md @@ -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 diff --git a/doc/src/manual/parallel-computing.md b/doc/src/manual/parallel-computing.md index 876ca902c2d9c..ea54c3b8d98dc 100644 --- a/doc/src/manual/parallel-computing.md +++ b/doc/src/manual/parallel-computing.md @@ -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. diff --git a/doc/src/manual/workflow-tips.md b/doc/src/manual/workflow-tips.md index bd00c03828b57..857822d8ded91 100644 --- a/doc/src/manual/workflow-tips.md +++ b/doc/src/manual/workflow-tips.md @@ -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")) diff --git a/etc/juliarc.jl b/etc/juliarc.jl deleted file mode 100644 index 971f38b51807c..0000000000000 --- a/etc/juliarc.jl +++ /dev/null @@ -1,2 +0,0 @@ -# This file should contain site-specific commands to be executed on Julia startup -# Users may store their own personal commands in the user home directory `homedir()`, in a file named `.juliarc.jl` diff --git a/etc/startup.jl b/etc/startup.jl new file mode 100644 index 0000000000000..e58753d634d73 --- /dev/null +++ b/etc/startup.jl @@ -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`. diff --git a/src/jloptions.c b/src/jloptions.c index fba335551fb56..6f8ad92df36d6 100644 --- a/src/jloptions.c +++ b/src/jloptions.c @@ -78,7 +78,7 @@ static const char opts[] = // startup options " -J, --sysimage Start up with the given system image file\n" " -H, --home 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" diff --git a/stdlib/Distributed/src/managers.jl b/stdlib/Distributed/src/managers.jl index 97669bd455308..bebf0f39c338b 100644 --- a/stdlib/Distributed/src/managers.jl +++ b/stdlib/Distributed/src/managers.jl @@ -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...) diff --git a/stdlib/Pkg/test/pkg.jl b/stdlib/Pkg/test/pkg.jl index fb37268ec549f..3a360985a564e 100644 --- a/stdlib/Pkg/test/pkg.jl +++ b/stdlib/Pkg/test/pkg.jl @@ -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\")" @@ -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") diff --git a/stdlib/REPL/docs/src/index.md b/stdlib/REPL/docs/src/index.md index 34422a2674d28..68b393795ad7b 100644 --- a/stdlib/REPL/docs/src/index.md +++ b/stdlib/REPL/docs/src/index.md @@ -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 @@ -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) @@ -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) @@ -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 diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 16d6346ce886c..94219438767c9 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -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\"]" @@ -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__) @@ -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') @@ -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