Command not found after setting source in bash script [duplicate]
up vote
1
down vote
favorite
This question already has an answer here:
Can not successfully source .bashrc from a shell script
5 answers
Following the instructions here, and everything works fine manually. However, when I use the instructions in a bash script, I get rbenv command not found
because the source ~/.bashrc
didn't execute correctly. What's going on? Feel like I've run into this before on something else...
*Execute bit is set, ran dos2unix, and have #!/bin/bash
at the top.
#!/bin/bash
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.3.1
command-line bash scripts source
marked as duplicate by muru
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 2 at 4:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
1
down vote
favorite
This question already has an answer here:
Can not successfully source .bashrc from a shell script
5 answers
Following the instructions here, and everything works fine manually. However, when I use the instructions in a bash script, I get rbenv command not found
because the source ~/.bashrc
didn't execute correctly. What's going on? Feel like I've run into this before on something else...
*Execute bit is set, ran dos2unix, and have #!/bin/bash
at the top.
#!/bin/bash
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.3.1
command-line bash scripts source
marked as duplicate by muru
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 2 at 4:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This question already has an answer here:
Can not successfully source .bashrc from a shell script
5 answers
Following the instructions here, and everything works fine manually. However, when I use the instructions in a bash script, I get rbenv command not found
because the source ~/.bashrc
didn't execute correctly. What's going on? Feel like I've run into this before on something else...
*Execute bit is set, ran dos2unix, and have #!/bin/bash
at the top.
#!/bin/bash
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.3.1
command-line bash scripts source
This question already has an answer here:
Can not successfully source .bashrc from a shell script
5 answers
Following the instructions here, and everything works fine manually. However, when I use the instructions in a bash script, I get rbenv command not found
because the source ~/.bashrc
didn't execute correctly. What's going on? Feel like I've run into this before on something else...
*Execute bit is set, ran dos2unix, and have #!/bin/bash
at the top.
#!/bin/bash
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.3.1
This question already has an answer here:
Can not successfully source .bashrc from a shell script
5 answers
command-line bash scripts source
command-line bash scripts source
edited Dec 1 at 22:13
asked Dec 1 at 21:17
user58446
83
83
marked as duplicate by muru
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 2 at 4:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by muru
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 2 at 4:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
That’s because the script subshell doesn‘t run interactively, in which case the ~/.bashrc
is set to do nothing by default. You can either use any of the workarounds explained in this and this answer or simply call rbenv
with the full path on the last line:
$HOME/.rbenv/bin/rbenv install 2.3.1
Note that for Cosmic onwards there’s an rbenv
package in the repositories.
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
accepted
That’s because the script subshell doesn‘t run interactively, in which case the ~/.bashrc
is set to do nothing by default. You can either use any of the workarounds explained in this and this answer or simply call rbenv
with the full path on the last line:
$HOME/.rbenv/bin/rbenv install 2.3.1
Note that for Cosmic onwards there’s an rbenv
package in the repositories.
add a comment |
up vote
0
down vote
accepted
That’s because the script subshell doesn‘t run interactively, in which case the ~/.bashrc
is set to do nothing by default. You can either use any of the workarounds explained in this and this answer or simply call rbenv
with the full path on the last line:
$HOME/.rbenv/bin/rbenv install 2.3.1
Note that for Cosmic onwards there’s an rbenv
package in the repositories.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
That’s because the script subshell doesn‘t run interactively, in which case the ~/.bashrc
is set to do nothing by default. You can either use any of the workarounds explained in this and this answer or simply call rbenv
with the full path on the last line:
$HOME/.rbenv/bin/rbenv install 2.3.1
Note that for Cosmic onwards there’s an rbenv
package in the repositories.
That’s because the script subshell doesn‘t run interactively, in which case the ~/.bashrc
is set to do nothing by default. You can either use any of the workarounds explained in this and this answer or simply call rbenv
with the full path on the last line:
$HOME/.rbenv/bin/rbenv install 2.3.1
Note that for Cosmic onwards there’s an rbenv
package in the repositories.
edited Dec 2 at 8:05
answered Dec 1 at 23:12
dessert
21.5k55896
21.5k55896
add a comment |
add a comment |