Skip to content

Commit e1b16fa

Browse files
Set SOURCE_PATH in notebook process (#304)
1 parent 9b7da34 commit e1b16fa

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Fixed
11+
12+
- Ensure `Base.source_path()` reflects the currently running notebook path [#304]
13+
1014
## [v0.17.1] - 2025-05-14
1115

1216
### Fixed
@@ -444,3 +448,4 @@ caching is enabled. Delete this folder to clear the cache. [#259]
444448
[#298]: https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/298
445449
[#299]: https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/299
446450
[#303]: https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/303
451+
[#304]: https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/304

src/QuartoNotebookWorker/src/refresh.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ function refresh!(path, original_options, options = original_options)
33
# notebook file, which is not necessarily right initially if the parent
44
# process was started from a different directory to the notebook.
55
cd(dirname(path))
6+
task_local_storage()[:SOURCE_PATH] = path
67

78
# Reset back to the original project environment if it happens to
89
# have changed during cell evaluation.

test/examples/source_path.qmd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: "Source Path"
3+
engine: julia
4+
---
5+
6+
```{julia}
7+
Base.source_path()
8+
```

test/testsets/source_path.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include("../utilities/prelude.jl")
2+
3+
test_example(joinpath(@__DIR__, "../examples/source_path.qmd")) do json
4+
cell = json["cells"][2]
5+
data = cell["outputs"][1]["data"]
6+
@test contains(data["text/plain"], "source_path.qmd")
7+
end

0 commit comments

Comments
 (0)