How to configure rbenv with ruby? - ruby

I've tried to install ruby on my mac. Ruby is already installed :
brew install ruby
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
ghcup reshape tidy-viewer vermin
==> Updated Formulae
Updated 159 formulae.
==> New Casks
kindavim music-bar presentation
==> Updated Casks
Updated 143 casks.
==> Deleted Casks
airqmon
Warning: ruby 3.0.3 is already installed and up-to-date.
To reinstall 3.0.3, run:
brew reinstall ruby
But when i run ruby -version, i get the following result :
/Users/oscar/.rbenv/shims/ruby: line 21: /usr/local/Cellar/rbenv/0.4.0/libexec/rbenv: No such file or directory
I am using rbenv. I've tried to reinstall rbenv but i get the same error.
I am new in ruby and i need some help please.
How to solve this error ?
Thanks

You installed Ruby previously with rbenv and now you show that you installed Ruby with brew, which is a totally different process. I assume you removed your rbenv installation, but left around some leftovers. If you wish to continue with your brew Ruby installation, which is in my opinion perfectly good, you just need to remove the rbenv leftovers by removing your /Users/oscar/.rbenv directory, possibly you may also need to restart your Terminal.

Related

Brew Install Trouble

I'm struggling to brew install minikube. I don't have any version, but need an older version. I'm trying the familiar way, but get an error:
~ brew install minikube#1.18.1
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "minikube#1.18.1".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
I've tried to do a bit of homework, but still errors:
~ brew install https://github.com/Homebrew/homebrew-core/blob/8d37c361ee69503961a3010e7896f6ecf8d3a059/Formula/minikube.rb
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 16 formulae.
Traceback (most recent call last):
`brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap on GitHub instead.: Invalid usage: Non-checksummed download of minikube formula file from an arbitrary URL is unsupported! (UsageError)
`brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap on GitHub instead.: Invalid usage: Non-checksummed download of minikube formula file from an arbitrary URL is unsupported! (UsageError)
This must be elementary, but I can't seem to figure this out :(
$brew update-reset
This helped me with the error.
Brew only does creates separate versions for certain formula, and its mostly only the larger ones where they might provide different versions due to backward compatibility and stuff.
You might have some luck with the answers in this question Homebrew install specific version of formula?.
Before running:
brew install https://github.com/Homebrew/homebrew-core/blob/8d37c361ee69503961a3010e7896f6ecf8d3a059/Formula/minikube.rb
you should execute:
brew unlink minikube
That way you will remove the old minikube links and link the newly installed binary.
If that's still not working than try running:
wget https://github.com/Homebrew/homebrew-core/blob/8d37c361ee69503961a3010e7896f6ecf8d3a059/Formula/minikube.rb
followed by:
brew install --HEAD -s minikube.rb
I think first you can try to run 'brew install minikube' only, see if you can successfully install it or not. If no error then it's probably your version issue. If still has Error then that might be your local home-brew issues, then you can Try to run 'brew doctor', based on the warning and Error info search in stackoverflow you probably will find out the answer.

Unable to install Ruby on Mac with Homebrew

I am trying to install ruby 3.0 with Homebrew.
brew install ruby
But I am getting an error
Error: No available formula or cask with the name "ruby".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
When I try 'brew search ruby', I get this:
==> Formulae
homebrew/portable-ruby/portable-libyaml
homebrew/portable-ruby/portable-ncurses
homebrew/portable-ruby/portable-openssl
homebrew/portable-ruby/portable-readline
homebrew/portable-ruby/portable-ruby
homebrew/portable-ruby/portable-zlib
==> Casks
rubymine rubymotion
I tried uninstalling homebrew and reinstalling it and also used brew cleanup. Nothing worked.
Also, my MacOS version is 11.2.3 (20D91) MacOS Big Sur.
I was getting the same error and ran brew doctor which gave me this message:
Warning: Homebrew/homebrew-core was not tapped properly! Run:
rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core
Try running brew doctor and see if you get the same.
I followed the instructions and yah! I have ruby!
This isn't an exact answer for your question, but an alternate approach, and one I recommend following when using languages like Ruby and Python, where you often need multiple different versions installed simultaneously, along with the ability to switch between them as you move between projects: use a tool like RVM.
If brew cannot find/install the version you need, rvm will download and build it from source, and then you can switch between versions with rvm use <version>. When I was doing a lot of ruby dev some years back I found it indispensable, and it's going to be a faster way to stay current than waiting on homebrew to keep pace, generally.
(edit) Other functionally similar tools include rbenv and chruby.

