Titanium JIRA Archive
Alloy (ALOY)

[ALOY-282] Alloy - Syntax error breaks build process

GitHub Issuen/a
Resolution Date2012-09-19T14:45:07.000+0000
Affected Version/sn/a
Fix Version/s2012 Sprint 19, Release 3.0.0
ReporterPedro Enrique


The problem

When building an alloy application through the command line, if there is a syntax error in the code, the build will fail and cannot be run again. The "iphone" folder inside the Resource is missing and needs to be recreated

Steps to reproduce:

1. Create an Alloy app 2. Run it through the command line: _alloy run_ 3. Create a syntax error in index.js, for example _#.index.open()_ instead of _$.index.open()_ 4. Build will fail 5. Fix the error and _alloy run_ again 6. Build will fail again, this time because "iphone" folder is missing, we need to manually recreate it. Note: Not sure if this happens also through Studio, my Studio installation has issues and cannot launch the simulator.


  1. Russell McMahon 2012-09-19

    Did you try "alloy compile" after the fix
  2. Pedro Enrique 2012-09-19

    Here is the fix:
       // Alloy/commands/run/index.js
       var path = require('path'),
       	_ = require("../../lib/alloy/underscore")._,
       	U = require('../../utils'),
       	logger = require('../../common/logger'),
       	titanium = require('../../common/titanium'),
       	fs = require('fs');
       module.exports = function(args, program) {
       	if (!titanium.home) {
       		U.die('run command not supported on platform "' + process.platform + '"');
       	// Validate the input path
       	var inputPath = path.resolve(args.length > 0 ? args[0] : U.resolveAppHome());
       	if (!path.existsSync(inputPath)) {
       		U.die('inputPath "' + inputPath + '" does not exist');
       	// Validate that this is a Titanium alloy-powered project
       	if (U.isTiProject(inputPath)) {
       		if (!path.existsSync(path.join(inputPath,'app'))) {
       			U.die("This project doesn't seem to contain an Alloy app directory");
       	// Check for platform
       	var platform = args[1] || 'iphone';
       	var missingPath = path.resolve('Resources/'+platform);
       	// Check for missing directory
       	if(!path.existsSync(missingPath)) {
       		// Create it if need be
       		console.log(platform + ' does not exist');
       		fs.mkdir(missingPath, 0777, function() {
       			console.log(platform + ' created');
       	//run the project
       	var p = titanium.run(
       		platform, //optional platform
       		program.tiversion, //optional version
       		program.tiSDK //optional SDK direct path
  3. Tony Lukasavage 2012-09-19

    This issue relates to TIMOB-10991. A true solution will come when that ticket is resolved. In the meantime I will attempt to workaround this bug.
  4. Tony Lukasavage 2012-09-19

    Thanks Pedro for the alloy run fix. This will resolve command line usage problems. Need TIMOB-10991 before TiStudio can catch it though. I'll do my best to minimize the situations where this occurs. Syntax errors will not be one of them. ;-)
  5. Tony Lukasavage 2012-09-19

    As fixed as i can get it without TIMOB-10991. The only time it would fail is if you manually delete Resources (or the necessary platform-specific folders) or import a project that has no Resources path and try to run through studio. The nice part is though that alloy run or alloy compile from the command line will recover from any state

JSON Source