Running Node (or any unix cmd line program) from Shell from a LC Stack

David Bovill david at viral.academy
Mon May 9 20:51:08 CEST 2016


Yes - here is the handler you need:

command bash_AddSystemPathsToPATH
> if the platform = "MacOS" then -- and it is recent ???
> put url "file:/etc/paths" into systemPaths
> put token 1 to -1 of systemPaths into systemPathArray
> put $PATH into revPATH
> replace ":" with CR in revPATH
> put systemPathArray & CR & revPATH into combinedPath
> sort combinedPath
> put token 1 to -1 of combinedPath into combinedPath
> split combinedPath with CR and ":"
> put keys (combinedPath) into newPathIndex
> replace CR with ":" in newPathIndex
> put newPathIndex into $PATH
> end if
> return $PATH
> end bash_AddSystemPathsToPATH


Essentially there is a nice easy list of paths on modern OSX systems here:

   -  /etc/paths

What is happening is that unfortunately the $PATH that Livecode sees is not
the same as your users shell - due to varied ways that users systems are
configured.

You want to use the above script on startup to automatically configure your
$PATH in Livecode for things like "brew" and npm.


On 9 May 2016 at 19:09, Mark Waddingham <mark at livecode.com> wrote:

> Yes - I think a 'login' type shell option would help here. (Which, if I
> recall correctly, causes the standard terminal setup scripts to run).
>
> The reason the action of shell is to not use a login shell is because
> otherwise env vars you might want to pass to your new process might get
> clobbered by user settings which is (in general) probably not what you want.
>
> For example if you set PATH temporarily to a specific folder to control
> the environment of your new process, it might be overridden by user
> settings causing breakage the other way. (Particularly if you need to use
> your own env vars which happened to also be set - for other reasons - in a
> user's shell environment).
>
> Sent from my iPhone
>
> > On 9 May 2016, at 00:11, Mark Wieder <mwieder at ahsoftware.net> wrote:
> >
> >> On 05/08/2016 03:06 PM, [-hh] wrote:
> >> On Mac, especially 10.11.x (with SIP enabled) , most user
> >> installations MUST go into "/usr/local/bin".
> >> So adjust the LC global $PATH to shell's $PATH. Minimal:
> >>
> >> on preopenstack
> >>   put "/usr/local/bin:" before $PATH
> >>   -- put ":/usr/local/bin" after $PATH
> >> end preopenstack
> >>
> >> The second line prefers "system installations" before "user
> installations".
> >>
> >> [Is it worth an enhancement request to add "/usr/local/bin" by default
> >> to LC's global $PATH on Mac?]
> >
> > Possibly. Maybe an addendum to
> http://quality.livecode.com/show_bug.cgi?id=10569, although that's four
> years old now (wow - even Mark Waddingham's enhancement requests don't get
> any love).
> >
> > I think the documentation on the shell() command needs some work to
> cover things like this (hint for anyone who wants to take this task on).
> The shell you get when you invoke the shell() command is a bit the same as
> the shell you get in the terminal prompt and a bit not. You're running into
> one of the nots.
> >
> > Another way around this is to specify the absolute path to node instead
> of letting the OS get it from the PATH env variable. You could also change
> the PATh setting in one of the config rc files... I'm not at my Mac right
> now, so I can't tell you which one.
> >
> > --
> > Mark Wieder
> > ahsoftware at gmail.com
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


More information about the use-livecode mailing list