Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when running on mono #1984

Closed
borgdylan opened this issue Jan 24, 2016 · 32 comments
Closed

Exception when running on mono #1984

borgdylan opened this issue Jan 24, 2016 · 32 comments

Comments

@borgdylan
Copy link

Using the NuGet 3.4 beta packages on mono yields the exception:

The UTC time represented when the offset is applied must be between year 0 and 10,000.
Parameter name: offset

Such exception hinders the real NuGet client from being used when implementing the dotnet-restore command of the dotnet cli.

@emgarten
Copy link
Member

@borgdylan would provide some repro steps?

@borgdylan
Copy link
Author

I ran a simple restore from a project.json. In packages with more than one target framework I also get key duplication errors. Is Nuget really meant to replace DNX's package restore?

@emgarten
Copy link
Member

What build are you using? Can you share the project.json file?

@borgdylan
Copy link
Author

I am using 3.4.0.517.
This:

{
    "name": "dotnet-compile-dnc",
    "version": "1.0.0-*",
    "compilerName": "dnc",
    "compilationOptions": {
        "emitEntryPoint": true
    },
    "compileFiles": ["dylan.NET.Cli.dyl"],
    "dependencies": {
        "Microsoft.DotNet.Compiler.Common": "1.0.0-*",
        "Microsoft.DotNet.Cli.Utils": "1.0.0-*"
    },
    "frameworks": {
        "net451": {
            "dependencies": {
                "dylan.NET": "11.7.1.1"
            }
        }
    },
    "scripts": {
    }
}

leads to the exception. Other project,json files yield to nuget hanging. It seems to try fetching a package ad infinitum even if there is no hope.

@emgarten
Copy link
Member

How are you executing the restore? Is the restore running on mono, or it is just restoring for mono/net451?

Also what OS are you running on?

@borgdylan
Copy link
Author

I am running restore on mono for Linux x86

@emgarten
Copy link
Member

Would you give me the exact steps you are using to run this and the command on mono?

@borgdylan
Copy link
Author

mono NuGet.exe restore project.json

@yishaigalatzer
Copy link

Can you share your project,json?

Also nuget.exe restore for dnx style project is NOT something we are testing or targeting like I mentioned in our other discussion. This would be something you either run from the .net CLI or from windows (at this point at least),

@borgdylan
Copy link
Author

My project.json has been been shared above. Also, the .NET CLI has switched to shelling to NuGet for restore. If NuGet is not ready for DNX style restore, then the .NET CLI should revert back to shelling to DNX for restore. My issues arise because of their change since teh "NuGet.CommandLine.XPlat" package exhibits the same exceptions when used with more than one target framework which is common for class libraries.

@yishaigalatzer
Copy link

The cli is a place where we are integrating nuget and will keep improving it. However it is not planned to support mono at the moment with the cli

@borgdylan
Copy link
Author

The packages do have dnx451 binaries and I think they should support mono since coreclr does not do normal x86 at the moment. That is why I ported the cli to run on mono.

@yishaigalatzer
Copy link

If only mono was working the same as desktop life would be beautiful. I'm open to taking pull requests on nuget for this if you want to support it, but I have no developers available to invest in this at the moment

@borgdylan
Copy link
Author

If the source can be built no problem under mono I could see what causes the issues for teh xplat cli dll and fix it.

@borgdylan
Copy link
Author

The first thing I would do is to add net451 as a target to NuGet.CommandLine.XPlat, to make building the .NET cli for mono easier (targets net451). See https://github.com/borgdylan/dotnet-cli for the code that I had working.

@emgarten
Copy link
Member

@borgdylan what code are you executing here? NuGet.exe or NuGet.CommandLine.XPlat?

@borgdylan
Copy link
Author

I executed Nuget.exe. However for project.json stuff it would suffice to get either one working.

@yishaigalatzer
Copy link

Dylan will really help nail down the exact scenarios your are tackling.

When you say the cli this means a completely different code base. When your use nuget.exe you need to specify what version, and what build.

Can you help us by rewinding and missing our all the exact details?

@borgdylan
Copy link
Author

I was using Nuget.exe 3.4.0.517.

@yishaigalatzer
Copy link

And did you get the exception from the cli or nuget.exe ?

@borgdylan
Copy link
Author

Both

@borgdylan
Copy link
Author

If I am not mistaken the CLI detects mono and force one http request at any given time. I do not observe this in practice when I run with -p 1 and -v Debug.

@borgdylan
Copy link
Author

After hacking around with mono i.e. setting an env var that DNX used to set I arrive at an exception rather than a hang.

