zsh: command not found for all installed programs - zsh

I'm using zsh as my shell on mac OS M1 Pro Monterrey. When I echo my path I get
/Users/vcui/bin:/usr/local/bin:/Users/vcui/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users/vcui/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
However typing in any commands like node or nvm gives me "zsh: command not found". My ~/.zshrc starts with
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
I've also first sourced my ~/.zshrc before running node or nvm.
Since I have the PATH specified in my ~/.zshrc, why are all of the program commands unrecognized?

Related

Shell PATH to R under macOS Big Sur

I have a problem with R CMD under Big Sur. I installed R via default .pkg (not via brew) and I have been using zsh (Z shell) as the default shell. I think that I have a problem with PATH that I am not able to fix.
In Terminal:
~ echo $0
zsh
~ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Users/vanderleidebastiani/.jenv/bin:/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/R.framework/Resources:/Library/Frameworks/R.framework/Resources
~ R CMD
looks ok
In R/RStudio:
> system("echo $0")
sh
> system("echo $PATH")
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/opt/local/bin:/Applications/RStudio.app/Contents/MacOS/postback
> system("R CMD")
sh: R: command not found
Warning message:
In system("R CMD") : error in running command
I can solve this temporarily with Sys.getenv if I include the PATH to "/Library/Frameworks/R.framework/Resources"
Sys.getenv("PATH")
"/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/opt/local/bin:/Applications/RStudio.app/Contents/MacOS/postback"
Sys.setenv(PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/opt/local/bin:/Applications/RStudio.app/Contents/MacOS/postback:/Library/Frameworks/R.framework/Resources")
system("R CMD")
-looks ok
I tried to include the PATH permanently, so I edited .bash_profile, .profile, .zshrc, .bashrc in my home folder (in case "/Users/vanderleidebastiani") to include:
# Setting PATH for R
export PATH="$PATH:/Library/Frameworks/R.framework/Resources"
However, it does not make any effect. The PATH does not recognize after I restart R, it goes back to initial settings.
Do I need to include PATH in another file or I made some mistake in the way to include it?
Best, Vanderlei
To create a new path just do this in MACOS Big Sur
sudo touch ~/.zshrc
sudo nano export PATH=$PATH:/YOUR PATH
crtl + x and save
source ~/.zshrc or close and open the terminal
Check with echo $PATH
I had the same problem but with access to homebrew installed binaries. The fix I found was to modify the global PATH variable in Big Sur.
It turns out if you drop a text file into the /etc/paths.d folder it will be parsed and added to PATH even after a restart of RStudio.
I used sudo nano /etc/paths.d/homebrew to add a text file and pasted in /opt/homebrew/bin and /opt/homebrew/sbin on separate lines. After saving and closing I rebooted RStudio and ran echo $PATH from RStudio's terminal to check that the path had been imported correctly.
Ref:
https://serverfault.com/questions/16355/how-do-i-set-the-global-path-environment-variable-on-os-x

julia command not found even after adding to PATH

I am not able to run a Julia file from the command line despite being able to use Julia fine from inside the REPL and Atom. I receive a zsh: command not found: julia error when I try that. Based on this resource, I ran export PATH="/Applications/Julia-1.4.2.app/Contents/Resources/julia/bin:$PATH" and sudo ln -s /Applications/Julia-1.4.2.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia but it did not resolve the issue. Is there anything else I could try?
edit: I am running macOS Catalina 10.15.5
ls -a /Applications/ showed that the file is actually named Julia-1.4.app

How to hide terminal warning when Oh-my-ZSH plugin can't access external app

I've been using oh-my-zsh for a while and it's working great. I'd like to use the command-line fuzzy finder plugin so I enabled it in .zshrc:
plugins=(fzf)
However if "fzf" is not installed I get a warning when opening my terminal window:
[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
Please add export FZF_BASE=/path/to/fzf/install/dir to your .zshrc
Is there a way to hide that warning message? When I install fzf with "sudo dnf install fzf" the warning dissapears, but maybe I want to clone my dotfiles on a different computer where it is not available and it's not that important to be there.
you should first install fzf, in Mac and i use the following command to install brew install fzf
You need to have fzf installed to use this plugin; otherwise remove it. It won't do anything without first installing fzf. Sudo apt install fzf
You can put the plugins= line inside an if statement that checks for the presence of fzf in your path. For example:
if [[ -n $(command -v fzf) ]] ; then
echo "fzf found, loading oh-my-zsh fzf plugin"
plugins=(vi-mode fzf)
else
echo "no fzf was found in the path"
plugins=(vi-mode)
fi
command -v is similar to which, but is superior for this context as explained in this answer.
The -n makes the [[ ]] evaluate as true whenever the $() produces a non-empty output.
For me, it was also very important that brew itself was in Path of ~/.zshenv like so:
export PATH=/opt/homebrew/bin:$PATH
Installed FZF with brew on an M1 Mac.
Otherwise, the error occurs:
[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc
When you install fzf by using brew, it needs to be set brew env.
You can solve to set PATH for fzf before the line of plugins=(fzf) in .zshrc file.
But, I recommand creating "$HOME/.zprofile" as following.
For m1 Mac.
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"
For, intel Mac
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/usr/local/bin/brew shellenv)"

Opening the atom editor from iTerm2 window is displaying - 'zsh: command not found: atom'

Just installed iTerm2 with oh-my-zsh, with atom already installed..
I have cloned a git repo of mine to use on an older laptop and for some reason oh-my-zsh is not opening my atom on the usual command.
➜ LandingPage git:(master) atom .
zsh: command not found: atom
Tried rectifying it by accessing and changing the .zshrc file but permission is denied. Anyone any suggestions?
Thanks,
Ant
As per this question/answer it looks like atom may not have created a symlink to the atom command.
This has nothing to do with zsh -- the first argument is just telling you the shell, the information after it is the error.
For example on my machine (which doesn't have atom) when running zsh and trying to open a file with atom I get zsh: command not found: atom. When I try the same command with bash, I get bash: atom: command not found.
Let me know if the above link doesn't work! Hopefully this helps.

Rscript: command not found

I'm working with R for a while, and I always worked with Rstudio, I tried just now to run a Rscript command in terminal (I have a mac..) and I got this error-
>Rscript script.R
-bash: Rscript: command not found
when I tried to open R in the terminal I go the same error-
>R
-bash: R: command not found
I can run R code with the Rstudio and the R application, but I know there is a way to run R throw the terminal.
Did I miss something when I installed R on my computer? do I need to add R to my PATH?
thanks in advance!
Steps to run R script through Windows command prompt
Set the PATH variable for Rscript.exein the environment variables. Rscript.exe can be found inside bin folder of R. Set the path for Rscript.exe to use Rscript command in Windows command prompt. To check if Rscript.exe has been set environmentally or not, type Rscript in command prompt. The follwoing message should come.
Go to Command Prompt, set the path where your .R file is there.
Run the following command: Here abcd.R is present under Documents folder. So I set path and then run Rscript abcd.R
For those who stumbled upon this but use a mac, you might find this useful. I recently downloaded and installed R and RStudio through the CRAN site. I didn't do it through homebrew. Since I downloaded this install directly from the site, it DID NOT add the RScript executable to my /usr/local/bin directory.
I have locate on my mac so I did a quick lookup:
locate RScript
And I found it here:
/Library/Frameworks/R.framework/Versions/4.0/Resources/bin/Rscript
What I had to do was create a symbolic link to my /usr/local/bin directory to get it to work:
cd /usr/local/bin
ln -s /Library/Frameworks/R.framework/Versions/4.0/Resources/bin/Rscript Rscript
Now I'm able to run Rscript through the command line. This may help someone else out there.

Resources