Can't install emacs in Homebrew

$ brew install emacs
Updating Homebrew...
Warning: Treating emacs as a formula. For the cask, use homebrew/cask/emacs
==> Downloading https://homebrew.bintray.com/bottles/emacs-27.1.mojave.bottle.1.tar.gz
Already downloaded: /Users/xxx/Library/Caches/Homebrew/downloads/edc19e2cbf4d5136f0e31adfb9c57161b65dd8163f861a92e10bfd617d1d611c--emacs-27.1.mojave.bottle.1.tar.gz
==> Pouring emacs-27.1.mojave.bottle.1.tar.gz
==> emacs cask is installed, skipping link.
==> Caveats
To have launchd start emacs now and restart at login:
brew services start emacs
Or, if you don't want/need a background service you can just run:
emacs
==> Summary
🍺 /usr/local/Cellar/emacs/27.1: 4,009 files, 104.0MB
==> Upgrading 1 dependent:
cask 0.8.4 -> 0.8.5
==> Upgrading cask 0.8.4 -> 0.8.5
==> Downloading https://github.com/cask/cask/archive/v0.8.5.tar.gz
==> Downloading from https://codeload.github.com/cask/cask/tar.gz/v0.8.5
######################################################################## 100.0%
Error: An exception occurred within a child process:
RuntimeError: /usr/local/opt/emacs not present or broken
Please reinstall emacs. Sorry :(
How to fix this?
By looking at the output, it seems emacs actually got installed:
==> Summary
🍺 /usr/local/Cellar/emacs/27.1: 4,009 files, 104.0MB
You should be able to use it straight away.
If you prefer a GUI version, you can install it with:
brew install --cask emacs
The problem
Error: An exception occurred within a child process:
RuntimeError: /usr/local/opt/emacs not present or broken
Please reinstall emacs. Sorry :(
It's another tool, cask, which fails to install:
It cannot find the emacs dir under /usr/local/opt/emacs.
Homebrew installed it at /usr/local/Cellar/emacs/27.1.
The fix
You can fix it by:
(Recommended) Creating a symlink in /usr/local/opt/ to emacs directory
$ brew link --overwrite emacs # if it complains about relinking, run brew unlink emacs && brew link emacs instead
$ brew install cask
(Alternative) If the previous point didn't help, ignoring dependencies while installing cask
$ brew install cask --ignore-dependencies
Please let me know if it helped

brew cannot find ANY packages

I just got my Mac Pro from the shop after hard drive failure. I am trying to install my environment again.
I installed homebrew from the current link on the homebrew website:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
but I cannot install ANY package. Brew cannot find ANYTHING.
~ brew install rbenv
Error: No available formula with the name "rbenv"
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
What is wrong?
I had the same issue and I was able to solve it by running the doctor command and follow the steps which need to be updated there.
My homebrew-core was not at the master branch.
brew doctor
git -C $(brew --repo homebrew/core) checkout master
And that's it. After that, I was able to run the rbenv install command.
brew search result
$ brew search rbenv
==> Formulae
rbenv rbenv-bundle-exec rbenv-chefdk rbenv-default-gems rbenv-vars
rbenv-aliases rbenv-bundler rbenv-communal-gems rbenv-gemset rbenv-whatis
rbenv-binstubs rbenv-bundler-ruby-version rbenv-ctags rbenv-use
install rbenv
$ brew install rbenv
==> Downloading https://github.com/rbenv/ruby-build/archive/v20200819.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20200819
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.1.2.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for rbenv: ruby-build
==> Installing rbenv dependency: ruby-build
==> ./install.sh
==> Caveats
ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded.
To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following
to your /Users/rchen/.bash_profile:
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl#1.1)"
Note: this may interfere with building old versions of Ruby (e.g <2.4) that use
OpenSSL <1.1.
==> Summary
🍺 /usr/local/Cellar/ruby-build/20200819: 509 files, 253.6KB, built in 5 seconds
==> Installing rbenv
==> Pouring rbenv-1.1.2.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/rbenv/1.1.2: 36 files, 65KB
==> Caveats
==> ruby-build
ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded.
To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following
to your /Users/rchen/.bash_profile:
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl#1.1)"
Note: this may interfere with building old versions of Ruby (e.g <2.4) that use
OpenSSL <1.1.
version test
$ rbenv --version
rbenv 1.1.2

rbenv not showing the available ruby versions

I have installed rbenv in my vagrant machine but when I try to list all the available ruby versions rbenv versions then it gives me this output:
system (set by /home/vagrant/.rbenv/version)
Does anyone know what is this?
Are you asking what the output of that command means? I'm looking at the rbenv documentation, and I think it indicates that rbenv only knows of one version of ruby - the version that came installed with your system.
Edit: If that's not the answer you were looking for, can you tell us what you expected to see? Did you have other versions installed on that machine?
Edit 2: If you want to see a list of versions you can install onto your machine, but aren't installed yet, run:
rbenv install --list
Here is more documentation for this command. This will help!
If you have tried both rbenv install --list and ruby-build --definitions and still can't see the latest Ruby versions on the list, then you need to upgrade ruby-build because that is what rbenv uses to "know" the available versions.
For example, assuming you use Mac OS X and installed ruby-build using Homebrew, you can update ruby-build by invoking:
brew upgrade ruby-build
Now, try listing the available versions again, and you should see the latest ones there.
Edit:
The ruby-build wiki lists a couple of ways of updating it, namely the above one using Homebrew and another one where it is installed as a plugin to rbenv:
cd "$(rbenv root)"/plugins/ruby-build && git pull
Rbenv is usually installed with it's companion ruby-build
You can get the versions available to be installed with:
ruby-build --definitions
To get a list of available ruby versions you can install, type the following:
rbenv install -l
To get a list of the ruby versions already installed on your machine, type the following:
rbenv versions
To answer your question as to what the below means:
system (set by /home/vagrant/.rbenv/version)
This is telling you that the system ruby (the default ruby installed on your system) is the only ruby version installed on your vagrant machine. Rbenv is using the default system ruby because it doesn't have any other ruby versions installed yet.
To see all available versions:
rbenv install --list-all
Or
rbenv install --list
To list only stable releases for each Ruby implementation.
If you are on Mac
brew upgrade rbenv ruby-build also works.
Documentation
List rbenv versions that are possible to install
"Only latest stable releases for each Ruby implementation are shown.
With the fewest key strokes (shorter than --list and --list-all)
rbenv install -l
Want to see what is available from rbenv to install?
ruby-build --definitions
Want to narrow that down a bit?
ruby-build --definitions | grep 3.0
To upgrade to the latest rbenv and update ruby-build with newly released Ruby versions, upgrade the Homebrew packages:
brew update && brew upgrade rbenv ruby-build
Also you can always just type rbenv
Which will give you a help menu
rbenv
TLDR the manpage or github repo or just plain forgot?
Take a peek at this site for quick rbenv recollection:
https://devhints.io/rbenv
Also, you may need to brew upgrade if you have installed with brew see here.

Resources