Bash script with limited path
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
New contributor
add a comment |
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
New contributor
Where arenode
andnpm
being installed? It could be that they are updatingPATH
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'sPATH
would be made.
– baum
2 days ago
add a comment |
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
New contributor
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
linux bash osx path
New contributor
New contributor
edited yesterday
Christopher
10.2k32947
10.2k32947
New contributor
asked 2 days ago
Catfish
1113
1113
New contributor
New contributor
Where arenode
andnpm
being installed? It could be that they are updatingPATH
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'sPATH
would be made.
– baum
2 days ago
add a comment |
Where arenode
andnpm
being installed? It could be that they are updatingPATH
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'sPATH
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
add a comment |
1 Answer
1
active
oldest
votes
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).
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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).
add a comment |
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).
add a comment |
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).
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).
answered yesterday
l0b0
27.7k17114242
27.7k17114242
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Where are
node
andnpm
being installed? It could be that they are updatingPATH
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'sPATH
would be made.– baum
2 days ago