I played around with this again today and I am having trouble once again. Here is an MWE. It will be a mix of what is given in the Pkg.jl
docs, in particular section 5 on creating anew package here the Workflow tips docs, here, the PkgTemplates.jl docs here, and the Revise.jl docs here.
I have a folder called Development
that I want to hold all my code, rather than .julia/dev
. Reading the workflow tips, this is how I start creating the project.
# Change directories into my development folder
$ cd Documents/Development
# Start julia
$ julia
# Use PkgTemplates
julia> using PkgTemplates
# Check what a default package would look like.
# note: I want the package directory to not be in .julia/dev
julia> t = Template()
Template:
→ User: pdeffebach
→ Host: github.com
→ License: MIT (pdeffebach <p.deffebach@gmail.com> 2019)
→ Package directory: ~/.julia/dev
→ Minimum Julia version: v1.0
→ SSH remote: No
→ Add packages to main environment: Yes
→ Commit Manifest.toml: No
→ Plugins: None
# Setting dir = "." does what I want.
julia> t = Template(dir = ".")
Template:
→ User: pdeffebach
→ Host: github.com
→ License: MIT (pdeffebach <p.deffebach@gmail.com> 2019)
→ Package directory: ~/Documents/Development/
→ Minimum Julia version: v1.0
→ SSH remote: No
→ Add packages to main environment: Yes
→ Commit Manifest.toml: No
→ Plugins: None
# Create the packag
julia> generate("HelloWorld", t)
# Get into the newly created directory
shell> cd HelloWorld
/home/peterwd/Documents/Development/HelloWorld
# Load revise to start editing
julia> using Revise
# Use the new HelloWorld package
julia> using HelloWorld
[ Info: Precompiling HelloWorld [233cd533-293a-414a-b31a-fd2ca2ae87f6]
julia> HelloWorld.greet()
Hello World!
In the docs for Revise here, it states that Revise can track " any package that you load with import
or using
". Given that I just did using HelloWorld
and it worked, I figured Revise should be able to do it.
julia> edit("src/HelloWorld.jl")
Now I change the output of HelloWorld.greet()
from "Hello, World!"
to just "Hello"
.
julia> HelloWorld.greet()
Hello World!
It didn’t work.
But in the Revise.jl docs here it has a dev Example
command in its tutorial. Given that I am creating code for the first time, I need to use develop slightly differently. I use the file-path method of develop
rather than a html for git or the command for developing a registered package.
(v1.2) pkg> develop .
Editing still doesn’t work so I close out of my julia session and open up a new one.
# Check that the package exists
[6e4b80f9] BenchmarkTools v0.4.3
[ad839575] Blink v0.12.0
[336ed68f] CSV v0.5.11
[1313f7d8] DataFramesMeta v0.5.0
[233cd533] HelloWorld v0.1.0 [`../../../Documents/Development/HelloWorld`]
[14b8a8f1] PkgTemplates v0.6.2
[91a5bcdd] Plots v0.26.2
[d330b81b] PyPlot v2.8.2
[1fd47b50] QuadGK v2.1.0
[295af30f] Revise v2.1.10
[1277b4bf] ShiftedArrays v0.5.0
[40c74d1a] TableView v0.4.0
# Load Revise
julia> using Revise
# Load HelloWorld
julia> using HelloWorld
# Check that the change I made earlier is in effect, from
# "Hello, World!" to "Hello!"
julia> HelloWorld.greet()
Hello!
# Edit the file again
edit("src/HelloWorld.jl")
Once again it opens up the editor and change the file, this time to "Hello, Peter!"
. The change is not updated.
Finally I will try by updating the LOAD_PATH
variable. I start a new julia session in the HelloWorld
directory.
julia> push!(LOAD_PATH, "~/Documents/Development")
4-element Array{String,1}:
"@"
"@v#.#"
"@stdlib"
"~/Documents/Development"
# Load Revise
julia> using Revise
# Load HelloWorld
julia> using HelloWorld
[ Info: Recompiling stale cache file /home/peterwd/.julia/compiled/v1.2/HelloWorld/C0i32.ji for HelloWorld [233cd533-293a-414a-b31a-fd2ca2ae87f6]
# See that the output is what it should be
julia> HelloWorld.greet()
Hello, Peter!
julia> edit("src/HelloWorld.jl")
Now I change it back from “Hello, Peter!” to “Hello, World!” once again. It still does not work.
Based on the documentation, these all seem like plausible methods for getting up and running. Finally, I tried not configuring the Template(dir = ".")
command and instead having it appear in .julia/dev
. This also did not work.
I don’t think a complete guide of creating a new package from scratch to using Revise on it exists. Hopefully with some modifications the lengthy MWE above can serve as the basis for such a guide.
Any help is appreciated.