Bash script with limited path












2














I'm trying to write my first bash script to essentially install a bunch of dependencies and then execute a script.



I'm struggling debugging this with the user b/c I'm a dev which means I already have a bunch of tools installed (such as homebrew, ruby, node, etc) and my user has a fresh install of OSX. I want this script to work with all new users with fresh installs of OSX.



I am trying to export a bare bones PATH at the beginning of my script simply for debugging purposes to mimic the users fresh install.



My issue at hand is that I'm not sure how to actually reference node or npm specifically so that I can run npm install.



You can see what my echo's are producing. Any ideas how to properly install node/npm and then execute it?



#!/bin/bash
# Install necessary deps and runs script to create user for the DEV environment.
# Mainly used for non engineers to be able to create their own emails.

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin::/usr/local
echo $PATH

# Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Install node 8
/usr/local/bin/brew install node@8

# Install npm - https://stackoverflow.com/a/36631430/222403
/usr/local/bin/brew postinstall node@8

echo /usr/local/bin/brew --prefix node@8 = $(/usr/local/bin/brew --prefix node@8)
echo which node = $(which node) --> PRINTS which node =
echo which node@8 = $(which node@8) --> PRINTS which node@8 =
echo which npm = $(which npm) --> prints which npm =
....









share|improve this question









New contributor




Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Where are node and npm being installed? It could be that they are updating PATH during the installation process, but that change is not reflected in your script. If you know the install path, use the absolute path (as you have done for brew). You could also try re-sourcing your profile (source ~/.bash_profile, on Mac) as that is where any changes to a user's PATH would be made.
    – baum
    2 days ago
















2














I'm trying to write my first bash script to essentially install a bunch of dependencies and then execute a script.



I'm struggling debugging this with the user b/c I'm a dev which means I already have a bunch of tools installed (such as homebrew, ruby, node, etc) and my user has a fresh install of OSX. I want this script to work with all new users with fresh installs of OSX.



I am trying to export a bare bones PATH at the beginning of my script simply for debugging purposes to mimic the users fresh install.



My issue at hand is that I'm not sure how to actually reference node or npm specifically so that I can run npm install.



You can see what my echo's are producing. Any ideas how to properly install node/npm and then execute it?



#!/bin/bash
# Install necessary deps and runs script to create user for the DEV environment.
# Mainly used for non engineers to be able to create their own emails.

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin::/usr/local
echo $PATH

# Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Install node 8
/usr/local/bin/brew install node@8

# Install npm - https://stackoverflow.com/a/36631430/222403
/usr/local/bin/brew postinstall node@8

echo /usr/local/bin/brew --prefix node@8 = $(/usr/local/bin/brew --prefix node@8)
echo which node = $(which node) --> PRINTS which node =
echo which node@8 = $(which node@8) --> PRINTS which node@8 =
echo which npm = $(which npm) --> prints which npm =
....









share|improve this question









New contributor




Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Where are node and npm being installed? It could be that they are updating PATH during the installation process, but that change is not reflected in your script. If you know the install path, use the absolute path (as you have done for brew). You could also try re-sourcing your profile (source ~/.bash_profile, on Mac) as that is where any changes to a user's PATH would be made.
    – baum
    2 days ago














2












2








2







I'm trying to write my first bash script to essentially install a bunch of dependencies and then execute a script.



I'm struggling debugging this with the user b/c I'm a dev which means I already have a bunch of tools installed (such as homebrew, ruby, node, etc) and my user has a fresh install of OSX. I want this script to work with all new users with fresh installs of OSX.



I am trying to export a bare bones PATH at the beginning of my script simply for debugging purposes to mimic the users fresh install.



My issue at hand is that I'm not sure how to actually reference node or npm specifically so that I can run npm install.



You can see what my echo's are producing. Any ideas how to properly install node/npm and then execute it?



#!/bin/bash
# Install necessary deps and runs script to create user for the DEV environment.
# Mainly used for non engineers to be able to create their own emails.

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin::/usr/local
echo $PATH

# Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Install node 8
/usr/local/bin/brew install node@8

# Install npm - https://stackoverflow.com/a/36631430/222403
/usr/local/bin/brew postinstall node@8

