New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cordova error "App id contains a reserved word, or is not a valid identifier" related to hyphens in app name #3950

Closed
jatsrt opened this Issue Mar 17, 2015 · 13 comments

Comments

Projects
None yet
3 participants
@jatsrt

jatsrt commented Mar 17, 2015

New build 1.0.4

I've completely remove ~/.meteor and /.meteor/loca

Running:
meteor run ios

Get:

Error creating Cordova prject: Error running /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/cordova-scripts/cordova.sh
App id contains a reserved word, or is not a valid identifier.

Error: Error running /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/cordova-scripts/cordova.sh
App id contains a reserved word, or is not a valid identifier.

at execFileSyncOrThrow (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:272:11)
at ensureCordovaProject (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:376:22)
at /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:781:5
at /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/buildmessage.js:327:18
at [object Object]._.extend.withValue (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fiber-helpers.js:115:14)
at /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/buildmessage.js:326:36
at [object Object]._.extend.withValue (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fiber-helpers.js:115:14)
at Object.enterJob (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/buildmessage.js:317:26)
at buildCordova (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:766:16)
at Object.cordova.buildTargets (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:137:3)
at Command.doRunCommand [as func] (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands.js:320:15)
at /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/main.js:1345:23

Error while running for mobile platforms: Error running /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/cordova-scripts/cordova.sh
Current working directory is not a Cordova-based project.

@jatsrt

This comment has been minimized.

jatsrt commented Mar 17, 2015

Executing this logic yeilds a valid app id:

.meteor/packages/meteor-tool/.1.0.42.6fy9sm++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/valid-identifier/valid-identifier.js

@jatsrt

This comment has been minimized.

jatsrt commented Mar 18, 2015

% Running build for platforms: [ 'android', 'ios' ]
% Building the cordova build project          
% Bundling the web.cordova program of the app 
Vulcanize: Adding all imports...             |
Vulcanize: Adding all imports...             -
% Ensuring the cordova build project          
% Cordova build project doesn't exist, creating one
% Running synchronously:  /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/cordova-scripts/cordova.sh [ 'create',
  'cordova-build',
  'com.meteor.app-name',
  'app-name' ]
Error creating Cordova prject: Error running /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/cordova-scripts/cordova.sh
App id contains a reserved word, or is not a valid identifier.


Error: Error running /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/cordova-scripts/cordova.sh
App id contains a reserved word, or is not a valid identifier.


    at execFileSyncOrThrow (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:272:11)
    at ensureCordovaProject (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:376:22)
    at /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:781:5
    at /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/buildmessage.js:327:18
    at [object Object]._.extend.withValue (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fiber-helpers.js:115:14)
    at /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/buildmessage.js:326:36
    at [object Object]._.extend.withValue (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fiber-helpers.js:115:14)
    at Object.enterJob (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/buildmessage.js:317:26)
    at buildCordova (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:766:16)
    at Object.cordova.buildTargets (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands-cordova.js:137:3)
    at buildCommand (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands.js:838:17)
    at Command.main.registerCommand._.extend.name [as func] (/Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands.js:738:12)
    at /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/main.js:1345:23
% Reading the mobile control file             
% Running the mobile control file             
% Copying resources for mobile apps           
% Writing new config.xml                      
% Ensuring that platforms in cordova build project are in sync
% Running synchronously:  /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/cordova-scripts/cordova.sh [ 'platform', 'list' ]
Error while building for mobile platforms: Error running /Users/jake/.meteor/packages/meteor-tool/.1.0.42.1o2guy5++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/cordova-scripts/cordova.sh
Current working directory is not a Cordova-based project.
@jatsrt

This comment has been minimized.

jatsrt commented Mar 18, 2015

so, it is creating a project using 'com.meteor.' instead of using anything that is defined in the mobile-config.js. So since my directory has a invalid char, it is going to be invalid.

@jatsrt

This comment has been minimized.

jatsrt commented Mar 18, 2015

Renaming to a directory without a "-" in the name solves the problem. However, doesn't seem to be the best to assume the project will never have a "-" in the name

@boustanihani

This comment has been minimized.

boustanihani commented Mar 18, 2015

I am getting this too, did you rename the project directory?

@jatsrt

This comment has been minimized.

jatsrt commented Mar 19, 2015

Yes, the project directory name is used in the initial creation of the cordova project. It doesn't seem to have any use after that. But it is verified to have a proper name according to cordova rules.

  1. Rename the directory
  2. Run or build the project, so that .meteor/local is generated
  3. Rename the directory back to the old name
  4. Builds will continue to run

If you remove .meteor/local you need to repeat the process.

@jatsrt jatsrt referenced this issue Mar 19, 2015

Closed

Release 1.0.4 #3814

21 of 23 tasks complete
@boustanihani

This comment has been minimized.

boustanihani commented Mar 19, 2015

Thanks 👍

@glasser glasser changed the title from Error Creating Cordova Project to Cordova error "App id contains a reserved word, or is not a valid identifier" related to hyphens in app name Mar 20, 2015

@glasser

This comment has been minimized.

Member

glasser commented Mar 20, 2015

OK, I have tried meteor create X; cd X; meteor add-platform ios on the four combinations of release 1.0.3.2 and 1.0.4.1, and hyphen in name and hyphen not in name, and I can verify that this fails only with hyphen and 1.0.4.1. This does seem like a regression.

@glasser

This comment has been minimized.

Member

glasser commented Mar 20, 2015

And it's specifically from the app ID (com.meteor. + appName) in ensureCordovaProject, which hits this check added in cordova-lib 4.2.0: apache/cordova-lib@894d476#diff-816eb0deb4190b411703bd428f40cdeeR55 and which is only actually checked at create time (though one could imagine that it ends up being important if the app ID is used for some java thing later). (I mention Java based on the description at https://www.npmjs.com/package/valid-identifier)

My suggestion, following this stack overflow question about Java namespace is that we convert dashes to underscores in ensureCordovaProject. Of course there might be other reasons it won't work, but this is the most common.

@glasser glasser closed this in dabe0ae Mar 20, 2015

@glasser

This comment has been minimized.

Member

glasser commented Mar 20, 2015

Going to release 1.0.4.2 to fix this.

glasser added a commit that referenced this issue Mar 20, 2015

Clean up Cordova app IDs a bit
Starting with cordova-lib 4.2.0 (shipped with Meteor 1.0.4) the cordova
create command checks that app IDs look like Java namespaces.  Clean up
the most obvious ways that our generated app IDs won't look like Java
namespaces (most notably hyphens).

This isn't perfect (eg we don't check for leading digits or
consecutive/leading/trailing dots, or for Java reserved words).  This
check is implemented by the valid-identifier NPM package.

While we're at it, put app ids under `com.meteor.userapps` so that there
are other parts of `com.meteor` available for potential MDG Java work.

Fixes #3950.
@glasser

This comment has been minimized.

Member

glasser commented Mar 20, 2015

Fixed in 1.0.4.2.

@jatsrt

This comment has been minimized.

jatsrt commented Mar 20, 2015

Excellent, much happier now. Confirmed on my side.

@glasser

This comment has been minimized.

Member

glasser commented Mar 20, 2015

Thanks @jatsrt for tracking down that this was a hyphen issue! I'm not sure I would have managed to reproduce it otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment