Travis: Cannot add package with the same name or uuid as the project


#1

I am trying to set up a new package. I am using what I believe to be a standard Travis script as per
https://github.com/JuliaLang/Example.jl/blob/master/.travis.yml

- julia -e 'using Pkg; Pkg.add(pwd()); Pkg.build("ImagePhaseCongruency"); Pkg.test("ImagePhaseCongruency"; coverage=true)'

However I end up with the error

ERROR: Cannot add package with the same name or uuid as the project

I have no understanding of how the error comes about, or how I might address it. I have, indeed, been developing the package in a project of the same name but this would appear to be the standard thing to do as suggested in the documentation
https://docs.julialang.org/en/v1/stdlib/Pkg/#Creating-your-own-packages-1

To avoid the Pkg.clone() deprecation message I have also been using

 - julia -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/peterkovesi/ImagePhaseCongruency.jl")); Pkg.build("ImagePhaseCongruency"); Pkg.test("ImagePhaseCongruency"; coverage=true)'

This results in the same error on Travis. However when I run this command from a terminal directly on my machine using a bare installation of v1.0.1 with no packages installed it does result in a successful build of my package.

Looking at other (somewhat dated) mentions of this error in Discourse don’t seem to give me any clues. I presume I am missing something simple and obvious.


#2

What you quote here is not in that file though? Example.jl uses the default script defined here: https://github.com/travis-ci/travis-build/blob/0cd568983d56387426cf94cbb60a5dd11c8e6e1b/lib/travis/build/script/julia.rb#L82-L92 which boils down to the following on Julia v0.7/v1.0 (if you have a Project.toml file):

julia --color=yes -e 'using Pkg; Pkg.build()'
julia --check-bounds=yes --color=yes -e 'using Pkg; Pkg.test(coverage=true)'

This happens because Travis runs with pwd set to the already cloned repo. And you are thus trying to add the package to the package itself, hence the error. You can mimic this locally by starting Julia in your package folder as julia --project=@. which will start julia with the package as its “active project”.


#3

Thank you so much! I was just about in tears trying to get things to go. Re-reading the Pkg documentation I can now (start to) see how things work with the new Project framework. However ultimately I feel some more documentation and examples would be useful for noobs such as me. Also, I have not been able to find where the --project switch is documented nor is it listed when you run julia --help. Anyway, thanks once again!


#4

Yea, fortunately this has now been documented, and it should be in the upcoming v1.0.2 release. (See https://github.com/JuliaLang/julia/pull/28556, https://github.com/JuliaLang/julia/pull/29497 and https://github.com/JuliaLang/julia/pull/29731.)