Created package is not defiened with using PkgTemplates

Hi,
I tried to create a simple package using PkgTemplates package. I used this template on invenia website to create my package:

t = Template(;
    user="Amirrezz94",
    dir="C:\\Users\\Amirr\\.julia\\dev",
    authors="Amir",
    julia=v"1.5.3",
    plugins=[
        License(; name="MIT"),
        Git(; manifest=true),
        GitHubActions(; x86=true),
        Codecov(),
        Documenter{GitHubActions}(),
    ],
)

and afterwards:

t("MyExample")

to update a repository on my GitHub with the same name and it worked successfully. But when I want to test the package on runtest.jl file, it says:

ArgumentError: Package MyExample not found in current path:
- Run `import Pkg; Pkg.add("MyExample")` to install the MyExample package.

require(::Module, ::Symbol) at loading.jl:893

I also tired import Pkg; Pkg.add("MyExample") which gave me the error:

SystemError: opening file "C:\\Users\\Amirr\\.julia\\registries\\General\\Registry.toml": No such file or directory

my runtest.jl file is like this:

using MyExample
using Test

@testset "MyExample.jl" begin
    # Write your tests here.

    my_f(2,1)
end

I followed this video to create the package.
I would appreciate if anyone could help me on this.

I thing you need to Pkg.develop the new package rather than adding it.

The result is the same and it cannot find Registry.toml file.
I get the same error as before when I use Pkg.develop("MyExample")

SystemError: opening file "C:\\Users\\Amirr\\.julia\\registries\\General\\Registry.toml": No such file or directory.

I checked that path and it seems that I don’t have such file in my .julia folder (Registry.toml).

Hmm, it sounds like you need Pkg.init(), but I thought that was called automatically if it was required. Can you add and import other packages?

Yeah it looks like you have an issue with your registry in general? Do other package manager commands work?

1 Like

I think you are following the general procedure for creating packages, but I wanted to do it through “PkgTemplates.jl”. And yes I can update/add/remove my other packages.

Yes package manager works for all the packages except the one I make with PkgTemplates.

I think it’s because of the fact that when I create a package, the Project.toml and Manifest.toml (which are located at C:\Users\Amirr\.julia\environments\v1.5) don’t get upadated and I cannot see the name of my package there, so, package manager doesn’t define my -new created- package.

this is the message I get when I create a package:

[ Info: Running prehooks
[ Info: Running hooks
 Activating environment at `C:\Users\Amirr\.julia\dev\FirstPkg\Project.toml`
   Updating registry at `C:\Users\Amirr\.julia\registries\General`
No Changes to `C:\Users\Amirr\.julia\dev\FirstPkg\Project.toml` 
No Changes to `C:\Users\Amirr\.julia\dev\FirstPkg\Manifest.toml`
 Activating environment at `C:\Users\Amirr\.julia\environments\v1.5\Project.toml`
 Activating new environment at `C:\Users\Amirr\.julia\dev\FirstPkg\docs\Project.toml`
  Resolving package versions...
Updating `C:\Users\Amirr\.julia\dev\FirstPkg\docs\Project.toml`
  [e30172f5] + Documenter v0.25.5
Updating `C:\Users\Amirr\.julia\dev\FirstPkg\docs\Manifest.toml`
  [ffbed154] + DocStringExtensions v0.8.3
  [e30172f5] + Documenter v0.25.5
  [b5f81e59] + IOCapture v0.1.1
  [682c06a0] + JSON v0.21.1
  [69de0a69] + Parsers v1.0.12
  [2a0f44e3] + Base64
  [ade2ca70] + Dates
  [8ba89e20] + Distributed
  [b77e0a4c] + InteractiveUtils
  [76f85450] + LibGit2
  [8f399da3] + Libdl
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [a63ad114] + Mmap
  [44cfe95a] + Pkg
  [de0858da] + Printf
  [3fa0cd96] + REPL
  [9a3f8284] + Random
  [ea8e919c] + SHA
  [9e88b42a] + Serialization
  [6462fe0b] + Sockets
  [8dfed614] + Test
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
Path `..` exists and looks like the correct package. Using existing path.
  Resolving package versions...
Updating `C:\Users\Amirr\.julia\dev\FirstPkg\docs\Project.toml`
  [eb04945b] + FirstPkg v0.1.0 `..`
Updating `C:\Users\Amirr\.julia\dev\FirstPkg\docs\Manifest.toml`
  [eb04945b] + FirstPkg v0.1.0 `..`
 Activating environment at `C:\Users\Amirr\.julia\environments\v1.5\Project.toml`
[ Info: Running posthooks
[ Info: New package is at C:\Users\Amirr\.julia\dev\FirstPkg