简体   繁体   中英

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.

Your problem is that you are not initializing the PATH when you start a new terminal, rather you are setting it in only your current session.

What you want to do is type the following commands:

   cd ~

That will navigate to your home directory

   ls -al

List all files including hidden files. In the list that appears, verify that a file called .zprofile exists.

To create or edit the file, run

   vi .zprofile

to open the file. To move to the end of its contents, hit Shift-G , then (lowercase) O to add a new line and enter insert mode. Now type:

  export PATH=/Users/repos/ringojs/bin:$PATH

at the end of the file.

Press Esc , type :x , and press Return

.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 (ie 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM