Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15804] CLI: All commands fail if "node" executable is not actually called "node"

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-01-17T00:35:19.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2014 Sprint 01, 2014 Sprint 01 Core, Release 3.2.1, Release 3.3.0
ComponentsCLI
Labelsn/a
ReporterChris Barber
AssigneeChris Barber
Created2013-11-23T01:21:37.000+0000
Updated2014-01-31T04:35:26.000+0000

Description

On Ubuntu, we found that if node.js is installed via some sort of Debian package, that installs node.js as /usr/bin/nodejs. /usr/bin/node is a symlink to /etc/alternatives/node which is also a symlink to /usr/bin/nodejs. The problem is process.args\[0\] is "node", but process.execPath is "/usr/bin/nodejs". The CLI compares these two to detect if the first arg is the node.js executable, then strip it off. Because "node" != "nodejs", the executable is not stripped off and the error happens.
[ERROR] "/usr/bin/titanium" is an unrecognized command.
or
[ERROR] "/usr/local/bin/titanium" is an unrecognized command.
To fix this, we need to properly resolve process.args\[0\]. That means that the CLI needs to call appc.subprocess.findExecutable(process.argv\[0\], ...) to convert "node" to "/usr/bin/node", then we need to run fs.realpathSync() on that result to resolve the symlinks to "/usr/bin/nodejs" and finally compare that to process.execPath.

Workaround

As a temporary workaround, you can copy /usr/bin/nodejs to /usr/bin/node.

Comments

  1. Chris Barber 2013-12-23

    Here's a Q&A question right after the 3.2 release: http://developer.appcelerator.com/question/160741/titanium-cli-32-doesnt-work-on-ubuntu-because-it-doesnt-strip-the-node-executable-from-the-args.
  2. Chris Barber 2013-12-26

    Here's a Github issue also relating to this problem: https://github.com/appcelerator/titanium/issues/86
  3. Chris Barber 2014-01-07

    Master pull request: https://github.com/appcelerator/titanium/pull/88 3.2.x pull request: https://github.com/appcelerator/titanium/pull/89
  4. Chris Barber 2014-01-15

    Here's another Q&A question related to this issue: http://developer.appcelerator.com/question/161405/unable-to-create-new-project---run-node-help-for-available-commands
  5. Samuel Dowse 2014-01-22

    Verified fixed on: Ubuntu 12.04 LTS Titanium CLI: 3.2.1 (git://github.com/appcelerator/titanium.git#3_2_X) Titanium SDK, build: 3.2.1.v20140121132444 NPM: 1.3.21 Node: 0.10.24 CLI: 3.2.0 did not recognize titanium command and threw error displayed in description CLI: 3.2.1 correctly recognizes the titanium command and works as expected Closing.

JSON Source