Skip to content

Instantly share code, notes, and snippets.

@0xced
Last active September 24, 2019 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xced/3c3aaad7fa879b19e03627793f09a89c to your computer and use it in GitHub Desktop.
Save 0xced/3c3aaad7fa879b19e03627793f09a89c to your computer and use it in GitHub Desktop.
Diagnosing issues when building Nerdle.AutoConfig on Travis CI

I'm submitting a pull request to Nerdle.AutoConfig and Build #103 fails with this error:

Installing Mono
E: Unable to locate package referenceassemblies-pcl
The command "sudo apt-get install -qq mono-complete mono-vbnc fsharp nuget referenceassemblies-pcl" failed and exited with 100 during .

Your build has been stopped.

The log also includes this information:

Operating System Details
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial

In order to reproduce this issue on my Mac, I use Docker with an interactive bash session

docker run --interactive --tty --rm ubuntu:xenial /bin/bash

Then in the container I run:

# apt-get update
Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Get:3 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [956 kB]                                              
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]                                                          
Get:5 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]                                    
Get:6 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB]                  
Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]                          
Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [583 kB]                     
Get:9 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]     
Get:10 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]     
Get:11 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [6114 B]                   
Get:12 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]                                                                                                          
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [1334 kB]                                                                                                       
Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB]                                                                                                 
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [987 kB]                                                                                                    
Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [19.1 kB]                                                                                                 
Get:17 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [7942 B]                                                                                                      
Get:18 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [8807 B]                                                                                                  
Fetched 16.1 MB in 9s (1779 kB/s)                                                                                                                                                          
Reading package lists... Done
# apt-get install referenceassemblies-pcl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package referenceassemblies-pcl

➡️ Problem reproduced, Ubuntu 16.04.6 LTS (Xenial Xerus) can't install referenceassemblies-pcl

Searching for Unable to locate package referenceassemblies-pcl leads to Unable to locate package referenceassemblies-pcl on Stack Overflow. The only answer is not applicable for me since I don't have control on how to install mono on Travis:

I resolved this by following the instructions on how to install mono on the actual mono website.

Another search result is Unable to locate mono packages in Ubuntu 14.04 on Ask Ubuntu. So I'm trying the accepted answer:

  • No need to remove /etc/apt/sources.list.d/mono-xamarin* since /etc/apt/sources.list.d is empty.
  • No need to sudo since I'm root in the docker container.
# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
Executing: /tmp/tmp.567NACctz3/gpg.1.sh --keyserver
hkp://keyserver.ubuntu.com:80
--recv-keys
3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
gpg: requesting key D3D831EF from hkp server keyserver.ubuntu.com
gpg: key D3D831EF: public key "Xamarin Public Jenkins (auto-signing) <releng@xamarin.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
# echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list
deb http://download.mono-project.com/repo/debian wheezy main
# apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://download.mono-project.com/repo/debian wheezy InRelease [4369 B]                                                                           
Hit:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease                                                                                                  
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease                                                                
Get:5 http://download.mono-project.com/repo/debian wheezy/main amd64 Packages [60.0 kB]                                   
Hit:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease                
Fetched 64.4 kB in 0s (123 kB/s)                                                 
Reading package lists... Done

After that, referenceassemblies-pcl can be installed:

# apt-get install referenceassemblies-pcl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
[...]

Can we execute those commands in Travis so that the mono installation succeeds?

Searching for Travis CI run commands before build returns Customizing the Build. I find this:

before_install:
- echo -e "machine github.com\n  login $GITHUB_TOKEN" > ~/.netrc
- git lfs pull

It's totally unrelated to my issue but I think I got the syntax for running commands. So I try to add apt commands in the .travis.yml file:

before_install:
  - sudo rm -f /etc/apt/sources.list.d/mono-xamarin*
  - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  - echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
  - sudo apt-get update

Then Build #104 runs and the Installing Mono phase succeeds but not because of the changes introduced in the .travis.yml file since before_install actually runs after the mono installation!

So I revert the change and force-push. Travis doesn't run when force-pushing so I close and re-open the pull request in order to trigger a new build on Travis. The Unable to locate package referenceassemblies-pcl was a glitch. I could have spared some time by just waiting and retrying instead of messing with apt!

And now, on to the next error in build #105:

dotnet "/home/travis/.nuget/packages/minver/1.2.0/build/../minver/MinVer.dll" --auto-increment "" --build-metadata "" --default-pre-release-phase "" --minimum-major-minor "" --repo "/home/travis/build/edpollitt/Nerdle.AutoConfig/Nerdle.AutoConfig" --tag-prefix "v" --verbosity "" --version-override ""
  
  Unhandled Exception: LibGit2Sharp.NotFoundException: object not found - no match for id (70d9fa918158110d240566adcd8fec857ca3b044)
     at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
     at LibGit2Sharp.Core.Proxy.git_revwalk_next(RevWalkerHandle walker)
     at LibGit2Sharp.CommitLog.CommitEnumerator.MoveNext()
     at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
     at MinVer.Lib.RepositoryExtensions.GetVersion(Repository repo, String tagPrefix, VersionPart autoIncrement, String defaultPreReleasePhase, ILogger log)
     at MinVer.Lib.Versioner.GetVersion(String repoOrWorkDir, String tagPrefix, VersionPart autoIncrement, String defaultPreReleasePhase, ILogger log) in C:\projects\min-ver\MinVer.Lib\Versioner.cs:line 50
     at MinVer.Lib.Versioner.GetVersion(String repoOrWorkDir, String tagPrefix, MajorMinor minMajorMinor, String buildMeta, VersionPart autoIncrement, String defaultPreReleasePhase, ILogger log) in C:\projects\min-ver\MinVer.Lib\Versioner.cs:line 12
     at MinVer.Program.<>c__DisplayClass1_0.<Main>b__0() in C:\projects\min-ver\minver-cli\Program.cs:line 65
     at MinVer.Program.Main(String[] args) in C:\projects\min-ver\minver-cli\Program.cs:line 37
  Aborted (core dumped)

Searching for LibGit2Sharp.NotFoundException: object not found - no match for id leads to issue #1043 on GitVersion's repository with this comment:

It seems it was a shallow clone causing the issue, after doing the full clone seems to be ok, maybe a more descriptive error would be good?

Thanks for you help.

I konw that MinVer searches the commit history so it would make sense that it fails if a commit is missing. Looking at the Travis log we find

git clone --depth=50 https://github.com/edpollitt/Nerdle.AutoConfig.git edpollitt/Nerdle.AutoConfig

It looks like the shallow clone with --depth=50 is what is causing the issue to MinVer. Searching for Travis CI git shallow returns Disadvantages of shallow cloning on Travis and other CI services? on Stack Overflow. And the answer is probably here:

# Or remove the --depth flag entirely with:
git:
  depth: false

Finally, build #106 succeeds and all tests pass. 🎉

The next step will be to submit a pull request on MinVer to transform the LibGit2Sharp.NotFoundException into a better error suggesting to check if the git repository was shallow cloned, maybe even checking if it's running on Travis with the TRAVIS=true environment variable to further improve the error message.

It turns out, the problem doesn't exist anymore in MinVer 2.0.0-alpha.2, i.e. MinVer runs just fine on a shallow clone of depth 50.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment