Unable to install Ruby on Ubuntu - ruby

I'm trying to install Ruby 2.6.1 on Ubuntu but keep coming across this error.
Have tried uninstalling Ubuntu, googling the problem, running in administrator mode, downloading a different version.
This is the error:
:~$ rvm install 2.6.1
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/20.04/x86_64/ruby-2.6.1.tar.bz2
Checking requirements for ubuntu.
Installing requirements for ubuntu.
mkdir: cannot create directory ‘/usr/share/rvm/log/1625135668_ruby-2.6.1’: Permission denied
tee: /usr/share/rvm/log/1625135668_ruby-2.6.1/update_system.log: No such file or directory
Updating system..jaydene password required for 'apt-get --quiet --yes update':
Sorry, try again.
jaydene password required for 'apt-get --quiet --yes update':
..
Error running 'requirements_debian_update_system ruby-2.6.1',
please read /usr/share/rvm/log/1625135668_ruby-2.6.1/update_system.log
Requirements installation failed with status: 1.
:~$

you can use a gorails website to checkout ruby on rails installation. And ruby installs version as per dependencies on your system. If it's not founding 2.6.1 it will install next supported version for ex. 2.6.7.
check this website: https://gorails.com/setup/ubuntu/21.04

Check this: How do I install Ruby 1.9.3 on Ubuntu without RVM? but SO says to avoid link answers so here is the script:
#!/usr/bin/env bash
# -- this really is the only solution that worked for me on snap :/
ruby -v
if ! command -v ruby &> /dev/null
then
echo "Going to try to install ruby (ideally 3.1.2)"
# - install rebenv (following ruby-build really is needed eventhough it doesn't look like it)
mkdir -p ~/.rbenv
cd ~/.rbenv
git clone https://github.com/rbenv/rbenv.git .
# if $HOME/.rbenv/bin not in path append it, otherwise don't change it
echo $PATH | tr ':' '\n' | awk '{print " " $0}';
if [[ ":$PATH:" != *":$HOME/.rbenv/bin:"* ]]; then
echo "might want to put $HOME/.rbenv/bin in your path"
export PATH="$HOME/.rbenv/bin:$PATH"
# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc.lfs
fi
eval "$(rbenv init -)"
rbenv -v
# - install ruby-build, odd, this really is needed for ruby to install despite it not looking like ruby build is need at the bottom
mkdir -p ~/.ruby-build
cd ~/.ruby-build
git clone https://github.com/rbenv/ruby-build.git .
# if $HOME/.ruby-build/bin not in path append it, otherwise don't change it
echo $PATH | tr ':' '\n' | awk '{print " " $0}';
if [[ $PATH != *"$HOME/.ruby-build/bin"* ]]; then
echo "might want to put $HOME/.ruby-build/bin in your path"
export PATH="$HOME/.ruby-build/bin:$PATH"
# echo 'export PATH="$HOME/.ruby-build/bin:$PATH"' >> ~/.bashrc.lfs
fi
ruby-build --version
# - install ruby without sudo -- using rbenv
mkdir -p ~/.local
# ruby-build 3.1.2 ~/.local/
rbenv install 3.1.2
rbenv global 3.1.2
fi
ruby -v
# - Original Prover doesn't work on SNAP
# Proverbot's way to install ruby
# # First, install Ruby, as that is for some reason required to build the "system" project
# git clone https://github.com/rbenv/ruby-build.git ~/ruby-build
# mkdir -p ~/.local
# PREFIX=~/.local ./ruby-build/install.sh
# ~/.local/ruby-build 3.1.2 ~/.local/
# ref: https://superuser.com/questions/340490/how-to-install-and-use-different-versions-of-ruby/1756372#1756372

Related

Why do I get: 'ERROR: While executing gem ... (Gem::FilePermissionError)' when trying bundle install?

