mrward/monodevelop-nuget-addin

Unable to manage packages

Opened this issue · 3 comments

I have tried to create the directory manually. I have given everyone r/w. Is there a way to switch the directory or am I missing something in setup. If there are any other logs or info, please let me know.

I have Mono MDK 3.2.1 installed and Xamarian 4.0.12 (build 3)

System.TypeInitializationException: An exception was thrown by the type initializer for ICSharpCode.PackageManagement.PackageManagementServices ---> System.UnauthorizedAccessException: Access to the path "/Users/chrisyoung/.config/NuGet" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0006c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.2.1/mcs/class/corlib/System.IO/Directory.cs:116
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.2.1/mcs/class/corlib/System.IO/Directory.cs:80
at NuGet.PhysicalFileSystem.EnsureDirectory (System.String path) [0x00000] in :0
at NuGet.PhysicalFileSystem.AddFileCore (System.String path, System.Action1 writeToStream) [0x00000] in <filename unknown>:0 at NuGet.PhysicalFileSystem.AddFile (System.String path, System.Action1 writeToStream) [0x00000] in :0
at NuGet.XmlUtility.CreateDocument (System.Xml.Linq.XName rootName, IFileSystem fileSystem, System.String path) [0x00000] in :0
at NuGet.XmlUtility.GetOrCreateDocument (System.Xml.Linq.XName rootName, IFileSystem fileSystem, System.String path) [0x00000] in :0
at NuGet.Settings..ctor (IFileSystem fileSystem, System.String fileName, Boolean isMachineWideSettings) [0x00000] in :0
at NuGet.Settings.ReadSettings (IFileSystem fileSystem, System.String settingsPath, Boolean isMachineWideSettings) [0x00000] in :0
at NuGet.Settings.ReadSettings (IFileSystem fileSystem, System.String settingsPath) [0x00000] in :0
at NuGet.Settings.LoadUserSpecificSettings (System.Collections.Generic.List`1 validSettingFiles, IFileSystem fileSystem, System.String configFileName) [0x00000] in :0
at NuGet.Settings.LoadDefaultSettings (IFileSystem fileSystem, System.String configFileName, IMachineWideSettings machineWideSettings) [0x00000] in :0
at ICSharpCode.PackageManagement.PackageManagementOptions..ctor (MonoDevelop.Core.Properties properties) [0x00000] in :0
at ICSharpCode.PackageManagement.PackageManagementOptions..ctor () [0x00000] in :0
at ICSharpCode.PackageManagement.PackageManagementServices..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at MonoDevelop.PackageManagement.Commands.ManagePackagesHandler.Run () [0x00000] in :0

Not sure. Looking at the code NuGet is trying to do:

Directory.CreateDirectory(path);

Where the path is "/Users/chrisyoung/.config/NuGet". Without recompiling NuGet.Core.dll there is no way to change the directory being used. My guess is that NuGet needs write access to the parent .config directory.

I tried the following:

  • Everyone r/w access to the parent folder
  • Created the .config and gave everyone r/w access
  • Created the .config/NuGet folder and gave r/w access

All of these had the same result. Is there anything else I could try? Would there be a better spot to post this, since it appears to be a problem with the nuget.core.dll?

Directory.CreateDirectory(...) should work if the directory exists and is read-only.

I would probably create a simple app that just tries to create a directory and try it on different directories with different permissions. Maybe try parts of the path "/Users", "/Users/chrisyoung", etc.

using System;
using System.IO;

namespace DirectoryCreation
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            if (args.Length == 0) {
                Console.WriteLine ("Directory name missing");
                return;
            }

            try {
                string path = args [0];
                Directory.CreateDirectory (path);
            } catch (Exception ex) {
                Console.WriteLine (ex.ToString ());
            }
        }
    }
}

The NuGet.Core source used by the addin is available on GitHub if you want to modify it but it seems like we should be able to get it working without changing the code.