All bash commands lost after sourcing bash_profile after osx upgrade - linux

I recently upgraded my osx to os x el capitan. I noticed that subl command was missing so I tried adding the path to my bash_profile. It didn't work out so I removed it and then do a source ~/.bash_profile and now all of my bash commands are gone.
Here is my bash_profile file
export $PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
##
# Your previous /Users/judyngai/.bash_profile file was backed up as /Users/judyngai/.bash_profile.macports-saved_2013-06-27_at_16:30:58
##
# MacPorts Installer addition on 2013-06-27_at_16:30:58: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/usr/local/sbin:$path
export PATH=/usr/local/bin:$PATH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
:q!
and when I do export $PATH
I am getting this
31-34-238:bin judyngai$ export $PATH
-bash: export: `/usr/local/bin:/usr/local/sbin:': not a valid identifier
I cd into all of the directories that its getting searched through /usr/local/bin, /bin, /usr/local/bin etc. and saw all of the commands in there.
and this
31-34-238:~ judyngai$ source ~/.bash_profile
-bash: export: `/Users/judyngai/.rbenv/bin:/usr/local/bin:/usr/local/sbin:=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin': not a valid identifier
env: bash: No such file or directory
-bash: :q!: command not found
I actually think my bash_profile is fine so what is wrong? Rbenv and macport both look fine.

