eval "$(rbenv init -)" does not work when referenced from ~/.zshrc (OS X) - ruby

This is one those strange things, although I'm sure the most recent installation of Sierra has something to do with this.
In fact, yesterday night I had to completely (manually remove) the whole rbenv folder to make it working again.
In a nutshell, the following eval "$(rbenv init -)" has been added immediately after the PATH declaration in the ~/.zshrc file.
However, when launching the iTerm console, that line pass ignored and in fact all the gems under the shims are ignored. This should also result in the default ruby version to be loaded, which is not the case as a ruby -v returns my global 2.3.1 recently installed.
The funny thing is that a eval "$(rbenv init -)" at a command line properly resolve and all works fine after that.
I have another Mac, where I can't install Sierra and the same settings, same ZSH version etc. works just fine.
Does anybody experience the same?
Thanks
Andrea

Ok, I've raked the net for 30 minutes without results, so I did a simple test.
Instead of copy and pasting the results proposed by the rbenv init, I typed what is proposed into the ~/.zshrc file to get it working like a charm.
I can only assume that some characters shown on screen are encoded in some different way, hence they generate the problem.

Related

A pyenv related error occurs in the zsh terminal of MacBook Air M1

An error occurs whenever I turn on the terminal.
# Terminal
/Users/{username}/.zshrc:103: command not found: pyenv
/Users/{username}/.zshrc:104: command not found: pyenv
# line 103, 104 of /Users/{username}/.zshrc
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
There's no problem with the annotation. But I think I wrote it down because I needed two codes when I used Catalina, so is it okay if I don't have it?
Oh, but using brew install pyenv caused an installation error.
It was installed using arch -arm64 brew install pyenv as the guide in the error message.
Not only pyenv, but also pyenv-virtualenv.
The Catalina time machine was moved to the new MacBook Air M1, and the data seemed to have passed normally, but none of the applications have passed.
What's the problem? Did the other people have their applications transferred together?
Ah, the existing workspace folder, the GitHub clone folder, has all disappeared.
I had the same issue and it ended up being The line, eval "$(pyenv init -)" was above the homebrew eval line, eval $(/opt/homebrew/bin/brew shellenv) in my .zshrc.

Mas OS Big Sur update - Python3 / conda / pip not found

Sorry if this is a stupid question. I use python/jupyter a lot and it's stopped working after updating from Mac OS High Sierra to Big Sur. I'm trying to figure out why, but I'm not great with command line stuff.
The problem. When I try python3, pip -v, conda, etc. it says "command not found". python still seems to run, but it's 2.7 and I know I had 3 (I probably had a few versions from untidy file systems). I want to avoid reinstalling all my packages and things again, because I know it's still there and I've done this a few times already.
Some clues. I know this OS upgrade moves me from bash to zsh. I've tried just switching back to bash with chsh -s /bin/zsh but it still says command not found. I also noticed the OS update creates a Mac HD (below System/Volumes) within my Mac HD, and in that second one seems to be still all my python3/conda/pip/etc. folders. Not sure if/how this matters. Or if this is just a path issue.
I just want to get Jupyter running again on my Mac without reinstalling all my myriad packages from square one. Any help appreciated!
After extreme toil and research, I finally found something that worked for me.
Find the location of your Anaconda3. For me it was in ~/opt/anaconda3
Open terminal and type source <location of anaconda3>/bin/activate and then in the next line, write conda init zsh
Close your terminal and open it again. You should see a prefix (base) when you open it again.
All in all, for me it was
rko3 ~ % source opt/anaconda3/bin/activate
rko3 ~ % conda init zsh
Let me know if this works for you!
PS. You may be tempted to change $PATH variables. Anaconda advises against that. Use this reference instead that suggests the above. https://docs.anaconda.com/anaconda/install/mac-os/
I've just resolved this exact issue on my machine after upgrading to Big Sur from Mojave.
The issue: MacOS, as of Catalina, no longer lets you use the system root folder. Anaconda used to install in this folder. After upgrading from Mojave to Big Sur, you'll likely find your anaconda3 folder, including all your environments and packages, located here: /System/Volumes/Data/anaconda3.
Here is what to do to fix it:
Open Terminal
Move the anaconda3 folder:
sudo mv /System/Volumes/Data/anaconda3 ~/
Download Anaconda's Conda Prefix Replacement (crp) tool:
curl -L https://repo.anaconda.com/pkgs/misc/cpr-exec/cpr-0.1.1-osx-64.exe -o cpr && chmod +x cpr
Run the CRP tool (this will take a few minutes):
./cpr rehome ~/anaconda3/
Source anacoda3
source ~/anaconda3/bin/activate
Initiate conda
conda init
Quit Terminal and open it again.
Edit: Someone didn't like that I ended this answer with "That's it! Enjoy". In the scenario described, the steps above were indeed all it took to resolve the issue. If you're experiencing the same issue, I hope this helps resolve it, so you can get back to enjoying your updated OS.
Seems like your environement is not activated. Zsh sources ~/.zshrc while bash sources ~/.bashrc.
You can copy lines related to conda from your ~/.bashrc to your ~/.zshrc.
AF
Open the Anaconda navigator and click on the Environments section. There you will see the base (root) and a green triangle next to it.
Click on the triangle and select Open Terminal.
Now, in the terminal you will be already in the necessary directory for anaconda and you can then update any packages.
For example, just by writing conda update --all you can update all packages available for updates.

