"command not found: pyenv" when called by zsh script - shell

I have made a launcher on my xubuntu desktop which calls a script named dev_blog.sh.
dev_blog.sh contains :
#!/usr/bin/zsh
echo ça marche
pyenv activate zinnia
/usr/bin/zsh
When I call the launcher from the desktop, my terminal opens and I can read :
dev_blog.sh:3: command not found: pyenv
Whereas when I type the same line in the same terminal, it works.
Here's the content of my .zshrc :
export ZSH=/home/proph73/.oh-my-zsh
ZSH_THEME="agnoster"
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
source $ZSH/oh-my-zsh.sh`

PATH="$HOME/bin:$HOME/.local/bin:$PATH" move this to your .profile or use the full path to the executable in your shortcut $(which pyenv)

Related

iTerm2 "send text at start" is displaying once at start and then executing again in zsh

iTerm2 zsh session starting
The above image shows the representation of the problem.
I use zsh with ohmyzsh and starship.
I disabled ohmyzsh and starship and still i got the same result.
Even though I presented iTerm2 here I get this behavior in vscode terminal and mac terminal too depending on whether there is a startup text or command initiated with the respective programs.
This is my .zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
PATH=/opt/homebrew/bin:$PATH
export PATH
PATH="/Library/Frameworks/Python.framework/Versions/3.10/bin:${PATH}"
export PATH
and this is part of .zshrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
I've also commented out etc/zshrc and etc/zprofile in speculation of them interfering. and they were unsuccessful too.
What would be the problem and how can I resolve this.
Thanks in advance.

PYTHONPATH environment variable not saving on macOS

Running echo $PYTHONPATH returns a blank line:
freddy#dave ~ % echo $PYTHONPATH
freddy#dave ~ %
echo $PATH returns properly
freddy#dave ~ % echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin: ...
.bash_profile for user freddy:
# Fig pre block. Keep at the top of this file.
export PATH="${PATH}:${HOME}/.local/bin"
eval "$(fig init bash pre)"
# Use Python 3.10, not homebrew
export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10"
export PATH="/opt/homebrew/bin:${PATH}"
source ~/.bash_profile
# Fig post block. Keep at the bottom of this file.
eval "$(fig init bash post)"%
Why does echo $PYTHONPATH return nothing? And how do I assign it to my Python3.10 path?
I've tried restarting, this does not help
I've run source ~/.bash_profile (this just closes the terminal after execution though?)
A test variable: export TEST="TEST" also echos a blank line
As the comment suggests, I'm trying to use Python3.10 instead of my Homebrew installation, which is for some system packages
I am using zsh, not bash.
I moved PYTHONPATH to .zshrc and it saves as an environment variable now.
However, I have opted for the pyenv setup. And have added the following to my .zshrc file:
eval "$(pyenv init --path)"
https://stackoverflow.com/a/69378384/14141223

command not found: rbenv when starting a new terminal

I have this line eval "$(rbenv init - zsh)" in my .zshrc. But it's throwing the command not found error for rbenv every time I start a new terminal. But rbenv works if I type it in manually, it only breaks when I start a new terminal. So in order for me to set a specific version for ruby, I need to run eval "$(rbenv init - zsh)" manually every time instead of relying on the terminal itself to run it automatically.
PS: I installed rbenv with Homebrew.
I have this line eval "$(rbenv init - zsh)" in my .zshrc.
The line should be after the rbenv binary location is loaded to the PATH environment variable.
Example:
export PATH="/home/someusername/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"

rbenv: no such command `init-'

I'm trying to install ruby in terminal via homebrew.
So far I've entered:
brew install rbenv
and then I rain
rbenv init
after the command was run I received
# Load rbenv automatically by appending
# the following to ~/.bash_profile:
eval "$(rbenv init -)"
finally I entered:
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
I restarted my terminal per instructions and then received
rbenv: no such command `init-'
at the top of my new terminal.
error messages: rbenv: no such command `init-'
expected messages: nothing, blank terminal
The default shell (Bash before macOS 10.15) on macOS is a login shell. Only .bash_profile is used in initialization by default.
You need to put eval "$(rbenv init -)" into ~/.bash_profile but not ~/.bashrc.
Bash init files
login mode:
/etc/profile
~/.bash_profile, ~/.bash_login, ~/.profile (only first one that exists)
interactive non-login:
/etc/bash.bashrc (some Linux; not on Mac OS X)
~/.bashrc
non-interactive:
source file in $BASH_ENV
Check the path of the red line for an interactive, login shell on macOS.
References
Unix shell initialization
Shell startup scripts

promlexport: command not found

Tried to install something via terminal and got sucked into a rabbit hole and accidentally deleted some shit (incl. Ruby & rbenv). Now whenever I open terminal it automatically feeds me this:
-bash: promlexport: command not found
-bash: rbenv: command not found
-bash: rbenv: command not found
-bash: rbenv: command not found
-bash: rbenv: command not found
I get that rbenv isn't working right now, but wtf is promlexport? I've googled it and literally 0 relevant searches come up… I'm working on a mac using the beta OS X Yosemite.
This is my .bash_profile (if that means anything to you — sure doesn't to me):
function proml {
case $TERM in
xterm*)
TITLEBAR='\[\0033]0;\u!\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="\u: \p\e[32m\1\W\[\e[0m\]l\n\[\e[0.31m\]❤️ \[\e[0m\]"
}
promlexport PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
PS – Might this be fixed when I update to the public OS X Yosemite?
I deleted the following from my .bash_profile:
promlexport PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Of course, it fixed everything. Instead of trying to reinstall rbenv, I successfully installed rvn. Definitely a "duh" moment, but more importantly, a learning one.

Resources