How can I change PATH? - terminal

Im trying to use git for my very first project on terminal but it says zsh: command not found: git so I tried to download git by downloading homebrew first but guess what it says zsh: command not found: curl. So apparently all commands is not working on my terminal and I have no idea why.
I also tried this export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" but this is only temporary.
How Can I fix my PATH??

Since macOS Catalina, you can define the PATH environment variable in the ~/.zshrc file with:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
you can then add more entries to an existing PATH environment variable with:
export PATH="/usr/local/opt/ruby/bin:$PATH"

Related

Bash command not found on macos

I am unable to run certain (macos) terminal commands after switching back to bash from temporarily using zsh. One of the commands is 'amplify publish' which returns the following error:
bash: amplify: command not found
I have installed the amplify cli globally using: npm install -g #aws-amplify/cli
echo $PATH returns /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
and the contents of my .bashrc file is as follows:
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export EDITOR="code --wait"
Amplify is not the only command that is suddenly missing, but this is the most pressing.
Thanks in advance for your help!
appending that path to the globally installed npm package folder to the current PATH variable solved my issue!

How can I permanently add Homebrew to my PATH?

I have an M1 Mac Mini. Every time I want to use brew in a new terminal, it tells me :
zsh: command not found: brew
So I always do this to solve it :
export PATH=$PATH:/opt/homebrew/bin
But then the next time I open a terminal, this has been forgotten. Is there a way to make it stick? I wonder why the homebrew installation doesn't do this by default? (It does warn me that it's not added to the path during installation).
Thanks!
Create/open the ~/.zshrc file and add this line to it: export PATH=$PATH:/opt/homebrew/bin

Setting up React Native on Mac

I'm trying to install React Native on Mac but I'm not able to get past the first step.
npm install -g expo-cli
This seems to work but when I run the next step expo init AwesomeProject I'm getting this error.
-bash: expo: command not found
I also do not have a .npm-global folder. I'm running npm 6.13.4 on Mac OS X 10.15.2.
This might be a local environment issue.
Your computer should know where to look for the commands you're using, it's likely that your mac is not looking for the correct folder.
In order to expo command works, you must have /Users/yourUser/.npm-global/bin in your $PATH commands.
Open your global bash_profile file vim ~/.bash_profile.
add export PATH=$PATH:~/.npm-global/bin.
Save the changes, and right after in your command line:
source ~/.bash_profile
Now you can try the command again!
Important Note: .bash_profile will run only on login shells. For non-login shells, you would need to create or edit .bashrc with this line above.

command not found after go build

I have install and setup go.
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin
I have created a package at following location.
$HOME/go/src/github.com/shamsher31/gosymbol
I build inside package folder using
go build
It creates binary in bin folder inside GOPATH
But when I try to run package name from command line it gives following error.
symbol: command not found
How can I execute binary from command line ?
You need following configuration for ubuntu.
$ sudo gedit ~/.bashrc
Add the following config
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go;
export PATH=$PATH:$GOPATH/bin;
/usr/local/go/bin will be your go installation path and
$GOPATH/bin will be where your custom build packages will get installed.
I was having a similar problem on OSX, I found this the easiest way to get golang up and running:
With HomeBrew:
brew install go
Then add these to your .bash_profile:
export PATH=$PATH:$GOPATH/bin
export GOPATH=$HOME/.go
For Go latest version go1.13.7 and above
If you have installed Go in its default location, then you no need to set up the GOROOT path.
The default location for Unix or macOS is /usr/local/go and for Windows - c:\Go.
You can verify the path using the command go env.
Note: If you are the getting the same error "command not found", then you need to unset GOROOT.
If you want to set up Go in the preferred location, then you need to export the GOROOT path like this:
export GOROOT="/your/preferred/location"
and
export PATH="$PATH:$GOROOT/bin"
in .bashrc or .bash_profile file.
i was the same problem in mac but i'm using zsh
I was able to solve the problem by editing the file ~/.zsh
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go;
export PATH=$PATH:$GOPATH/bin;
for mac
example I put custom go folder in workspace directory. you could change my custom go directory workspace by your own.
add the following script to .bashrc
export GOROOT="/usr/local/go"
export GOPATH="$HOME/workspace/go"
export PATH="$HOME/workspace/go/bin:$PATH"
then run source .bashrc on your terminal
as icza said
go build leaves the executable in the current working directory.
Maybe help add ./ to you run command.
go build
./symbol
On Windows:
Set $GOPATH env, e.g., $HOME/go
Add $GOPATH/bin into $PATH
It should work now.

grc.bashrc no such file or directory

I am newbie to OSX, I tried to install bash, but when I running the terminal I got this error msg: -bash: /usr/local/Cellar/grc/1.5/etc/grc.bashrc: No such file or directory
so how I can fix it?
Reading the output of brew info grc
grc: stable 1.5
http://korpus.juls.savba.sk/~garabik/software/grc.html
Conflicts with: cc65
Not installed
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/grc.rb
==> Caveats
New shell sessions will start using GRC after you add this to your profile:
source "`brew --prefix`/etc/grc.bashrc"
suggests you look for and remove from your .bash_profile file a line similar to the last line in the output above.
I had the same issue where the shell (in my case zsh) had an error upon starting, which for me appeared after upgrading OS X.
The problem is that the brew command is called before the shell knows where the brew command is stored. To fix it, in your .bash_profile (or .zshrc) move this line:
source "`brew --prefix`/etc/grc.bashrc"
to be after this line:
export PATH=/usr/local/bin:/usr/local/sbin:$PATH

Resources