[TIMOB-15804] CLI: All commands fail if "node" executable is not actually called "node"
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-01-17T00:35:19.000+0000 |
Affected Version/s | Release 3.2.0 |
Fix Version/s | 2014 Sprint 01, 2014 Sprint 01 Core, Release 3.2.1, Release 3.3.0 |
Components | CLI |
Labels | n/a |
Reporter | Chris Barber |
Assignee | Chris Barber |
Created | 2013-11-23T01:21:37.000+0000 |
Updated | 2014-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
.
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.
Here's a Github issue also relating to this problem: https://github.com/appcelerator/titanium/issues/86
Master pull request: https://github.com/appcelerator/titanium/pull/88 3.2.x pull request: https://github.com/appcelerator/titanium/pull/89
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
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.