Search code examples
osx-lionzshringojs

Adding new directory to the $PATH


In order to run new web application using ringojs, it's recommended to add the ringojs bin directory to your PATH environment variable, so i tried like so:

 echo 'export PATH=Users/repos/ringojs/bin:$PATH' >> ~/.profile

Then close and reopen the terminal, and tried to create new ringojs web app as described in the ringo README.

ringo-admin create --google-appengine myapp

However, i got always:

zsh: command not found: ringo-admin

Please note i have set the ant and ivy tools successfully. Am i missing something there? is the way to add to the $PATH incorrect?

Update:

After using Abraham suggestion, here is the .bash_profile content so far:

 <echo message=" test       --> run JUnit and RingoJS tests"/>
        <echo message=" docs       --> generates the API docs"/>
        <echo message=" package    --> creates RingoJS distribution"/>
        <echo message=" dpkg       --> creates RingoJS debian package"/>
        <echo message=" clean      --> clean up compiled resources"/>
    </target>

    <!-- =================================================================== -->
    <!-- Initializes some variables                                          -->
    <!-- =================================================================== -->
    <target name="init">
        <property name="project" value="ringojs"/>
        <property name="version" value="0.9"/>

        <property name="home" value="."/>

        <property name="src" value="${home}/src"/>
        <property name="lib" value="${home}/lib"/>
        <property name="build" value="${home}/build"/>
        <property name="classes" value="${build}/classes"/>
        <property name="docs" value="${home}/docs"/>
        <property name="jsdocs" value="${home}/docs/modules"/>
        <property name="javadocs" value="${home}/docs/java"/>

        <property name="ringo-core.jar" value="${lib}/ringo-core.jar"/>
        <property name="ringo-modules.jar" value="${lib}/ringo-modules.jar"/>

        <property name="debug" value="on"/>
        <property name="optimize" value="on"/>
        <property name="deprecation" value="on"/>

        <property name="testclasses" value=""/>

        <path id="classpath">
            <fileset dir="lib">
                <include name="**/*.jar"/>
                <exclude name="${ringo-core.jar}"/>
            </fileset>
            <pathelement location="${classes}"/>export PATH=Users/repos/ringojs/bin:$PATH' >> ~/.profile

However, i still get the same ringo-admin command not found, even though i closed and reopened the terminal session.


Solution

  • .profile file is sourced only if bash or other POSIX-compatible shell is a login shell. Zsh will source this only if it is invoked using symlink named sh (i.e. in POSIX compatibility mode). .bash_profile is the same, but only for bash. What you need is either adding this line to .zshrc (if you want to use this only in interactive sessions, should be preferred), .zshenv (for all sessions) or (the best if works) just try full system restart with new (with export … line) .zprofile: if there happens to be a login shell launched before normal one, it will work perfectly.

    Note that if you choose to use .zshrc and, especially, .zshenv then you must check that new path is not already there: exported variables are passed to each parent process thus you will easily end up with a sequence of identical directories in $PATH.