echo /usr/local/bin/brew --prefix node@8 = $(/usr/local/bin/brew --prefix node@8)
echo which node = $(which node) --> PRINTS which node =
echo which node@8 = $(which node@8) --> PRINTS which node@8 =
echo which npm = $(which npm) --> prints which npm =
....









share|improve this question









New contributor




Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm trying to write my first bash script to essentially install a bunch of dependencies and then execute a script.



I'm struggling debugging this with the user b/c I'm a dev which means I already have a bunch of tools installed (such as homebrew, ruby, node, etc) and my user has a fresh install of OSX. I want this script to work with all new users with fresh installs of OSX.



I am trying to export a bare bones PATH at the beginning of my script simply for debugging purposes to mimic the users fresh install.



My issue at hand is that I'm not sure how to actually reference node or npm specifically so that I can run npm install.



You can see what my echo's are producing. Any ideas how to properly install node/npm and then execute it?



#!/bin/bash
# Install necessary deps and runs script to create user for the DEV environment.
# Mainly used for non engineers to be able to create their own emails.

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin::/usr/local
echo $PATH

# Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Install node 8
/usr/local/bin/brew install node@8

# Install npm - https://stackoverflow.com/a/36631430/222403
/usr/local/bin/brew postinstall node@8

echo /usr/local/bin/brew --prefix node@8 = $(/usr/local/bin/brew --prefix node@8)
echo which node = $(which node) --> PRINTS which node =
echo which node@8 = $(which node@8) --> PRINTS which node@8 =
echo which npm = $(which npm) --> prints which npm =
....






linux bash osx path






share|improve this question









New contributor




Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Christopher

10.2k32947




10.2k32947






New contributor




Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Catfish

1113




1113




New contributor




Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Catfish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Where are node and npm being installed? It could be that they are updating PATH during the installation process, but that change is not reflected in your script. If you know the install path, use the absolute path (as you have done for brew). You could also try re-sourcing your profile (source ~/.bash_profile, on Mac) as that is where any changes to a user's PATH would be made.
    – baum
    2 days ago


















  • Where are node and npm being installed? It could be that they are updating PATH during the installation process, but that change is not reflected in your script. If you know the install path, use the absolute path (as you have done for brew). You could also try re-sourcing your profile (source ~/.bash_profile, on Mac) as that is where any changes to a user's PATH would be made.
    – baum
    2 days ago
















Where are node and npm being installed? It could be that they are updating PATH during the installation process, but that change is not reflected in your script. If you know the install path, use the absolute path (as you have done for brew). You could also try re-sourcing your profile (source ~/.bash_profile, on Mac) as that is where any changes to a user's PATH would be made.
– baum
2 days ago




Where are node and npm being installed? It could be that they are updating PATH during the installation process, but that change is not reflected in your script. If you know the install path, use the absolute path (as you have done for brew). You could also try re-sourcing your profile (source ~/.bash_profile, on Mac) as that is where any changes to a user's PATH would be made.
– baum
2 days ago










1 Answer
1






active

oldest

votes


















1














According to the documentation Homebrew will install in /usr/local/bin, so you either need to add :/usr/local/bin to your PATH or run /usr/local/bin/node (and ditto for the other programs).






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Catfish is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492610%2fbash-script-with-limited-path%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    According to the documentation Homebrew will install in /usr/local/bin, so you either need to add :/usr/local/bin to your PATH or run /usr/local/bin/node (and ditto for the other programs).






    share|improve this answer


























      1














      According to the documentation Homebrew will install in /usr/local/bin, so you either need to add :/usr/local/bin to your PATH or run /usr/local/bin/node (and ditto for the other programs).






      share|improve this answer
























        1












        1








        1






        According to the documentation Homebrew will install in /usr/local/bin, so you either need to add :/usr/local/bin to your PATH or run /usr/local/bin/node (and ditto for the other programs).






        share|improve this answer












        According to the documentation Homebrew will install in /usr/local/bin, so you either need to add :/usr/local/bin to your PATH or run /usr/local/bin/node (and ditto for the other programs).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        l0b0

        27.7k17114242




        27.7k17114242






















            Catfish is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Catfish is a new contributor. Be nice, and check out our Code of Conduct.













            Catfish is a new contributor. Be nice, and check out our Code of Conduct.












            Catfish is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492610%2fbash-script-with-limited-path%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

            is 'sed' thread safe

            How to make a Squid Proxy server?