Cannot resolve "rbenv init" instruction for zsh and oh-my-zsh on Mac

I'm a Ruby developer setting up my local development environment on a new iMac running macOS High Sierra with iTerm2, Homebrew, rbenv, zsh and oh-my-zsh.
I used RVM before on my Linux machine, but want to switch to rbenv with this iMac because I've heard it's better in some ways, so I'm trying to make sure all is as it should be with my rbenv setup before I start downloading/installing Rails and other gems.
I'm running rbenv init, which, as I understand it, will tell me what I need to do next to get rbenv working. It displays this message:
# Load rbenv automatically by appending
# the following to ~/.zshrc:
eval "$(rbenv init -)"
So I went into my .zshrc file and added that line. My .zshrc file currently looks exactly like this (comments omitted):
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export ZSH="/Users/christian/.oh-my-zsh"
plugins=(git)
source $ZSH/oh-my-zsh.sh
No matter how many times I restart my iTerm terminal and run rbenv init, it always gives me that same instruction, and nothing else.
The first line in the file used to be: export PATH=$HOME/bin:/usr/local/bin:$PATH but I changed it to the current line because another StackOverflow page suggested this to someone having a very similar problem, but it didn't help.
I don't understand why it keeps telling me to add something that's already in the .zshrc file, and I don't know whether I've successfully setup rbenv with everything and am ready to start developing in Ruby on Rails.
I've looked at lots of stuff about this on here and other sites, but I can't seem to find the answer. I would be very grateful if someone could tell me why it keeps giving me that same message? how I make it proceed with the instructions and tell me the next thing to do? and how I'll be able to tell for sure when my rbenv is properly setup for development?
I eventually ran curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash and it showed green for everything. It seems I had everything already setup correctly; the rbenv init interface was just confusingly telling me to do something I'd already done. I confirmed it was all working by downloading different versions of Ruby with rbenv install, switching between them with rbenv local and rbenv global, and making sure ruby -v always displayed whatever version I had selected.

PIP is linked only to system environment

I'm using pyenv-virtualenv on Ubuntu 16.04 LTS.
While I was installing imblearn package for my virtualenv using Python 3.5, I realized it was being installed on system environment which uses Python 2.7. I checked with pyenv version but it clearly returned that I was on my virtualenv.
I opened a Python shell and tried to import imblearn and got ImportError: No module named 'imblearn'.
When I checked with pip list, it clearly stated that imblearn was installed. But every other packages that have been installed were missing, hence telling that the list was of system environment.
I've tried making a new environment and checked but the list is still of system and installation goes to system as well.
My pip is stuck with system.
I have never experienced this before and have no idea how to fix this.
Below is my .bashrc setting:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Just the way it tells me to set.
I've been using it fine until yesterday which I found out this was happening.
I suspect it has something to do with pyenv global command which I used while I was telling my partner how to use pyenv-virtualenv yesterday.
Still, I have never had a problem with that command before.
Please help.
Update
For some reason, source ~/.bashrc put everything back to normal. (I don't know why I typed this command. I just did it.)
But I'd still like to know how this happened and why it is fixed when I changed nothing in my .bashrc file and when even re-opening terminal or rebooting didn't fix things.
I still don't know how this was solved, and assume that this won't happen in later version pyenv-virtualenv.
It's a year old post, but I guess I could post what helped me back then so that others won't try to solve my long ago problem for me.
Thanks for letting me know.
source ~/.bashrc

RBENV resolve duplicate directories for ruby-build

I recently updated my ruby version for the first time since installing rbenv. On my development machine I discovered that I needed to reinstall bundler and all my gems again for each application using bundle install.
Now, when I login to my production server I notice that I have a ruby-build directory in my home folder at ~/ruby-build and in .rbenv/plugins. How can I find out which one my server is using and so which one to run git pull and install the new version of ruby? Can I just delete the directory at ~/ruby-build and deal with the other? Doing some exploring I find I also have a ruby-build in usr/local/bin on my server but this is not a directory.
I am completely confused by all of this. Rbenv lives in my home directory, rather than in any system directory on the server. Does this matter? How does it still work on a server even if I am not logged in?
Running rbenv versions from my home directory on the server reports "The program 'rbenv' is currently not installed" but lists the versions installed on my development laptop.
My .bashrc on the sever contains this entry at the top
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"
fi
My .bashrc on my development laptop contains this entry at the bottom.
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Since you include that in your .bashrc, I imagine that if you were to echo $RBENV_ROOT in the terminal you'll find out which rbenv directory is the one being used.
Although, you say that the rbenv command doesn't work so perhaps $RBENV_ROOT is not defined. In that case, you can simply do something like RBENV_ROOT=$HOME/.rbenv/ before that conditional -- or whatever you like -- to set the rbenv directory it should use.
When you do that, to define $RBENV_ROOT, re-login to make the changes take effect, or re-source the .bashrc file with source ~/.bashrc.

Resources