trace: System.AggregateException: One or more errors occurred. ---> System.ArgumentException: An item with the same key has already been added.
  at System.ThrowHelper.ThrowArgumentException (ExceptionResource resource) <0xb51db240 + 0x00036> in <filename unknown>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value, Boolean add) <0xb502a5e0 + 0x00163> in <filename unknown>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value) <0xb5029940 + 0x00033> in <filename unknown>:0 
  at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] (IEnumerable`1 source, System.Func`2 keySelector, System.Func`2 elementSelector, IEqualityComparer`1 comparer) <0xb46b5a08 + 0x000e3> in <filename unknown>:0 
  at System.Linq.Enumerable.ToDictionary[TSource,TKey] (IEnumerable`1 source, System.Func`2 keySelector) <0xb46b5980 + 0x0004f> in <filename unknown>:0 
  at NuGet.Commands.RestoreCommand.CreateLockFile (NuGet.ProjectModel.LockFile previousLockFile, NuGet.ProjectModel.PackageSpec project, IEnumerable`1 targetGraphs, NuGet.Repositories.NuGetv3LocalRepository repository, NuGet.DependencyResolver.RemoteWalkContext context) <0xb3770348 + 0x011f7> in <filename unknown>:0 
  at NuGet.Commands.RestoreCommand+<ExecuteAsync>d__7.MoveNext () <0xb46bc650 + 0x00533> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xb51138e0 + 0x00035> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xb51127e0 + 0x000b7> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xb5112750 + 0x00084> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xb5112700 + 0x0003f> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0xb5112b60 + 0x00024> in <filename unknown>:0 
  at NuGet.CommandLine.XPlat.Program+<ExecuteRestore>d__10.MoveNext () <0xb4f0e1a8 + 0x00b57> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xb51138e0 + 0x00035> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xb51127e0 + 0x000b7> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xb5112750 + 0x00084> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xb5112700 + 0x0003f> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0xb5408110 + 0x0001f> 24302 in <filename unknown>:0 
  at NuGet.CommandLine.XPlat.Program+<>c__DisplayClass6_1+<<Main>b__1>d.MoveNext () <0xb4f0cca8 + 0x0038b> in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) <0xb51c3a10 + 0x00049> in <filename unknown>:0 
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (Boolean waitCompletionNotification) <0xb5402da0 + 0x00089> 24175 in <filename unknown>:0 
  at System.Threading.Tasks.Task`1[TResult].get_Result () <0xb5402d10 + 0x00048> 24173 in <filename unknown>:0 
  at Microsoft.Dnx.Runtime.Common.CommandLine.CommandLineApplication+<>c__DisplayClass68_0.<OnExecute>b__0 () <0xb4f0c9a8 + 0x00023> in <filename unknown>:0 
  at Microsoft.Dnx.Runtime.Common.CommandLine.CommandLineApplication.Execute (System.String[] args) <0xb4f0ba88 + 0x007aa> in <filename unknown>:0 
  at NuGet.CommandLine.XPlat.Program.Main (System.String[] args) <0xb72b5f08 + 0x00353> in <filename unknown>:0 
---> (Inner Exception #0) System.ArgumentException: An item with the same key has already been added.
  at System.ThrowHelper.ThrowArgumentException (ExceptionResource resource) <0xb51db240 + 0x00036> in <filename unknown>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value, Boolean add) <0xb502a5e0 + 0x00163> in <filename unknown>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value) <0xb5029940 + 0x00033> in <filename unknown>:0 
  at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] (IEnumerable`1 source, System.Func`2 keySelector, System.Func`2 elementSelector, IEqualityComparer`1 comparer) <0xb46b5a08 + 0x000e3> in <filename unknown>:0 
  at System.Linq.Enumerable.ToDictionary[TSource,TKey] (IEnumerable`1 source, System.Func`2 keySelector) <0xb46b5980 + 0x0004f> in <filename unknown>:0 
  at NuGet.Commands.RestoreCommand.CreateLockFile (NuGet.ProjectModel.LockFile previousLockFile, NuGet.ProjectModel.PackageSpec project, IEnumerable`1 targetGraphs, NuGet.Repositories.NuGetv3LocalRepository repository, NuGet.DependencyResolver.RemoteWalkContext context) <0xb3770348 + 0x011f7> in <filename unknown>:0 
  at NuGet.Commands.RestoreCommand+<ExecuteAsync>d__7.MoveNext () <0xb46bc650 + 0x00533> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xb51138e0 + 0x00035> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xb51127e0 + 0x000b7> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xb5112750 + 0x00084> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xb5112700 + 0x0003f> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0xb5112b60 + 0x00024> in <filename unknown>:0 
  at NuGet.CommandLine.XPlat.Program+<ExecuteRestore>d__10.MoveNext () <0xb4f0e1a8 + 0x00b57> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xb51138e0 + 0x00035> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xb51127e0 + 0x000b7> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xb5112750 + 0x00084> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xb5112700 + 0x0003f> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0xb5408110 + 0x0001f> 24302 in <filename unknown>:0 
  at NuGet.CommandLine.XPlat.Program+<>c__DisplayClass6_1+<<Main>b__1>d.MoveNext () <0xb4f0cca8 + 0x0038b> in <filename unknown>:0 <---

@borgdylan
Copy link
Author

@yishaigalatzer I tried to build parts of teh nuget clients repo but I failed since the preprocess fails to build with "Microsoft.CodeAnalysis" not being available in the compile module source file.

@emgarten
Copy link
Member

NuGet cannot be built with the CLI yet, only DNX.

After hacking around with mono i.e. setting an env var that DNX used to set I arrive at an exception rather than a hang.

What env var is that?

@borgdylan
Copy link
Author

I set MONO_THREADS_PER_CPU to 50. In my case I also passed -p1 to the CLI. I think the exception is being caused by a stale NuGet cache. This can also happen on Windows machines with prior NuGet versions. Later I will try clearing the and see if the issue persists. I'd rather not have to change the code since I cannot get it to build.

@borgdylan
Copy link
Author

I have cleared the cache, but still the exception persists. NuGet seems to be merging in runtimes from the same package for three times:

trace: Merging in runtimes defined in package/Microsoft.NETCore.Platforms 1.0.1-rc2-23704.
trace: Merging in runtimes defined in package/Microsoft.Win32.Primitives 4.0.1-rc2-23704.
trace: Merging in runtimes defined in package/System.Console 4.0.0-rc2-23704.
trace: Merging in runtimes defined in package/System.Diagnostics.Debug 4.0.11-rc2-23704.
trace: Merging in runtimes defined in package/System.Diagnostics.Process 4.1.0-rc2-23704.
trace: Merging in runtimes defined in package/System.IO.FileSystem 4.0.1-rc2-23704.
trace: Merging in runtimes defined in package/System.Net.Primitives 4.0.11-rc2-23704.
trace: Merging in runtimes defined in package/System.Net.Sockets 4.1.0-rc2-23704.
trace: Merging in runtimes defined in package/System.Runtime.Extensions 4.0.11-rc2-23704.
trace: Merging in runtimes defined in package/System.Runtime.InteropServices.RuntimeInformation 4.0.0-rc2-23704.
trace: Merging in runtimes defined in package/System.Threading 4.0.11-rc2-23704.
trace: Merging in runtimes defined in package/System.Private.Uri 4.0.1-rc2-23728.
trace: Merging in runtimes defined in package/System.Runtime.InteropServices.RuntimeInformation 4.0.0-rc2-23621.
trace: Merging in runtimes defined in package/System.Security.Cryptography.Algorithms 4.0.0-rc2-23704.
trace: Merging in runtimes defined in package/Microsoft.NETCore.Targets 1.0.1-rc2-23704.
trace: Merging in runtimes defined in package/Microsoft.NETCore.Runtime.CoreCLR 1.0.1-rc2-23704.
trace: Merging in runtimes defined in package/System.Private.Uri 4.0.1-rc2-23704.
trace: Merging in runtimes defined in package/System.IO.FileSystem 4.0.1-rc2-23616.
trace: Merging in runtimes defined in package/System.Linq.Expressions 4.0.10.
trace: Merging in runtimes defined in package/System.IO.FileSystem 4.0.1-rc2-23722.
trace: Merging in runtimes defined in package/System.IO.Compression 4.0.0-beta-23109.
trace: Merging in runtimes defined in package/Microsoft.NETCore.Targets.DNXCore 5.0.0-rc2-23704.
trace: Merging in runtimes defined in package/Microsoft.NETCore.Windows.ApiSets 1.0.1-rc2-23704.
trace: Merging in runtimes defined in package/System.Private.Uri 4.0.1-rc2-23616.
trace: Merging in runtimes defined in package/System.Private.Uri 4.0.1-rc2-23728.
trace: Merging in runtimes defined in package/System.Private.Uri 4.0.1-rc2-23728.
trace: Merging in runtimes defined in package/System.Private.Uri 4.0.1-rc2-23722.

I do not think that is OK.

@borgdylan
Copy link
Author

Good News: Using NuGet.CommandLine.XPlat build 566 I managed to overcome the duplicate key bug. Using it with my Mono fork of the the .NET CLI yields a fully functional .NET build toolchain for 32-bit Ubuntu. I have found a separate issue in NuGet.exe for which I will open a separate issue.

@borgdylan
Copy link
Author

Also for the record the winning command line is mono NuGet.CommandLine.XPlat.dll --disable-parallel while setting MONO_THREADS_PER_CPU to 50

@emgarten
Copy link
Member

@borgdylan glad to hear you got it working. There were a lot of fixes that went into 566.

FYI --disable-parallel should be on by default for mono:
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.CommandLine.XPlat/Program.cs#L135

But adding the flag doesn't hurt of course.

Are you still able to get the UTC time exception? I'd like to fix that also.

@borgdylan
Copy link
Author

That is due to bad packages made by Nuget.exe. the xmlns URL overriden in the nuspec should mention 2012/06 not 2011/08.

@borgdylan
Copy link
Author

I opened a specific bug here: #2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants