Description:
Ritu experienced an issue during update to 3.3.0 GA components which resulted in her ti config JSON getting corrupted. The cause or timing of this are not known.
No other team members experienced it during our update testing, so at this point seems isolated to a single system.
When a project is created in Studio in this configuration, the tiapp.xml is not rendered correctly. In addition all commands for the CLI fail, see below for details:
ChangeMeMBA-5:analytics ragrawal$ ti -v
FATAL ERROR: Error: Unable to parse config file
ChangeMeMBA-5:analytics ragrawal$ ti info
FATAL ERROR: Error: Unable to parse config file
To fix the issue, the JSON structure was manually edited to be valid.
Steps to reproduce:
Steps are mostly unknown, but have more detail on config
Configure a system in the following manner:
One latest development version of the SDK in your titanium folder, but no GA 3.3.0
Latest modules from a previous development 3.3.0 build install
Studio 3.3.0 Latest version
GA npm components (acs 1.0.14, CLI 3.2.3, Alloy 1.3.1, titanium-code-preocessor 1.1.1)
Check for Appcelerator updates in studio
Update your NPM components and SDK
Check in terminal "ti config"
Result:
JSON structure is invalid, and the CLI is unable to parse. CLI commands fail, and Studio tiapp.xml editor fails to render (since components are missing from CLI-built project)
Expected Result:
CLI identifies bad structure and offers information on solution
Mentioned on the Q & A forums: http://developer.appcelerator.com/question/176261/update-sdk-330-dont-detect-my-iphone-or-android#comment-215280
Hello Ingo, i also got the invalid config.json upon updating to 3.3.0.GA, mentioned on [http://developer.appcelerator.com/question/176261/update-sdk-330-dont-detect-my-iphone-or-android#comment-215280] Upgrade was done using Titanium Studio on OS X 10.9.4 No error messages during update. config.json prior to update.
config.json after update to 3.3.0GA.
Hope that helps. Greetings, Matthias
Yup, looks like what I got too. Just delete the /Users/mkroeger/Library/Application Support/Titanium/" stuff and the two closing curly braces after.
One thing we know is the path that is getting appended to the end is the "defaultInstallLocation" which is supposed to be under the "sdk" section.
Yes Mark, i already removed these two lines to make it work for me.
Issue is not reproducible for following environment. | Appcelerator Studio | 3.3.0.201407111535 | | Titanium SDK | 3.3.0.GA| | Node | 0.10.28 | | ACS | 1.0.14 | | Alloy | 1.4.0 | | NPM | 1.4.9 | | CLI | 3.3.0 | | Titanium-code-processor | 1.1.1 | | OS | OSX 10.9.4 | *Note:* I encounter the same issue earlier in following situations but I couldn't reproduce again with the same procedures. Scinario 1: ( on Mac OSX, Titanium Studio & Appc Studio) - In my first week in Appcelerator, I set up all the environments for 3.2.3GA release of Titanium studio on my macbook. Everything worked fine. - Then I installed Appcelerator studio 3.2.3 and tried to create a project, I couldn't. So, I ran "ti -v" command and I faced same issue. - I referred forum (https://developer.appcelerator.com/question/161934/issue-with-starting-app-in-titanium-studio) and deleted *config.json* file as suggested by André Maia. Everything started to work smoothly. Scenario 2: ( on Windows 8.1, Appc Studio only) - I was working on one of 3.3.0 RC version. To test something, I reverted my studio 3.2.3 GA release. - Then again reverted to 3.2.0 GA release. After that I updated the studio to 3.2.3 GA again. - Then I faced the issue on the windows machine. - I had to delete the *config.json* file and restart the studio to proceed my intended test. - Then It worked fine. Now I have tried above scenarios but issue *could not be reproducible* again.
Possible fix is to more gracefully handle the error: * Add file locking to the file * When loading the config file, put in a try/catch. * If it crashes during setup, back up config file, and fall back to defaults.
[~skypanther] Can you please take a look at this ticket? Try and do items #2 and #3 (at least), and if you can come up with a solution for #1, try that too.
I'm unable to reproduce on OS X. I cannot reproduce on Windows (Win 8.1, Appcelerator Studio 3.3.0, with starting case of CLI 3.2.3 & Alloy 1.3.1, updated successfully). When loading the config file (#2) -- it's already in a try/catch block. Still investigating #3 (and #1).
I am also unable to reproduce the issue on OS X with the configuration mentioned in the steps to reproduce it.
PR to implement your #3 suggestion of falling back to defaults in the case of config.json being unreadable https://github.com/appcelerator/titanium/pull/151 To test (on OSX): 1. Make a backup copy of ~/.titanium/config.json so you can restore it at the end. 2. Edit ~/.titanium/config.json and add any extra string and a closing } curly brace after the final curly brace in the file to create an invalid JSON structure. 3. Run
ti config
you should see the message "\[ERROR\] Unable to parse config file. Please runti setup
to re-create the configuration file." followed by output of the default configuration data. 4. Runti setup
and use the Quick Setup function to set valid values for your configuration. 5. Runti config
and you should see valid output of the data you just entered (Restore your backup copy when you're done)While working on CLI automation, I ran "ti sdk select stable" command simultaneously for one of my test case to work.After no. of attempts, I found that the config.json file got corrupted.In my case, the file size is reduced to zero bytes. Please find below the environment details. | Appcelerator Studio | 3.4.0.201408210941 | | Titanium SDK | 3.3.0.GA| | Node | 0.10.13 | | ACS | 1.0.16 | | Alloy | 1.4.1 | | NPM | 1.3.2 | | CLI | 3.3.0 | | Titanium-code-processor | 1.1.1 | | OS | OSX 10.9.4 | Error message on terminal: KAGRAWAL-MBP:Expect_Script kagrawal$ ti sdk select stable FATAL ERROR: Error: Unable to parse config file KAGRAWAL-MBP:Expect_Script kagrawal$ ti -v FATAL ERROR: Error: Unable to parse config file KAGRAWAL-MBP:Expect_Script kagrawal$ ti FATAL ERROR: Error: Unable to parse config file KAGRAWAL-MBP:Expect_Script kagrawal$ ti create -h FATAL ERROR: Error: Unable to parse config file KAGRAWAL-MBP:Expect_Script kagrawal$ ti config FATAL ERROR: Error: Unable to parse config file
I also encountered this "FATAL ERROR" on a customer's machine today although the config.json was even correctly formatted when I opened it to attempt edit it. $ open ~/.titanium/config.json [~kagrawal], you may need to remove it manually ($ rm -f ~/.titanium/config.json) to get the CLI working back again. While this might not be the right way to proceed most of the Titanium commands seem to work by except of "ti sdk select" which was unable to select any SDK (verified this via "ti config"). Re-installing the Titanium CLI may not solve the fatal error thrown either.
Pull request: https://github.com/appcelerator/titanium/pull/152
New solution attempted to: * Write to temp file. * Rename temp to replace original.
Thanks [~egomez] for the suggestion.
Verified fix on : Mac OSX 10.9.4 Windows 8.1 Appcelerator Studio, build: 3.4.0.201408291834 Titanium SDK build: 3.4.0.v20140829184521 Titanium CLI, build: 3.4.0-dev Alloy: 1.5.0-dev Edited the config.json file so that the parser would see the file as corrupt and be unable to parse it. The file is then renamed, the default used in its place and the user is alerted to this.