So I tried to do this tutorial https://programminghistorian.org/en/lessons/building-static-sites-with-jekyll-github-pages#on-a-mac-, but got stuck in the ruby section. Here's what happened and what I have tried:
When trying the tutorial I ran into my first "permission" error trying to use this command line
gem install rubygems-update
So I went ahead to the Jekyll website, read the documentation and figured out that I needed to work around that permission error that my guess is that it is generated becase Macs already have a ruby version that they need to run, and also that even if I install a new ruby version I can't change the one my Mac is running.
I tried everything here on the documentation. Even the rbenv path to install ruby and then when trying to see what version I was running with ruby -v, I got the same thing "2.6.3p62".
Then I found this blog post, and again tried to install it that way and again with homebrew. The only thing I modified from there is:
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
to this
echo 'export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.1/bin:$PATH"' >> ~/.zshrc
Because after running echo $SHELL it seems my shell is zsh.
However, when I restarted my console and typed ruby -v the terminal displayed the same old version "2.6.3p62". Also I saw here that I can run which ruby after I installed it and run the echo command to see if it is requiring it from the new defined path but no. It's still inside /usr/bin/ruby
I have run out of options and asking for some help. Thank you.
A possible script for the terminal of an M1 chip MacOS to setup a Ruby (any desired version) environment is:
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install git
git config --global color.ui true
git config --global user.name "your name here"
git config --global user.email your_email_here
Then download VS Code in Chrome and go back to your terminal to enter the following commands.
brew install rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
Next up is where you insert your desired version. This time I suggest 2.7.3
rbenv install 2.7.3
rbenv global 2.7.3
rbenv rehash
gem install bundler pry byebug
gem install pry
gem install pry-doc
I'm running openSUSE 13.1 and I'm trying to install Python 3.5.1 in an virtualenv, because the system default is 3.3.5 and cannot be further updated with yast.
I have downloaded the source, stored it in folder ~/pysrc35 and created a new directory ~/localpython and installed it
./configure --prefix=/home/<user>/.localpython
make
make install
the python3 executable there works and the localpython/bin looks like
2to3 easy_install-3.5 idle3.5 pip3.5 pydoc3.5 python3.5 python3.5m python3-config pyvenv-3.5
2to3-3.5 idle3 pip3 pydoc3 python3 python3.5-config python3.5m-config pyvenv
Now I want to use pip, which seems to have been included in the installation, but when I run it I get the error:
ImportError: No module named 'pip'
I have already set $PYTHONHOME to /home/<usr>/localpython/bin/python3 and $PYTHONPATH to /home/<usr>/localpython/lib/python3.5/:/home/<usr>/localpython/lib64/python3.5/:/home/<usr>/localpython/include/python3.5m/, because I got errors on that before, but now I'm stuck with pip.
A great solution for this was using pyenv. This tool makes installing different python versions and virtual environments super easy. The only prerequisite is probably just having git installed. Then you clone it
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
and run
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
eval "$(pyenv virtualenv-init -)"
in terminal. For Linux distributions other than openSUSE or Ubuntu ~/.bashrc might have to be replaced by
~/.bash_profile
. After restarting the terminal, run
pyenv install 3.5.x
to install whatever version you want (except 3.5.1 is not yet available). Then you should switch to your desired Python version, e.g. with
pyenv shell 3.5.x
to set the version for the current terminal session.
After that a virtual environment can be created and activated by
pyenv virtualenv /path/to/venv
pyenv activate /path/to/venv
See also this video for a comprehensive tutorial on using pyenv and in conjunction with django.
In Ubuntu 10.04 I just installed rbenv.
The install command is not present.
rbenv 0.4.0-49-g8b04303
Usage: rbenv <command> [<args>]
Some useful rbenv commands are:
commands List all available rbenv commands
local Set or show the local application-specific Ruby version
global Set or show the global Ruby version
shell Set or show the shell-specific Ruby version
rehash Rehash rbenv shims (run this after installing executables)
version Show the current Ruby version and its origin
versions List all Ruby versions available to rbenv
which Display the full path to an executable
whence List all Ruby versions that contain the given executable
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/sstephenson/rbenv#readme
What am I missing?
The install command is not embedded into rbenv, it comes from the ruby-build plugin. You can install it using the command:
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
On Mac OS X you can install it through homebrew:
brew install ruby-build
On Debian (version >= 7) and Ubuntu (version >= 12.10) both rbenv and ruby-build can be installed using apt-get (or aptitude):
sudo apt-get update
sudo apt-get install rbenv ruby-build
On FreeBSD ruby-build is available in the Ports Collection, it can be install both as a binary package or build from the port:
# Using pkgng rbenv will be installed
pkg install ruby-build
# Building ruby-build form Ports will install rbenv only if the RBENV option is set
cd /usr/ports/devel/ruby-build
make install
I found that when using rbenv from a global directory, it's necessary to export the RBENV_ROOT variable, otherwise it won't load the plugins.
export RBENV_ROOT="/usr/local/rbenv"
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
fi
As everyone mentioned problem is missing ruby-build. For older versions of OS ruby-build may not be available as an apt package. In that case install using original instructions, which should've omitted the word Optional in this:
(Optional) Install ruby-build, which provides the rbenv install
command that simplifies the process of installing new Ruby versions.
git clone git#github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# OR use http
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Simply install ruby-build in ubuntu:
sudo apt-get install ruby-build
And add
eval "$(rbenv init -)"
To your ~/.bashrc
I had installed the ruby-build plugin before and installed ruby 1.9.3-p327 using
$ rbenv install 1.9.3-p327
A few days later I tried to install ruby 2.0.0-p247 using
$ rbenv install 2.0.0-p247
but I received the error message
rbenv: no such command 'install'
All I had to do was to run
$ exec $SHELL -l
and that fixed the problem.
Answered on 2021
If you're getting that error, it's very likely you have accidentally skipped one of the installation instructions:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
Replace .bashrc with whatever shell you're using, for example .zshrc, or just manually access your shell config file and paste this line:
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
I strong advise against re-installing/installing Ruby via brew or apt-get just to get around this issue. The whole point of using rbenv is to make your life easier in future when there is ruby version upgrade, or when you're working on different rails projects that require different version of ruby.
It looks like ruby-build is not present. Run this command :
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
Anyone finding their way here with this issue on OSX and already having installed ruby-build via homebrew (like me), you may solve this by just upgrading ruby-build:
brew update
brew upgrade ruby-build
This fixed the problem for me.
This issue also happens in Linux when doing a stand-alone installation of ruby-build, if the ruby-build executable is not found in the path. If installing under /usr/local, try for example:
PATH=/usr/local/bin:$PATH /usr/local/bin/rbenv install ...
I came to this solution, but looking for a macOS solution that uses MacPorts.
So, here the same command using MacPorts:
➜ ~ sudo port install ruby-build
Password:
---> Computing dependencies for ruby-build
---> Fetching archive for ruby-build
---> Attempting to fetch ruby-build-20210804_0.darwin_19.noarch.tbz2 from https://packages.macports.org/ruby-build
---> Attempting to fetch ruby-build-20210804_0.darwin_19.noarch.tbz2.rmd160 from https://packages.macports.org/ruby-build
---> Installing ruby-build #20210804_0
---> Activating ruby-build #20210804_0
---> Cleaning ruby-build
---> Scanning binaries for linking errors
---> No broken files found.
---> No broken ports found.
➜ ~ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /opt/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /opt/local/bin/rbenv-install (ruby-build 20210804)
Counting installed Ruby versions: none
There aren't any Ruby versions installed under `/Users/user/.rbenv/versions'.
You can install Ruby versions like so: rbenv install 3.0.2
Checking RubyGems settings: OK
Auditing installed plugins: OK
➜ ~ rbenv install 3.0.2
Downloading openssl-1.1.1k.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
Installing openssl-1.1.1k...
I am writing a bash script in mac OSX. now i want to set up librarian-chef,
echo "installing the librarian-chef gem"
gem install librarian-chef
echo "librarian-chef installing cookbooks from the recipies"
librarian-chef install
and then run it. so that the rest of the bash script can complete but i keep getting this line 31: librarian-chef: command not found
so i figured the gem installed fine but the path wasn't refreshed so it couldn't be used? so i tried
echo "librarian-chef installing cookbooks from the recipies"
source ~/.bash_profile
librarian-chef install
so that it would refresh it but that didnt work?
./vagrant_prepare.sh: line 30: ~/.bash_profile: No such file or directory
how can i install it and then use it anyone seen this?
i do have bash profile btw
ls -a
. .bash_history .dropbox .rbenv .viminfo Dumps Pictures temp
.. .bash_profile .gem .redis Desktop Library Public test.sh
.CFUserTextEncoding .bundler .gitconfig .ruby-version Documents Movies VirtualBox VMs
.DS_Store .cache .local .ssh Downloads Music Work
.Trash .config .pow .vagrant.d Dropbox Nexus chronosphere.sh
Add this in your ~/.bash_profile:
eval "$(rbenv init -)"
Reopen terminal and run script again.
#!/bin/bash
echo "installing the librarian-chef gem"
gem install librarian-chef
echo "librarian-chef installing cookbooks from the recipies"
librarian-chef install
I installed rbenv according to the instructions at https://github.com/sstephenson/rbenv#section_2
Restarting my shell at point 4 will result in an error
$ rbenv init -
rbenv: no such command `init'
Trying to run the command directly from its folder doesn't work either.
$ cd .rbenv/bin
$ ./rbenv init -
rbenv: no such command `init'
My $PATH
$ echo $PATH
/home/myusername/.rbenv/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/myusername/bin
Running rbenv install works until rbenv rehash is called
$ rbenv install 1.9.3-p0
Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz...
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /home/hbrandl/.rbenv/versions/1.9.3-p0
Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz...
Installing ruby-1.9.3-p0...
Installed ruby-1.9.3-p0 to /home/hbrandl/.rbenv/versions/1.9.3-p0
rbenv: no such command `rehash'
All other rbenv commands don't seem to work.
Any help or pointers greatly appreciated.
Check if the symlink is correct:
> ls -l ~/.rbenv/bin/rbenv
lrwxr-xr-x 1 kelvin staff 16 Mar 29 11:19 /Users/kelvin/.rbenv/bin/rbenv# -> ../libexec/rbenv
Is your rbenv a symlink to ../libexec/rbenv ? It should be, because it reads that symlink location to know that "libexec" is the location of the other executables.
To fix:
> cd ~/.rbenv/bin
> mv rbenv rbenv.broken
> ln -s ../libexec/rbenv rbenv
It might've broken if you copied the ~/.rbenv from another location, which would probably mess the links up.
A working workaround for my problem was to simply add the libexec folder to my path as well.
My rbenv PATH additions now look as follows:
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/libexec:$PATH"
This fixes the problem for me.