Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17346] CLI: Ti config JSON corrupted resulting in inability to run CLI commands

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2014-08-30T01:32:12.000+0000
Affected Version/sRelease 3.3.0
Fix Version/sRelease 3.4.0
ComponentsCLI
Labelsqe-3.3.0
ReporterEric Merriman
AssigneeChris Barber
Created2014-07-17T22:24:56.000+0000
Updated2014-09-14T20:14:32.000+0000

Description

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

Attachments

FileDateSize
Screen Shot 2014-07-17 at 11.26.29 AM.png2014-07-17T22:24:56.000+0000200068

Comments

  1. Mark Mokryn 2014-07-18

  2. Ingo Muschenetz 2014-07-18

    Mentioned on the Q & A forums: http://developer.appcelerator.com/question/176261/update-sdk-330-dont-detect-my-iphone-or-android#comment-215280
  3. Matthias Kroeger 2014-07-19

    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.
       {
       	"user": {
       		"locale": "en-us"
       	},
       	"app": {
       		"workspace": "",
       		"sdk": "latest"
       	},
       	"cli": {
       		"colors": true,
       		"completion": false,
       		"logLevel": "info",
       		"prompt": false,
       		"progressBars": true,
       		"failOnWrongSDK": false,
       		"httpProxyServer": "",
       		"rejectUnauthorized": true,
       		"width": 100,
       		"ignoreDirs": "^(\\.svn|_svn|\\.git|\\.hg|\\.?[Cc][Vv][Ss]|\\.bzr|\\$RECYCLE\\.BIN)$",
       		"ignoreFiles": "^(\\.gitignore|\\.npmignore|\\.cvsignore|\\.DS_Store|\\._.*|[Tt]humbs.db|\\.vspscc|\\.vssscc|\\.sublime-project|\\.sublime-workspace|\\.project|\\.tmproj)$",
       		"quiet": false
       	},
       	"paths": {
       		"commands": [],
       		"hooks": [
       			"/usr/local/lib/node_modules/rapiddev/plugin/rapiddev/hooks"
       		],
       		"modules": [
       			"/usr/local/lib/node_modules/rapiddev/module"
       		],
       		"plugins": [],
       		"sdks": [
       			"/Volumes/MacData/BB10TitaniumStudio/TitaniumSDK/",
       			"/Volumes/MacData/BB10TitaniumStudio/TitaniumSDK"
       		]
       	},
       	"android": {
       		"sdkPath": "/Users/mkroeger/android-sdk"
       	}
       }
       
    config.json after update to 3.3.0GA.
       {
       	"user": {
       		"locale": "en-us"
       	},
       	"app": {
       		"workspace": "",
       		"sdk": "latest"
       	},
       	"cli": {
       		"colors": true,
       		"completion": false,
       		"logLevel": "info",
       		"prompt": false,
       		"progressBars": true,
       		"failOnWrongSDK": false,
       		"httpProxyServer": "",
       		"rejectUnauthorized": true,
       		"width": 100,
       		"ignoreDirs": "^(\\.svn|_svn|\\.git|\\.hg|\\.?[Cc][Vv][Ss]|\\.bzr|\\$RECYCLE\\.BIN)$",
       		"ignoreFiles": "^(\\.gitignore|\\.npmignore|\\.cvsignore|\\.DS_Store|\\._.*|[Tt]humbs.db|\\.vspscc|\\.vssscc|\\.sublime-project|\\.sublime-workspace|\\.project|\\.tmproj)$",
       		"quiet": false
       	},
       	"paths": {
       		"commands": [],
       		"hooks": [
       			"/usr/local/lib/node_modules/rapiddev/plugin/rapiddev/hooks"
       		],
       		"modules": [
       			"/usr/local/lib/node_modules/rapiddev/module"
       		],
       		"plugins": [],
       		"sdks": [
       			"/Volumes/MacData/BB10TitaniumStudio/TitaniumSDK/",
       			"/Volumes/MacData/BB10TitaniumStudio/TitaniumSDK"
       		]
       	},
       	"android": {
       		"sdkPath": "/Users/mkroeger/android-sdk"
       	},
       	"sdk": {
       		"selected": "3.3.0.GA"
       	}
       }/Users/mkroeger/Library/Application Support/Titanium/"
       	}
       }
       
    Hope that helps. Greetings, Matthias
  4. Mark Mokryn 2014-07-19

    Yup, looks like what I got too. Just delete the /Users/mkroeger/Library/Application Support/Titanium/" stuff and the two closing curly braces after.
  5. Chris Barber 2014-07-19

    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.
  6. Matthias Kroeger 2014-07-19

    Yes Mark, i already removed these two lines to make it work for me.
  7. Kajenthiran Velummaylum 2014-07-21

    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.
  8. Ingo Muschenetz 2014-08-20

    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.
  9. Ingo Muschenetz 2014-08-27

    [~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.
  10. Tim Poulsen 2014-08-27

    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).
  11. Khushbu Agrawal 2014-08-28

    I am also unable to reproduce the issue on OS X with the configuration mentioned in the steps to reproduce it.
  12. Tim Poulsen 2014-08-28

    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 run ti setup to re-create the configuration file." followed by output of the default configuration data. 4. Run ti setup and use the Quick Setup function to set valid values for your configuration. 5. Run ti config and you should see valid output of the data you just entered (Restore your backup copy when you're done)
  13. Khushbu Agrawal 2014-08-29

    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
  14. Eduardo Gomez 2014-08-29

    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.
  15. Chris Barber 2014-08-30

    Pull request: https://github.com/appcelerator/titanium/pull/152
  16. Ingo Muschenetz 2014-08-30

    New solution attempted to: * Write to temp file. * Rename temp to replace original.
  17. Khushbu Agrawal 2014-08-30

    Thanks [~egomez] for the suggestion.
  18. Ewan Harris 2014-09-02

    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.

JSON Source