Hi. I’m climbing up the wall a bit here. I’ve never created a package before, so I want to create one, simply to work out how to work with packages, but I’ve come to a complete standstill. I’ve viewed about 20 different YouTube tutorials and read several online texts on generating and publishing packages, but can’t get any of them to work for me.
I want to generate a package at an arbitrary location (not necessarily ~/.julia/dev), and publish it to a GitHub repository. I can generate a local package using PkgTemplates, and I can create a GitHub repository, but I can’t seem to link the two. When I try to add the local package, I get the GitHub message “The repository does not seem to exist anymore”.
OK many thanks - that seems to have worked fine, but since those instructions put the package in the .julia/dev directory, I had to do a bit extra. In total, what I did was the folloiwng:
Create an EMPTY repository on github, with my package name followed by .jl
Create the .julia/dev/MyPackage directory with the content inside:
using PkgTemplates
tpl = Template(user=“lmiq”)
tpl(“MyPackage”)
Navigate to the package directory and push content to repository for the first time:
cd ~/.julia/dev/MyPackage
git push --set-upstream origin master
Go to github and clone the new repository into the directory where I actually want it
At this stage I can delete the package from .julia/dev
OK, many thanks to @lmiq and @jlperla . To anyone coming after, I’ve now solved my problem by creating the following little Julia file which I open in VSCode whenever I want to create a new package. I can then do everything from within VSC (and github):
# In GitHub:
# Create empty (!) repository PackageName.jl
# In Julia:
using PkgTemplates
t = Template(user="NiallPalfreyman")
t("PackageName")
# In cmd:
# cd ~/.julia/dev/PackageName
# git push --set-upstream origin master
# In GitHub:
# Clone repository PackageName.jl to required local directory
# In Windows:
# Delete PackageName from ~/.julia/dev
Thanks very much everyone - those are great new resources. There is just one thing that is still puzzling me. In all of these references they say that if you start Julia from within a particular folder like, say, the desktop, then generate will create the package in that folder. Yet that just does not seem to be the case for me. No matter where I start Julia, it always creates the package in ~/.julia/dev. Is this something I’ve omitted in my installation somehow?
Are you using Pkg.generate() or PkgTemplates.generate() ?
The default for Pkg.generate() is to create a folder in the current folder.
The default for PkgTemplates.generate() is to create a folder in ~/.julia/dev (Pkg.devdir())
The interactive menu of PkgTemplates allows you to customize dir.