Bash reload to find an executable after installing from a script
up vote
-1
down vote
favorite
I'm trying to write a little shell script to install nvm
and then to install a node version specified in the .nvmrc
file. The installation of nvm
seems to be succesful, but I can not call nvm install
, because $(command -v nvm)
has no output. Also in the terminal, I get the message from the nvm
install.sh
script:
=> Close and reopen your terminal to start using nvm or run the following to use it now:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
fi
source ~/.bash_profile
source ~/.bashrc
if [ -x "$(command -v nvm)" ]; then
nvm install
exit 0
fi
exit 1
How to use the command nvm
in the bash script?
node.js bash shell nvm
|
show 2 more comments
up vote
-1
down vote
favorite
I'm trying to write a little shell script to install nvm
and then to install a node version specified in the .nvmrc
file. The installation of nvm
seems to be succesful, but I can not call nvm install
, because $(command -v nvm)
has no output. Also in the terminal, I get the message from the nvm
install.sh
script:
=> Close and reopen your terminal to start using nvm or run the following to use it now:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
fi
source ~/.bash_profile
source ~/.bashrc
if [ -x "$(command -v nvm)" ]; then
nvm install
exit 0
fi
exit 1
How to use the command nvm
in the bash script?
node.js bash shell nvm
Did you tryhash -r nvm
? Though probably you also need to reload your.bashrc
or.bash_profile
if it made edits to that. ("Do the following" probably explains in more detail what exactly you need, but you don't reveal where this quote is from so I can't check.)
– tripleee
Nov 8 at 11:42
By the way, you should probably simplyexit
to return the result fromnvm
rather than blindly assume it finished successfully.
– tripleee
Nov 8 at 11:43
"You should probably simply exit to return the result from nvm rather than blindly assume it finished successfully" Yes, but for now I only need to callnvm install
. You can assumenvm
is installed successfully.
– BuZZ-dEE
Nov 8 at 11:52
@tripleee I've addedsource ~/.bash_profile
andsource ~/.bashrc
to the script file. Could you clarify whathash -r nvm
does? I get no output forhash -r nvm
in a bash, where I can callnvm
successfully.
– BuZZ-dEE
Nov 8 at 12:01
@tripleee thx now I know whathash -r nvm
does. It solved my problem. :)
– BuZZ-dEE
Nov 8 at 12:09
|
show 2 more comments
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm trying to write a little shell script to install nvm
and then to install a node version specified in the .nvmrc
file. The installation of nvm
seems to be succesful, but I can not call nvm install
, because $(command -v nvm)
has no output. Also in the terminal, I get the message from the nvm
install.sh
script:
=> Close and reopen your terminal to start using nvm or run the following to use it now:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
fi
source ~/.bash_profile
source ~/.bashrc
if [ -x "$(command -v nvm)" ]; then
nvm install
exit 0
fi
exit 1
How to use the command nvm
in the bash script?
node.js bash shell nvm
I'm trying to write a little shell script to install nvm
and then to install a node version specified in the .nvmrc
file. The installation of nvm
seems to be succesful, but I can not call nvm install
, because $(command -v nvm)
has no output. Also in the terminal, I get the message from the nvm
install.sh
script:
=> Close and reopen your terminal to start using nvm or run the following to use it now:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
fi
source ~/.bash_profile
source ~/.bashrc
if [ -x "$(command -v nvm)" ]; then
nvm install
exit 0
fi
exit 1
How to use the command nvm
in the bash script?
node.js bash shell nvm
node.js bash shell nvm
edited Nov 8 at 11:54
asked Nov 8 at 11:29
BuZZ-dEE
1,26422651
1,26422651
Did you tryhash -r nvm
? Though probably you also need to reload your.bashrc
or.bash_profile
if it made edits to that. ("Do the following" probably explains in more detail what exactly you need, but you don't reveal where this quote is from so I can't check.)
– tripleee
Nov 8 at 11:42
By the way, you should probably simplyexit
to return the result fromnvm
rather than blindly assume it finished successfully.
– tripleee
Nov 8 at 11:43
"You should probably simply exit to return the result from nvm rather than blindly assume it finished successfully" Yes, but for now I only need to callnvm install
. You can assumenvm
is installed successfully.
– BuZZ-dEE
Nov 8 at 11:52
@tripleee I've addedsource ~/.bash_profile
andsource ~/.bashrc
to the script file. Could you clarify whathash -r nvm
does? I get no output forhash -r nvm
in a bash, where I can callnvm
successfully.
– BuZZ-dEE
Nov 8 at 12:01
@tripleee thx now I know whathash -r nvm
does. It solved my problem. :)
– BuZZ-dEE
Nov 8 at 12:09
|
show 2 more comments
Did you tryhash -r nvm
? Though probably you also need to reload your.bashrc
or.bash_profile
if it made edits to that. ("Do the following" probably explains in more detail what exactly you need, but you don't reveal where this quote is from so I can't check.)
– tripleee
Nov 8 at 11:42
By the way, you should probably simplyexit
to return the result fromnvm
rather than blindly assume it finished successfully.
– tripleee
Nov 8 at 11:43
"You should probably simply exit to return the result from nvm rather than blindly assume it finished successfully" Yes, but for now I only need to callnvm install
. You can assumenvm
is installed successfully.
– BuZZ-dEE
Nov 8 at 11:52
@tripleee I've addedsource ~/.bash_profile
andsource ~/.bashrc
to the script file. Could you clarify whathash -r nvm
does? I get no output forhash -r nvm
in a bash, where I can callnvm
successfully.
– BuZZ-dEE
Nov 8 at 12:01
@tripleee thx now I know whathash -r nvm
does. It solved my problem. :)
– BuZZ-dEE
Nov 8 at 12:09
Did you try
hash -r nvm
? Though probably you also need to reload your .bashrc
or .bash_profile
if it made edits to that. ("Do the following" probably explains in more detail what exactly you need, but you don't reveal where this quote is from so I can't check.)– tripleee
Nov 8 at 11:42
Did you try
hash -r nvm
? Though probably you also need to reload your .bashrc
or .bash_profile
if it made edits to that. ("Do the following" probably explains in more detail what exactly you need, but you don't reveal where this quote is from so I can't check.)– tripleee
Nov 8 at 11:42
By the way, you should probably simply
exit
to return the result from nvm
rather than blindly assume it finished successfully.– tripleee
Nov 8 at 11:43
By the way, you should probably simply
exit
to return the result from nvm
rather than blindly assume it finished successfully.– tripleee
Nov 8 at 11:43
"You should probably simply exit to return the result from nvm rather than blindly assume it finished successfully" Yes, but for now I only need to call
nvm install
. You can assume nvm
is installed successfully.– BuZZ-dEE
Nov 8 at 11:52
"You should probably simply exit to return the result from nvm rather than blindly assume it finished successfully" Yes, but for now I only need to call
nvm install
. You can assume nvm
is installed successfully.– BuZZ-dEE
Nov 8 at 11:52
@tripleee I've added
source ~/.bash_profile
and source ~/.bashrc
to the script file. Could you clarify what hash -r nvm
does? I get no output for hash -r nvm
in a bash, where I can call nvm
successfully.– BuZZ-dEE
Nov 8 at 12:01
@tripleee I've added
source ~/.bash_profile
and source ~/.bashrc
to the script file. Could you clarify what hash -r nvm
does? I get no output for hash -r nvm
in a bash, where I can call nvm
successfully.– BuZZ-dEE
Nov 8 at 12:01
@tripleee thx now I know what
hash -r nvm
does. It solved my problem. :)– BuZZ-dEE
Nov 8 at 12:09
@tripleee thx now I know what
hash -r nvm
does. It solved my problem. :)– BuZZ-dEE
Nov 8 at 12:09
|
show 2 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
If you want to simply modify the environment with the command given by the script without reloading the whole profile use :
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
grep
will remove the comments starting with =>
and potentially a leading hidden character.
eval
will execute the commands in the current shell.
then do not use -x
since command -v nvm
returns nvm and not the full path.
if [ -n "$(command -v nvm)" ]; then
nvm install
exit $?
fi
And following triplee advice use a bare exit
to keep the return code.
Script becomes:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
fi
if [ -n "$(command -v nvm)" ]; then
nvm install
exit
fi
exit 1
Thx for your annswer.if ! [ -x "$(command -v nvm)" ];
does not work. Even ifnvm
is already installed, the if block is executed.
– BuZZ-dEE
Nov 8 at 12:53
That is what I said, -x check the path when command -v nvm returns nvm. So I changed the test to -n that checks if the string is not empty and then it works well.
– Eric Le Blouc'h
Nov 9 at 15:19
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you want to simply modify the environment with the command given by the script without reloading the whole profile use :
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
grep
will remove the comments starting with =>
and potentially a leading hidden character.
eval
will execute the commands in the current shell.
then do not use -x
since command -v nvm
returns nvm and not the full path.
if [ -n "$(command -v nvm)" ]; then
nvm install
exit $?
fi
And following triplee advice use a bare exit
to keep the return code.
Script becomes:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
fi
if [ -n "$(command -v nvm)" ]; then
nvm install
exit
fi
exit 1
Thx for your annswer.if ! [ -x "$(command -v nvm)" ];
does not work. Even ifnvm
is already installed, the if block is executed.
– BuZZ-dEE
Nov 8 at 12:53
That is what I said, -x check the path when command -v nvm returns nvm. So I changed the test to -n that checks if the string is not empty and then it works well.
– Eric Le Blouc'h
Nov 9 at 15:19
add a comment |
up vote
0
down vote
If you want to simply modify the environment with the command given by the script without reloading the whole profile use :
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
grep
will remove the comments starting with =>
and potentially a leading hidden character.
eval
will execute the commands in the current shell.
then do not use -x
since command -v nvm
returns nvm and not the full path.
if [ -n "$(command -v nvm)" ]; then
nvm install
exit $?
fi
And following triplee advice use a bare exit
to keep the return code.
Script becomes:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
fi
if [ -n "$(command -v nvm)" ]; then
nvm install
exit
fi
exit 1
Thx for your annswer.if ! [ -x "$(command -v nvm)" ];
does not work. Even ifnvm
is already installed, the if block is executed.
– BuZZ-dEE
Nov 8 at 12:53
That is what I said, -x check the path when command -v nvm returns nvm. So I changed the test to -n that checks if the string is not empty and then it works well.
– Eric Le Blouc'h
Nov 9 at 15:19
add a comment |
up vote
0
down vote
up vote
0
down vote
If you want to simply modify the environment with the command given by the script without reloading the whole profile use :
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
grep
will remove the comments starting with =>
and potentially a leading hidden character.
eval
will execute the commands in the current shell.
then do not use -x
since command -v nvm
returns nvm and not the full path.
if [ -n "$(command -v nvm)" ]; then
nvm install
exit $?
fi
And following triplee advice use a bare exit
to keep the return code.
Script becomes:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
fi
if [ -n "$(command -v nvm)" ]; then
nvm install
exit
fi
exit 1
If you want to simply modify the environment with the command given by the script without reloading the whole profile use :
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
grep
will remove the comments starting with =>
and potentially a leading hidden character.
eval
will execute the commands in the current shell.
then do not use -x
since command -v nvm
returns nvm and not the full path.
if [ -n "$(command -v nvm)" ]; then
nvm install
exit $?
fi
And following triplee advice use a bare exit
to keep the return code.
Script becomes:
#!/bin/bash
if ! [ -x "$(command -v nvm)" ]; then
echo 'Installing Node version manager (http://nvm.sh).' >&2
eval "$(curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | grep -E -v "^.?=>")"
fi
if [ -n "$(command -v nvm)" ]; then
nvm install
exit
fi
exit 1
edited Nov 9 at 15:20
answered Nov 8 at 12:43
Eric Le Blouc'h
116
116
Thx for your annswer.if ! [ -x "$(command -v nvm)" ];
does not work. Even ifnvm
is already installed, the if block is executed.
– BuZZ-dEE
Nov 8 at 12:53
That is what I said, -x check the path when command -v nvm returns nvm. So I changed the test to -n that checks if the string is not empty and then it works well.
– Eric Le Blouc'h
Nov 9 at 15:19
add a comment |
Thx for your annswer.if ! [ -x "$(command -v nvm)" ];
does not work. Even ifnvm
is already installed, the if block is executed.
– BuZZ-dEE
Nov 8 at 12:53
That is what I said, -x check the path when command -v nvm returns nvm. So I changed the test to -n that checks if the string is not empty and then it works well.
– Eric Le Blouc'h
Nov 9 at 15:19
Thx for your annswer.
if ! [ -x "$(command -v nvm)" ];
does not work. Even if nvm
is already installed, the if block is executed.– BuZZ-dEE
Nov 8 at 12:53
Thx for your annswer.
if ! [ -x "$(command -v nvm)" ];
does not work. Even if nvm
is already installed, the if block is executed.– BuZZ-dEE
Nov 8 at 12:53
That is what I said, -x check the path when command -v nvm returns nvm. So I changed the test to -n that checks if the string is not empty and then it works well.
– Eric Le Blouc'h
Nov 9 at 15:19
That is what I said, -x check the path when command -v nvm returns nvm. So I changed the test to -n that checks if the string is not empty and then it works well.
– Eric Le Blouc'h
Nov 9 at 15:19
add a comment |
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%2fstackoverflow.com%2fquestions%2f53206859%2fbash-reload-to-find-an-executable-after-installing-from-a-script%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
Did you try
hash -r nvm
? Though probably you also need to reload your.bashrc
or.bash_profile
if it made edits to that. ("Do the following" probably explains in more detail what exactly you need, but you don't reveal where this quote is from so I can't check.)– tripleee
Nov 8 at 11:42
By the way, you should probably simply
exit
to return the result fromnvm
rather than blindly assume it finished successfully.– tripleee
Nov 8 at 11:43
"You should probably simply exit to return the result from nvm rather than blindly assume it finished successfully" Yes, but for now I only need to call
nvm install
. You can assumenvm
is installed successfully.– BuZZ-dEE
Nov 8 at 11:52
@tripleee I've added
source ~/.bash_profile
andsource ~/.bashrc
to the script file. Could you clarify whathash -r nvm
does? I get no output forhash -r nvm
in a bash, where I can callnvm
successfully.– BuZZ-dEE
Nov 8 at 12:01
@tripleee thx now I know what
hash -r nvm
does. It solved my problem. :)– BuZZ-dEE
Nov 8 at 12:09