I am trying to run 'gem install bundler' on a new macbook pro.
I get :
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
I have tried using RVM
I have tried using RBENV
rbenv doctor gives this output:
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20190423)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
My bash profile is like this:
alias brewup='brew update; brew upgrade; brew cleanup; brew doctor'
###
## Colors and prompt customisation
## OLD: export> PS1="\[\033[36m\]\u\[\033[m\]#\[\033[32m\]\h:\[\033[33;1m\] \w\[\033[m\] \$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1=" \[\033[01;35m\]\u#\h: \[\033[01;32m\]\w \[\033[01;34m\]\$(parse_git_branch) \[\033[01;34m\]\n>\[\e[0m\]"
## NVM stuff
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
## Ruby rbenv stuff
eval "$(rbenv init -)"
export PATH="/usr/local/sbin:$PATH"
export PATH="/Users/georgeclark/.gem/ruby/2.3.7/bin:$PATH"
the last 3 lines are vague attempts at getting this working, could well be wrong.
The output from some terminal commands I ran are as follows:
If I do ruby -v
I get: ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
which gem gives me /Users/georgeclark/.rbenv/shims/gem
output from:
echo $PATH, ls -l ~/.rbenv/shims, rbenv versions, gem env
is:
/Users/georgeclark/.rbenv/shims:/Users/georgeclark/.gem/ruby/2.3.7/bin:/usr/local/sbin:/Users/georgeclark/.nvm/versions/node/v10.16.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin, ls -l /Users/georgeclark/.rbenv/shims, rbenv versions, gem env
These seem ok.. just cant figure out why it wont run, and really don't want to use sudo 😕
It was my bad.
I wasn't setting the rbenv properly.
Once I set this up with:
rbenv global 2.4.5
Then all works fine.

Why do I need to add ~/.rbenv/bin to my path?

I read in rbenv can't change global ruby version that I need to add ~/.rbenv/bin to my PATH for rbenv to work.
That's also mentioned in the rbenv documentation but that directory doesn't exist as shown below:
$ ls -a ~/.rbenv/
. .. plugins shims version versions
So why do I need to add a directory that doesn't exist to my path for rbenv to work?
Edit:
#theTinMan, I tried uninstall and reinstalling, but I still don't have a ~/.rbenv/bin path. Where are you seeing in the documentation that it should be there?
$ rbenv --version
rbenv 1.0.0
$ which rbenv
rbenv () {
local command
command="$1"
if [ "$#" -gt 0 ]
then
shift
fi
case "$command" in
(rehash | shell) eval "$(rbenv "sh-$command" "$#")" ;;
(*) command rbenv "$command" "$#" ;;
esac
}
$ cd
$ ls .rbenv
plugins shims version versions
$ brew list | grep rbenv
rbenv
$
$ brew uninstall rbenv
Uninstalling /usr/local/Cellar/rbenv/1.0.0... (36 files, 61.9K)
rbenv 0.4.0 is still installed.
Remove all versions with `brew uninstall --force rbenv`.
$ brew uninstall --force rbenv
Uninstalling rbenv... (32 files, 49.9K)
$ brew install rbenv
==> Summary
🍺 /usr/local/Cellar/rbenv/1.0.0: 36 files, 62K
$ ls .rbenv
plugins shims version versions
$ rbenv -v
rbenv 1.0.0
$ rbenv versions
system
2.0.0-p648
* 2.3.1 (set by /Users/max/.rbenv/version)
$
I had the following in my .zshrc
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
But I only needed the bottom line
# export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Installing RVM and gems on OSX from a single shell script

