Allow starting Appium.app from commandline without global install of nodejs #793

Closed
wants to merge 2 commits into
from

Projects

None yet

5 participants

@tokunbo
Contributor
tokunbo commented Jun 20, 2013

WIthout this code modification, Appium.app won't start from the commandline when the machine doesn't have nodejs globally installed. Instead you hit the exception about not being able to find node.

@xuru
Contributor
xuru commented Jun 20, 2013

I would suggest having an array of possible node locations and loop through them in order using fileExists to determine if it's available. Once found, break out of the loop and go own with life, otherwise present the error to the user.

@penguinho
Member

the proper way to do this is with applescript. There is a node path property on Appium.app (for those who don't put i in the applications folder) jlipps already does this somewhere else in the same file

@penguinho
Member

var appScript = [
'try'
, ' set appiumIsRunning to false'
, ' tell application "System Events"'
, ' set appiumIsRunning to name of every process contains "Appium"'
, ' end tell'
, ' if appiumIsRunning then'
, ' tell application "Appium" to return node path'
, ' end if'
, 'end try'
, 'return "NULL"'
].join("\n");
var appNodeWorked = false;
try {
path = sysExec("osascript -e '" + appScript + "'");
appNodeWorked = path !== "NULL";
} catch(e) {}

@tokunbo
Contributor
tokunbo commented Jun 20, 2013

Yeah... that code is in there... it doesn't work when running Appium.app from the command line.
Notice that my code is only hit after that applescript, and 2 other directories, fail to contain node.

@bootstraponline
Member

Is the consensus to merge this or not? It sounds like there are better ways to fix the issue.

@penguinho
Member

I don't think we can hardcoe a guess to the /Application folder, that assumes that's where people put it, which often they don't we should correct this diff to use AppleScript and let LaunchServices find Appium.app

@bootstraponline
Member

use AppleScript and let LaunchServices find Appium.app

That sounds good to me.

@jlipps
Member
jlipps commented Jun 25, 2013

+1 on using applescript if that's more robust. Will that work @tokunbo?

@tokunbo
Contributor
tokunbo commented Jun 25, 2013

@jlipps It already looks to me that it doesn't work. My little code addition is only reached after the failure of applescript and 2 hardcored paths. But, if there's something else that can be done that I'm not aware of, good times.

I just need a way for Appium.app to allow me to start it via commandline without starting the Appium GUI, e.g.

cd /Applications/Appium.app/Contents/Resources/node_modules/appium
../../node/bin/node server.js -U $UUID --app com.companyname.appname --native-instruments-lib -a 0.0.0.0 -p 4444 > $ORIGINAL_WORKDIR/$DEVICENAME.appiumdebug.log 2>&1 &

Any fix that allows me to run Appium.app like the above is okay with me. ^_^

@jlipps
Member
jlipps commented Jun 25, 2013

If you're trying to run stuff from the command line, why bother with appium.app at all?

@tokunbo
Contributor
tokunbo commented Jun 25, 2013

@jlipps
Ah!!! Because I keep screwing up my nodejs install when it comes to appium. So, I just plain skip installing nodejs globally and use the nodejs that's inside the Appium.app folder structure. :-)

@jlipps
Member
jlipps commented Jun 25, 2013

Haha. Well it sounds like there's a much better solution out there for you, in the guise of installing a global node binary that works! I'd rather help you debug that at the hackathon on Monday than build this somewhat odd feature.

@penguinho penguinho closed this Jun 25, 2013
@tokunbo
Contributor
tokunbo commented Jun 25, 2013

penguinho with those ninja-closes.

Well, probably my issues were related to me not understanding the difference between "npm install" versus "sudo npm install" versus "brew install node" versus installing nodejs.dmg or something...

@jlipps
Member
jlipps commented Jun 25, 2013

I recommend brew install node. With that method you never need to sudo npm install anything.

@dichen001 dichen001 referenced this pull request in dichen001/Paper-Reading Jun 28, 2016
Open

Summary of the 20 issues in Herbsleb's 2014 FSE paper. #6

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