Bug 22024 - mtbserver throws a DirectoryNotFoundException when trying to access ~/Library/Developer/MonoTouch
Summary: mtbserver throws a DirectoryNotFoundException when trying to access ~/Library...
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 3.3
Hardware: PC Mac OS
: High major
Target Milestone: 3.5
Assignee: Jose Miguel Torres
Depends on:
Reported: 2014-08-11 20:48 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2015-01-05 11:20 UTC (History)
8 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Brendan Zagaeski (Xamarin Team, assistant) 2014-08-11 20:48:23 UTC
mtbserver throws a DirectoryNotFoundException when trying to access `~/Library/Developer/MonoTouch` if it doesn't already exist.

## Steps to reproduce

1. Delete `~/Library/Developer/MonoTouch` on the build host.

2. Open a Xamarin.iOS project in Visual Studio to pair to the build host.

3. Select "Tools -> Options -> Xamarin -> iOS Settings -> SDK Synchronization -> Check Now".

## Result

### Exception in mtbserver.log

> [11-Aug-2014 20:26:23] Exception: Exception type: System.IO.DirectoryNotFoundException
> Directory '/Users/macuser/Library/Developer/MonoTouch' not found.
>   at System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) [0x00000] in <filename unknown>:0 
>   at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0 
>   at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0 
>   at MonoTouch.Tools.Utilities.FilesHub.Load () [0x00000] in <filename unknown>:0 
>   at MonoTouch.Tools.Utilities.FilesHub..ctor (Boolean load) [0x00000] in <filename unknown>:0 
>   at Mtb.Server.Commands.StatusSdk.HandleRequest (ILoggingHelper logger, System.Object commandRequestState) [0x00000] in <filename unknown>:0 
>   at Mtb.Server.BaseCommand.OnRequest (System.Net.HttpListenerContext context, System.Object commandRequestState) [0x00000] in <filename unknown>:0 
>   at Mtb.Server.Listener.OnRequest (System.Object state) [0x00000] in <filename unknown>:0 

### Errors and warnings in Visual Studio

> Error   1    Failed to retrieve SDK status from server    Xamarin.iOS Extension
> Warning 2    Failed to obtain information about the remote's profile files. Unable to check SDK status.

## Workaround

Re-create the missing directory on the build host:
mkdir ~/Library/Developer/MonoTouch

## Version information
Xamarin 3.3.47
OS X 10.9.4
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2014-08-12 02:10:59 UTC

This is technically a regression: Xamarin.iOS + XamarinVS 3.0.54 will _create_ the `~/Library/Developer/MonoTouch` folder if it doesn't exist.

**But** it looks like XamarinVS 3.1.228 and XamarinVS 3.3.47 don't actually _use_ this folder anymore during the SDK update process. The folder remains empty after checking for SDK updates, and after completing the SDK sync. So maybe the fix will be as simple as removing the code that tries to access `~/Library/Developer/MonoTouch`.
Comment 6 PJ 2014-08-15 15:38:46 UTC
This was fixed by Daniel for XVS 3.5 with https://github.com/xamarin/XamarinVS/pull/681.
Comment 7 Mohit Kheterpal 2014-08-19 12:15:42 UTC
I have checked this issue and getting same behavior after following steps mention in bug description 

mtbserver log : https://gist.github.com/AkhileshKumar01/a3fca3fb180b8e11dcea

Hence reopening this issue.

Environment info :
Mac : https://gist.github.com/Mohit-Kheterpal/2f0515821c5de959887f

Windows : 
VS 2013
Comment 8 PJ 2014-08-19 12:21:37 UTC
Possibly because the fix was needed on the mtbs side which would mean the mac package used by XI 7.4.0 is out of date.
Comment 9 Adrian Alonso 2014-08-19 12:21:51 UTC
Did you install the latest build host ( or later) as well? Because the fix is in the mac side.
Comment 10 Jose Miguel Torres 2014-08-19 12:22:59 UTC
Did you install the last Xamarin iOS  Build Host package? The fix was made on Mac not on VS addin... please let me know
Comment 11 PJ 2014-08-19 12:24:29 UTC
Well, the Mac package is indeed way out of date:

> $ git clone git@github.com:xamarin/XamarinVS.git
> $ cd XamarinVS && git checkout -b v3.5 origin/v3.5
> $ cd XamarinVS && git reset --hard  26dcb09c8d853ffc6b7e2bc48ffedce62e4f49cf
> $ echo XamarinVS Wrench lane: xamarinvs-mac-v3.5

26dcb09c is from 08-06-2014, 17 commits behind HEAD.
Comment 12 PJ 2014-08-19 12:25:39 UTC
@Alo, @Jose: You must actually bump the version in the Xamarin.iOS build.

There is essentially no fix without actually including the fix into a Xamarin.iOS build.
Comment 13 Adrian Alonso 2014-08-19 12:26:16 UTC
@PJ doing that right now
Comment 14 Mohit Kheterpal 2014-08-20 06:14:16 UTC
*** Bug 22121 has been marked as a duplicate of this bug. ***
Comment 15 PJ 2014-08-20 09:03:29 UTC
The MT bump was merged in https://github.com/xamarin/monotouch/pull/45. Marking as RESOLVED for verification.
Comment 16 Mohit Kheterpal 2014-08-20 10:05:20 UTC
I have checked this issue, after following steps mention in bug description.

I have deleted monotouch folder from mac server  ~/Library/Developer/MonoTouch
and then click on refresh icon in windows VS to connect to mac build host then it connects successfully and generates monotouch folder ~/Library/Developer/MonoTouch

And sdk sync successfully without any error.

Hence closing this issue.

Environment info :
VS 2013
XVS 3.5.39