You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These are jl files that have project and manifest embedded inside them, similar to how Pluto notebooks have done for quite a while.
The delimiters are `#!manifest begin` and `#!manifest end` (analogous for project data) and the content can either have single line comments or be inside a multi line comment.
When the active project is set to a portable script the project and manifest data will be read from the inlined toml data.
Starting julia with a file (`julia file.jl`) will set the file as the active project if julia detects that it is a portable script.
Copy file name to clipboardExpand all lines: doc/src/manual/code-loading.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -397,6 +397,47 @@ are stored in the manifest file in the section for that package. The dependency
397
397
a package are the same as for its "parent" except that the listed triggers are also considered as
398
398
dependencies.
399
399
400
+
### [Portable scripts](@id portable-scripts)
401
+
402
+
Julia also understands *portable scripts*: scripts that embed their own `Project.toml` (and optionally `Manifest.toml`) so they can be executed as self-contained environments. To do this, place TOML data inside comment fences named `#!project` and `#!manifest`:
Lines inside the fenced blocks may either start with `#` (as in the example), be plain TOML, or be wrapped in multi-line comment delimiters `#= ... =#`:
425
+
426
+
```julia
427
+
#!project begin
428
+
#=
429
+
name = "HelloApp"
430
+
uuid = "9c5fa7d8-7220-48e8-b2f7-0042191c5f6d"
431
+
version = "0.1.0"
432
+
[deps]
433
+
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
434
+
=#
435
+
#!project end
436
+
```
437
+
438
+
439
+
Running `julia hello.jl` automatically activates the embedded project. The script path becomes the active project entry in `LOAD_PATH`, so package loading works exactly as if `Project.toml` and `Manifest.toml` lived next to the script. The `--project=@script` flag also expands to the script itself when no on-disk project exists but inline metadata is present.
440
+
400
441
### [Workspaces](@id workspaces)
401
442
402
443
A project file can define a workspace by giving a set of projects that is part of that workspace:
0 commit comments