This line is destroying your path: export PATH=/usr/local/sbin:$path -- variables are case sensitive.
However, this error
-bash: export:`/usr/local/bin:/usr/local/sbin:': not a valid identifier
Indicates you probably have this in your bash_profile
export PATH=/usr/local/sbin:$path # PATH=/usr/local/sbin:
export PATH=/usr/local/bin:$PATH # PATH=/usr/local/bin:/usr/local/sbin:
export $PATH="$HOME/.rbenv/bin:$PATH"
# .....^
Where you are substituting the variable on the left-hand side instead of providing the variable name.
You export a variable (name), not a variable's value.

Related

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

On executing sudo ./startup.sh in CentOS, I am getting the following error:
"Neither the JAVA_HOME nor the JRE_HOME environment variable is
defined"
But I have already defined it in bashrc in the following way:
export JAVA_HOME=/home/manish/New_learning/jdk1.8.0_212
export PATH=$JAVA_HOME/bin:$PATH
When you define it in your .bashrc file, it will be OK and well defined for your user.
When you launch the command with sudo, it runs as super-user/root, and NOT as your user; so your .bashrc file is 'useless' in this case.
You should update your environment with a system file like something under /etc/profile.d for instance:
sudo touch /etc/profile.d/variousPath.sh
sudo chown bsquare /etc/profile.d/variousPath.sh
cat >> /etc/profile.d/variousPath.sh <<EOF
export JAVA_HOME=/home/manish/New_learning/jdk1.8.0_212
export PATH=$JAVA_HOME/bin:$PATH
EOF
Reboot your computer, and your SYSTEM environment will know $JAVA_HOME.
Please Add in
../tomcat/bin/startup.sh
script with below java parameters syntax :
JAVA_HOME=/JDK/path/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export PATH
export JAVA_HOME
Example
JAVA_HOME=/appl/prod/Protine/tomcat/jdk1.5.0_16/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export PATH
export JAVA_HOME
It's working for me , hope it will work for you too.

Moving PATH to my .bashrc?

Following this guide,
I don't get the last line :
Don't forget to add the PATH to your .bashrc to make it permanent.
What exactly should I be doing ?
The statement you quoted is about the export PATH=$PATH:/usr/local/bin line from
For testing add /usr/local/bin to your path
export PATH=$PATH:/usr/local/bin
node -v
npm -v
The fragment PATH=$PATH:/usr/local/bin adds the path /usr/local/bin to the content of the PATH environment variable. This variable is used by the shell (bash) to search for executable programs.
The export in front of it tells bash to forward the updated PATH variable to all programs it launches.
Adding the line to .bashrc makes it run again every time you start a new bash instance (the environment variables are not stored anywhere, their values are set when bash starts).
/usr/local/bin is a standard path. Most probably you don't have to add that line to .bashrc or execute it at all. Use echo $PATH to check. If its output already contains /usr/local/bin (or contains it twice if you already executed the line above) then you don't need to do anything else. bash is able to find node and npm.
If /usr/local/bin is not in the output of echo $PATH (or it is only once after you have executed export PATH=$PATH:/usr/local/bin then run:
echo 'export PATH=$PATH:/usr/local/bin' >> ~/.bashrc
to put export PATH=$PATH:/usr/local/bin on a new line at the end of ~/.bashrc.

centos7 “export: command not found

I have followed a tutorial to install JDK 8 on my computer Centos7 OS, but in the last part I tried to set environment varibles.
In the last part of the tutorial I typed:
echo “export JAVA_HOME=/opt/jdk1.8.0_101” > /etc/profile.d/jre.sh
echo “export JRE_HOME=/opt/jdk1.8.0_101/jre” >> /etc/profile.d/jre.sh
echo “export PATH=$PATH:/opt/jdk1.8.0_101/bin:/opt/jdk1.8.0_101/jre/bin” >> /etc/profile.d/jre.sh
and then I am seeing this when I open the terminal:
bash: $'\342\200\234export':order not found
bash: $'\342\200\234export': order not found
bash: $'\342\200\234export': order not found
[evconsul8#localhost ~]$
Path:
[evconsul8#localhost ~]$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/evconsul8/.local/bin:/home/evconsul8/bin
After that I Trying to search the cause open
~/.bash_profile
[root#localhost evconsul8]# gedit ~/.bash_profile
Result:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export JAVA_HOME=/opt/jdk1.8.0_101
export JRE_HOME=/opt/jdk1.8.0_101/jre
export PATH=$PATH:/opt/jdk1.8.0_101/bin:/opt/jdk1.8.0_101/jre/bin
export PATH
Note: In one of my attemps after the error I added manually the lines corresponding to JAVA_HOME, JRE_HOME and PATH=$PATH in the file above. It was ok??
The principal problem I guess it is causing troubles to other apps in my machine.
You should use regular double quotes (") to enclose a string and not the fancy ones (“) you are using.

linux bash error: -bash: No such file or directory

After I login to Linux every time, it shows :
-bash: /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/xx/bin: No such file or directory
I notice that there is a '=' in it, but I don't know why.
My .bash_profile:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
$PATH=$PATH:$HOME/bin
export PATH
export JAVA_HOME=/opt/jdk1.8.0_73
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
I want to set the JAVA environment , and it works ,but after I edit profile,it shows the bash error.
How could I fix it?
$PATH=$PATH:$HOME/bin does not do what you want. After substituting the values for variables (PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin and HOME=/home/xx) it executes a command:
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/xx/bin
which explains the error.
To do a variable assignment, remove $ from variable name on the left side of the assignment:
PATH=$PATH:$HOME/bin

Why still says no GOPATH though i've set it?

Both GoSublime and vim-go tells me that GOPATH isn't set, however I've already done this.
my ~/.bashrc:
export GOPATH=$HOME/gopath
export PATH="$PATH:$GOPATH/bin"
and I can use go get to install gocode to my ~/gopath/bin
but it prints that: ...:/home/myusrname/gopath/bin: No such file or directory
for
~$ $PATH
~$ $PATH
is trying to execute your $PATH string, i.e. it's equivalent to writing the contents of the $PATH variable into the console and pressing enter. That results in the error you're seeing.
What you want is
~$ echo $PATH
finally i got it: i have to open gvim through shell with $GOPATH set - -!
You can try to start gvim with the command:
bash -lc gvim
It then starts gvim with the settings in your .bashrc file.
This is from https://github.com/fatih/vim-go/issues/468
In my case, I added GOPATH in my .profile
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
And restart my Unbuntu 16.04
Then for my vim-go, I installed the vim-go by the following command in gvim
:GoInstallBinaries

Resources