NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 253 forks source link

Package install error and Rollback #1485

Closed RickStrahl closed 8 years ago

RickStrahl commented 8 years ago

I have a problem with a package install on my machine. It appears this problem is isolated as others can install the package just fine.

Specifically this relates to Westwind.Globalization.Web version 2.2.0.

When I install this package on my install of VS2015 with the latest NuGet extension installed using the PM console:

install-package westwind.globalization.web  -version 2.2.0

all the dependencies install, but when the actual package installs the installer just aborts and rolls back everything. There's no useful error message or info that helps me track down what's happening.

The actual output from the install is when adding to a new Empty ASP.NET 4.5.2 project:

PM> install-package westwind.globalization.web -version 2.2.0
Attempting to gather dependencies information for package 'westwind.globalization.web.2.2.0' with respect to project 'WebApplication11', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for package 'westwind.globalization.web.2.2.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'westwind.globalization.web.2.2.0'
Resolved actions to install package 'westwind.globalization.web.2.2.0'
Adding package 'CommonMark.NET.0.9.0' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'CommonMark.NET.0.9.0' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'CommonMark.NET.0.9.0' to 'packages.config'
Successfully installed 'CommonMark.NET 0.9.0' to WebApplication11
Adding package 'Newtonsoft.Json.6.0.8' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'Newtonsoft.Json.6.0.8' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'Newtonsoft.Json.6.0.8' to 'packages.config'
Executing script file 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages\Newtonsoft.Json.6.0.8\tools\install.ps1'
Successfully installed 'Newtonsoft.Json 6.0.8' to WebApplication11
Adding package 'Westwind.Utilities.2.65.0' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'Westwind.Utilities.2.65.0' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'Westwind.Utilities.2.65.0' to 'packages.config'
Successfully installed 'Westwind.Utilities 2.65.0' to WebApplication11
Adding package 'Westwind.Globalization.2.2.0' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'Westwind.Globalization.2.2.0' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'Westwind.Globalization.2.2.0' to 'packages.config'
Successfully installed 'Westwind.Globalization 2.2.0' to WebApplication11
Adding package 'Westwind.Web.2.64.0' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'Westwind.Web.2.64.0' to folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Added package 'Westwind.Web.2.64.0' to 'packages.config'
Successfully installed 'Westwind.Web 2.64.0' to WebApplication11
Install failed. Rolling back...
Package 'Westwind.Globalization.Web 2.2.0' does not exist in project 'WebApplication11'
Removed package 'Westwind.Web 2.64.0' from 'packages.config'
Removed package 'Westwind.Globalization 2.2.0' from 'packages.config'
Removed package 'Westwind.Utilities 2.65.0' from 'packages.config'
Removed package 'Newtonsoft.Json 6.0.8' from 'packages.config'
Removed package 'CommonMark.NET 0.9.0' from 'packages.config'
Package 'Westwind.Globalization.Web 2.2.0' does not exist in folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removing package 'Westwind.Web 2.64.0' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removed package 'Westwind.Web 2.64.0' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removing package 'Westwind.Globalization 2.2.0' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removed package 'Westwind.Globalization 2.2.0' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removing package 'Westwind.Utilities 2.65.0' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removed package 'Westwind.Utilities 2.65.0' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removing package 'Newtonsoft.Json 6.0.8' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removed package 'Newtonsoft.Json 6.0.8' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removing package 'CommonMark.NET 0.9.0' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
Removed package 'CommonMark.NET 0.9.0' from folder 'c:\users\rstrahl\documents\visual studio 2015\Projects\WebApplication11\packages'
install-package : Object reference not set to an instance of an object.
At line:1 char:1
+ install-package westwind.globalization.web -version 2.2.0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Everything is fine until the actual requested package is installed last and then it seems to not be able to find the package.

A few more notes:

How can I debug what's going on with this? I'm baffled why this would work for others but not for me when installing from NuGet, but work fine when installing from a local package source.

Why aren't these packages showing up in my package cache???

emgarten commented 8 years ago

Try clearing %userprofile%.nuget\packages

RickStrahl commented 8 years ago

Deleted - it was there, but after deleting and restarting it's still not working from the official package source. Locally it works.

I don't get what the problem could be - file comparison shows exact same files in the local and remote packages so this is really bizarre.

emgarten commented 8 years ago

Does it work from: install-package westwind.globalization.web -version 2.2.0 -source https://www.nuget.org/api/v2/

Are there any errors related to nuget in your Visual Studio ActivityLog.xml ?

You can also remove %localappdata%/nuget/v3-cache

RickStrahl commented 8 years ago

So I created a new package (had some updates anyway) and that is now working properly. I'll circle back tonight and will try the -source install. But this is all very mysterious since the failing package work in VS2013, for many others and from local install, but not from Web even after blowing away all the the package cache folders.

I guess chalk that one up to Murphy's Law against me again :-)

yishaigalatzer commented 8 years ago

@RickStrahl is there any update on this issue?

We are working on making debugging easier. You have two ways

First

  1. Attach another visual studio
  2. Make sure jit option in debugger is turned off image
  3. Add symbolserver.org to your symbol servers
  4. Turn on first chance exception

Typically you will see some exception being thrown unexpectedly.

Second

  1. Clone git@github.com:NuGet/NuGet.Client.git
  2. Make sure you have the following installed (win 10 tools, ASP.NET 5 Beta 7, Visual Studio SDK)
  3. Run build from the root of the cloned project
  4. Uninstall the nuget extension
  5. Open Nuget.Clients solution
  6. Select vsextension as the default project
  7. Ctrl-F5 (F5 works but it will be a lot slower)
  8. Attach when everything is set up, right before you want to debug
  9. You are now in a good place to debug, and submit a PR if you find the issue

Last

Filed https://github.com/NuGet/Home/issues/1516 to make it easier to clear the cache.

RickStrahl commented 8 years ago

@yishaigalatzer No I never managed to get the package to work on my machine. I tried on another machine and it worked perfectly fine.

I ended up pushing a new, updated package and that works fine now on my machine.

I had a few more complaints from others also running into issues with that particular package but for most people it seemed to just work. Really weird and inconsistent behavior.

yishaigalatzer commented 8 years ago

@RickStrahl that concerns me, the problem is that it is really hard to debug these issues without a repro machine.

There could be one related issue I just fixed last week, and we will release in CommandLine 3.2.1. https://github.com/NuGet/Home/issues/1405

What happens there is that if you run restore, and broke it half way, the transaction for downloading the package is ending up in a corrupt state, and things roll downhill from there. We should release 3.2.1 beta hopefully tomorrow (if not then later this week).

I'm going to close this issue for now, but if you manage to get a repro, the instructions above should be of help to get to the bottom of things. At that point we can re-open this issue or have another issue with more details on what to do.

RickStrahl commented 8 years ago

It wasn't a restore that failed in this case - new install. The first install failed right out, but when it failed it DID take a long time for the packages to load. I ran the original install right after pushing to NuGet so I wonder if the package got pulled before it was fully ready. Regardless though - I cleared all the caches and it still continued to fail.

FWIW, which of the locations is the actual 'system' cache that it pulls from now?

C:\Users\rstrahl.nuget\packages C:\Users\rstrahl\AppData\Local\NuGet\Cache

Looks like the first is the one that things I currently use go into. Anywhere else (other than local caches).