I am attempting to install RVM and a few gems from a single bash script that I use to bootstrap a new development box. My goal is to have a single script I can run on a clean install of OSX to install any and everything I use for development.
After installing RVM, I am sourcing the $HOME/.rvm/scripts/rvm script, however in the next line, when I attempt to install a specific version of ruby, it says rvm is not found. Here is my script.
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable --autolibs=homebrew
source "$HOME/.rvm/scripts/rvm"
rvm install 2.1.1
rvm use 2.1.1
gem install jekyll
gem install tmuxinator
gem install scss-lint
I can't understand why this isn't working, because if I run each command individually in the terminal, everything works great.
Any ideas on a 1 script solution to install RVM, a specific version of Ruby, and a few gems?
If you look in .bashrc after RVM they have:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
What I would do overall for cleanliness
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable --autolibs=homebrew
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
. "$HOME/.rvm/scripts/rvm"
else
echo "$HOME/.rvm/scripts/rvm" could not be found.
exit 1
fi
export PATH="$PATH:$HOME/.rvm/bin"
rvm use 2.1.1 --default --install
for i in jekyll tmuxinator scss-lint; do gem install $i; done
You may need to add "source ~/.rvm/scripts/rvm" to your ~/.bash_profile file.
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
To install rvm:
rm -rf ~/.rvm
curl -L https://get.rvm.io | bash -s stable
In your script type:
type_rvm=$(type rvm | head -n 1)
echo "type rmv: $type_rvm"
You could try export rvm:
export PATH=$PATH:/opt/rvm/bin:/opt/rvm/sbin
I found a solution after reading through another stack overflow post.
A comment to one of the answers suggested makeing sure the script runs with bash and not sh. That was my problem. After changing the top line of my script (which wasn't included in my example) from #!/bin/sh to #!/usr/bin/env bash, everything worked as expected.

Heroku buildpacks - installing executables that are used by Python packages

I am trying to install M2Crypto on Heroku. This relies on SWIG being installed.
I've created a custom compiled swig executable and a custom buildpack.
I then git push my code up to Heroku, the custom buildpack installs SWIG then tries to install M2Crypto but fails because it can't find swig.
This is the buildpack customisation:
# Install SWIG
if [ ! -d $CACHE_DIR/swig ]; then
cd $BUILD_DIR
echo "-----> Fetching and installing SWIG 2"
curl -O https://s3.amazonaws.com/guybowden/swig.tar.gz >/dev/null 2>&1
echo "-----> Installing ..."
tar xzvf swig.tar.gz >/dev/null 2>&1
mv swig $CACHE_DIR/swig
rm swig.tar.gz
echo "SWIG installed" | indent
fi
mkdir -p .paybox
cp -R $CACHE_DIR/swig .paybox
echo "updating path..." | indent
PATH=$PATH:/app/.paybox/swig/bin/
export PATH
echo $PATH | indent
echo "setting SWIG_LIB environment var"
export SWIG_LIB=/app/.paybox/swig/share/swig/2.0.5/
This happens before any pip install commands are run.
If I heroku run bash and then manually run source .heroku/venv/bin/activate && pip install M2Crypto it installs no problem and my App works inside the bash prompt for the lifetime of that instance.
I think there's a problem with the PATH setting when the initial pip install -r requirements runs... any ideas?
And the answer is..
PATH=$PATH:$BUILD_DIR/.paybox/swig/bin/
export PATH
echo $PATH | indent
echo "setting SWIG_LIB environment var"
export SWIG_LIB=$BUILD_DIR/.paybox/swig/share/swig/2.0.5/
$BUILD_DIR is where the stuff is built when the buildpack is executed - not /app/ (which is where it lives when the app runs!

RVM installation fails

I followed the instructions from the RVM homepage (https://rvm.beginrescueend.com/rvm/install/)
I typed the following:
sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
the script executed and didn't seem to give any errors.
the same without sudo gave an error:
Warning: Failed to create the file
Warning: /usr/share/ruby-rvm/archives/wayneeseguin-rvm-stable.tgz: Permission
Warning: denied
0 792k 0 3908 0 0 2257 0 0:05:59 0:00:01 0:05:58 2257
curl: (23) Failed writing body (0 != 3908)
Could not download 'https://github.com/wayneeseguin/rvm/tarball/stable'.
curl returned status '23'.
I also put this in my ~/.bashrc
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
what I get is:
~$ type rvm | head -1
bash: type: rvm: not found
~$ source "/usr/local/rvm/scripts/rvm"
bash: /usr/local/rvm/scripts/rvm: No such file or directory
~$ source "$HOME/.rvm/scripts/rvm"
bash: /home/anonym/.rvm/scripts/rvm: No such file or directory
How can this be fixed?
PS
I'm using Ubuntu 11.10
Sudo problems. This worked for me to install rvm. Just do:
curl -L https://get.rvm.io | sudo bash -s stable --ruby
nano ~/.bashrc
at the bottom of the file add these line
unset rvm_path
unset GEM_HOME
Then run
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.3
rvm use 2.1.3 --default
ruby -v
Can you try this:
$ curl -s raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
or
$ curl -s raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | sudo bash -s stable
depending on your permissions. That should help. It helped me! :)
I'm sure there's a more elegant way to fix this, but I ran into the same issue and was kinda in a hurry, so I went for a quick and dirty workaround:
$ curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer > foo.sh
$ chmod 755 foo.sh
Then edit line 162, and add -k to the curl command:
$ vim foo.sh
162 if curl -Lk https://github.com/${_repo}/rvm/tarball/${_branch} -o ${rvm_archives_path}/${_repo}-rvm-${_branch}.tgz
Then run the script:
$ ./foo.sh --branch stable
Like I said, not ideal, but it got me where I needed to be quickly.
If anyone has this problem in the future in ubuntu I was getting this error because of an old package that still had config stuff hanging around.
Try running
sudo apt-get --purge remove ruby-rvm
That should take care of the permission error and let you install RVM as a normal user under $HOME/.rvm
Put this in your .bashrc instead (without echo)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
And restart your terminal.
You might have RVM installed under the wrong user. RVM won't let you install if it's installed under another user.
You can uninstall it from the other user with rvm implode.
Log over to the other user and RVM will install correctly!
https://rvm.io/rvm/security#ipv6-issues
You can forbid gpg's internal dirmngr from using IPv6 by add the following line to ~/.gnupg/dirmngr.conf:

Resources