Tag Archives: Cordova

2048 2048 2048 2048 – “The Windows PATH Can Be a Source of 2 Tons of Fun”

tl;dr Keep your Windows 7 PATH under 2048 characters and you’ll be good – don’t and you won’t.  In related news, if you already have a lot of dev tools installed on your PC, look at your path length first if it all gets pear shaped after your VS install…

Now the non-tldr…

I recently decided to give Visual Studio 2015 a spin… Having been working a lot with Ionic (Cordova) apps lately, I was interested to see what Microsoft was bringing to the party on that front (See Here and Here)…

The installation seemingly was going smooth enough, but at the end I was greeted with a lot of yellow exclamation marks – “man, that’s no good!”

Naturally, I start reading into the borked install components, one of which is Nuget… I see a lot of people that appear to have been in the same boat as me with previous RC installs… Now, I was installing the official final MSDN ISO release, but just figured it was in the realm of possibility that some of the issues had been carried over…  So I start following some of the processes that worked for those who’d traveled this path before me…

All of which I concluded without positive or desired results…

In addition to the messed up VS install, I began noticing a lot of other issues with my PC that didn’t exist before the attempted install..  One of the most troubling ones was that none of my environmental variables seemed to properly work anymore – %windir% resulted in a “Windows cannot find”, error as did most every other variable that I tried…

Figuring something surely must be wrong with my path, I start looking there – but nothing jumps out at me and it appears valid… Interestingly enough, from a cmd prompt %path% resulted in a very small substring of my actual PATH value – “definitely sounding like a PATH issue”, I continue to think..

But not knowing what I was looking for, I keep chasing the “VS2015 broke me” assumption via Google… Which keeps me coming up empty handed – after multiple uninstalls and reinstalls.. Keeping in mind that each install/uninstall takes about 2+hr on my quad 3Ghz/16gb dev machine – so not exactly a quick process, nor a resource light one (read: “dev machine very slow”)

After many wasted hours and not being able to shake the feeling that it had more to do with changes made to my PATH during the install more than any other system changes made, I decide to search to see if there is a limit to the PATH length (and if it’s possible to exceed this limit, if such a thing does exist)… It wasn’t until I entered in “Windows 7 path variable length” into the search that I came across this post, which answered everything…

2048 it is…  A number that I probably won’t forget for a long time…  2048….

Now, of course it would have been nice if the VS installer would have warned me of this… It would have been nice if any of the errors that made it into the installer error logs would have even so much as hinted at this… But they didn’t… but in all fairness, I am betting that MS aren’t the only or biggest offenders on this front… Though I do think that if your installer requires PATH updates and then makes them automatically for me, it should probably also ensure that it’s operating within the limits of what’s allowed by the OS… This is especially true when the company behind the installer is also the company behind the 2048 char constraint in place on the OS 😉

-Matt

Ionic – CORS with Live Reload

File this one under ‘lessons learned from hours spent chasing my tail’.

Recently, I’ve been working quite a bit with the Ionic Framework… While I can’t say that I was initially on board for the whole ‘hybrid app’ approach for mobile development, I’ve really grown to love the stack and find it fun to work in. Fun development aside, this isn’t to say that the stack (like any stack) is without its issues – for me currently, it’s the undocumented (or the only-documented-in-a-github-issue) gotchas that can create the largest headaches, as they can often result in an hour or two of tail-chasing.

As you’ve likely gathered from this post’s title, the most recent fun on this front was trying to chase down a CORS issue when testing a tablet application that I am currently writing. In this application, we’ve opted for custom auth headers – adding which caused the CORS issues to rear their ugly head…  In my case, it was specifically issues with Access-Control-Allow-Headers.

“No big deal – Cordova/Phonegap whitelists all domains, so you’re good to go”, right?  As is often the case, “no big deal” can be filed under the category of “famous last words” here…

Not previously known to me, apparently using -l(/livereload) causes a modification to the config.xml at runtime for that build – a modification that removes the ‘*’ whitelisting, which can result in banging your head against CORS issues when interfacing with a REST service during development using livereload…

For the skinny, check out the github issue discussing this – https://github.com/driftyco/ionic-cli/issues/89

Unfortunately, Googling for “Ionic CORS” will provide you with a lot of noise that can result in some tail chasing as you start following suggestions to delete client side default headers or researching server-side solutions to mask the problem… Googling for “livereload CORS” however will take you to some relevant information via Grunt livereload Server discussions.

In the end, it was just easiest to configure my development web server to allow the CORS operations, as I wanted to keep Live Reload capabilities with the least amount of fuss. There are some client side things that you can do (discussed in the linked thread), but as you will find, those are temporary and will need to be done over and over as you develop… I’ve also read some mention of configuring a Grunt proxy server to proxy these requests ‘locally’, but I’ve not been able to investigate that approach, so I can’t really speak to it, though I’d love to get some input on this approach if any readers have any…

Anywhos… I just wanted to put this out there in case “Ionic CORS” led anyone else on a wild goose chase.

Happy Developing!

-Matt