OS X Mavericks broke rbenv? - ruby-on-rails

Recently, I installed OS X Mavericks, and it seemed to have messed up my development environment. I got this message after running 'rails new first_app':
Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.
Password:
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.9.0)
Using atomic (1.1.15)
Using thread_safe (0.2.0)
Errno::EACCES: Permission denied - /Library/Ruby/Gems/2.0.0/build_info/tzinfo-0.3.39.info
An error occurred while installing tzinfo (0.3.39), and Bundler cannot continue.
Make sure that `gem install tzinfo -v '0.3.39'` succeeds before bundling.
I then did what was asked of me:
christohersmbp2:hartl christopherspears$ gem install tzinfo -v '0.3.39'
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
What is weird is that I do have rbenv installed. In fact, while trying to debug this issue, I upgraded rbenv:
christohersmbp2:~ christopherspears$ brew update
Already up-to-date.
christohersmbp2:~ christopherspears$ brew upgrade rbenv ruby-build
Warning: A newer Command Line Tools release is available
Update them from Software Update in the App Store.
Error: rbenv-0.4.0 already installed
Error: ruby-build-20140225 already installed
However, I get this error message when I try to call rbenv from the command line:
christohersmbp2:hartl christopherspears$ rbenv
-bash: rbenv: command not found
christohersmbp2:~ christopherspears$ rbenv rehash
-bash: rbenv: command not found
I think I have the path set up properly:
christohersmbp2:hartl christopherspears$ echo $PATH
/usr/local/share/python:/Users/christopherspears/.rbenv/bin:/Users/christopherspears/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
This is what I have in my .bash_profile file:
# rbenv stuff
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Strangely enough, I do think I am using the Ruby version in my versions folder:
christohersmbp2:versions christopherspears$ pwd
/Users/christopherspears/.rbenv/versions
christohersmbp2:versions christopherspears$ ls
2.0.0-p247/
christohersmbp2:versions christopherspears$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
Any hints? I seem to be doing everything correctly.
UPDATE:
I downloaded and installed the Xcode command line tools. Didn't seem to work:
christohersmbp2:~ christopherspears$ rbenv
-bash: rbenv: command not found

As #Christoper Spears say, uninstall then reinstall, or more specifically:
$ brew uninstall rbenv
$ brew install rbenv
(supposing you used brew to install it in the first place).

Well...the secret apparently is to uninstall and then reinstall rbenv. Actually, uninstalling and reinstalling a dev tool broken by OS X Mavericks seems to (almost) always be the solution.

Related

running sudo gem install fastlane -NV throws the error installing fastlane rubyzip requires ruby version >= 2.4 when

running
sudo gem install fastlane -NV
throws the error installing fastlane rubyzip requires ruby version >= 2.4 when
Initially, environment setup was done by running the following steps -
First uninstall rvm if it is installed -
rvm -v
rvm list
rvm uninstall {version_to_uninstall}
rvm use system - Switch to macOS default ruby version
rvm implode - uninstall rvm
rbenv - Ruby Environment Manager - we will use this to install ruby
brew install rbenv ruby-build
rbenv install 2.3.7
Add the following line to .bash_profile -
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
source ~/.bash_profile
rbenv global 2.3.7
ruby -v
bundle install
bundle exec fastlane bootstrap
open ProjectName.xcworkspace
Fixed by changing ruby version to 2.6.0 as follows -
rbenv install 2.6.0
rbenv global 2.6.0
Then -
sudo gem install fastlane -NV

Installing Ruby - Digital Ocean - RVM - Unstable ruby version - Can't install Gems

I am trying to install Ruby & Rails on DigitalOcean droplet, I have downloaded ruby 2.5.1 with RVM but when I check version it says 2.31 and when I list available versions I get only 2.5.1.
I have tried rvm use 2.5.1 I got below problem
I fix it by running source ~/.rvm/scripts/rvm , then rvm use 2.5.1 and run bundle install, I get the following error,
can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
Below show the unstable issues faced from RVM and ruby versions
UPDATE
When I ssh into the server and run ruby -v, I get 2.5.1, then if I run
/bin/bash --login
I check ruby -v, its 2.5.1
install ruby 2.5.1 first, from your image it seems rvm already installed correctly
you just need to install it (it shows from your list command)
rvm install 2.5.1
# this to install version 2.5.1
rvm use 2.5.1
# active ruby 2.5.1
ruby -v
# check your version and make sure it said 2.5.1
to install bundler to your home directory use
# after you active ruby 2.5.1 then install bundler
gem install bundler
# my suggestion do not install with sudo
# in case you still has write problem below is other solution suggested [from here][1]
gem install bundler --user-install
This will install Bundler into your home directory. Note that you will need to append ~/.gem/ruby//bin to your $PATH variable to use bundle.

Gemset error when updating to Ruby 2.4.2

I'm updating from Ruby 2.0 to 2.4.2 using RVM, and receive the following error messages during an install using $ rvm install ruby-2.4.2:
Making gemset ruby-2.4.2 pristine - please wait
'command gem pristine --extensions bigdecimal --version 1.3.0 gem-wrappers --version 1.3.2 io-console --version 0.4.6 json --version 2.0.4 openssl --version 2.0.5 psych --version 2.2.2' failed, you need to fix this gems manually.
Error running '__rvm_with ruby-2.4.2 gemset_pristine',
please read /Users/myname/.rvm/log/1507820191_ruby-2.4.2/gemset.pristine-ruby-2.4.2.log
Making gemset ruby-2.4.2#global pristine - please wait
'command gem pristine --extensions bigdecimal --version 1.3.0 io-console --version 0.4.6 json --version 2.0.4 openssl --version 2.0.5 psych --version 2.2.2' failed, you need to fix this gems manually.
Error running '__rvm_with ruby-2.4.2#global gemset_pristine',
please read /Users/myname/.rvm/log/1507820191_ruby-2.4.2/gemset.pristine-ruby-2.4.2#global.log
I'm… not quite sure what this means, or what I should do next. Any thoughts? I'm running macOS 10.12.6.
[Edit]: Here's a copy of the error log.
According to the RVM docs, you don't use ruby- in the command.
It should be:
$ rvm install 2.4.2
I'm not sure if that matters or not though.
Have you tried upgrading RVM and Homebrew?
[Edit] Based on this info from the log file:
bigdecimal-1.3.0 +gemset_pristine:20> gem pristine --extensions bigdecimal --version 1.3.0
ERROR: Loading command: pristine (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
+gemset_pristine:21> _failed+=( 'bigdecimal --version 1.3.0' )
Looks like a zlib problem. Try installing (or re-installing) Command Line Tools.
$ xcode-select --install
There is a very similar issue on github https://github.com/rvm/rvm/issues/4090
It was solved by running $ brew doctor
Just came up against this after needing to use SASS after a while. During which time I had upgraded to El Capitan. So Ruby was 'Old'.
You could probably cut a lot of my steps out by running the following (with a little prior knowledge of the latest Ruby Version).
xcode-select --install
brew install zlib
rvm reinstall ruby-<latest_version> --with-zlib-dir=/usr/local/Cellar/zlib/<latest_version>
This was how I had to go about it. I didn't need to uninstall in the end but I took a lot of wrong turns.
Initially I had to run this line to get xcode up to date:
xcode-select --install
Then install zlib
brew install zlib
Take a note of the directory zlib is installed in
/usr/local/Cellar/zlib/1.2.11
Next update rvm
\curl -sSL https://get.rvm.io | bash -s stable --ruby
Following these steps got me to the point where I was running the latest version of ruby 2.4.1. But zlib wasn't linked to ruby.
So the final step was to run a reinstall
rvm reinstall ruby-2.4.1 --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11
Found a fix as referenced in this RVM GitHub issue that involves installing zlib using brew and then re-installing ruby while pointing to that zlib directory.
As someone in that thread pointed out, this shouldn't be necessary. Still not sure why the problem arose.
Steps
$ brew install zlib
$ rvm remove 2.4.2
$ rvm install 2.4.2 —-with-zlib-dir=/usr/local/Cellar/zlib/1.2.11

rails `bundle install` trying to install system wide

I accidentally ran sudo bundle install and now when I run just bundle install I get an error:
Error details:
Errno::EACCES: Permission denied # rb_sysopen -
here are the environment/bundler settings:
Environment
Bundler 1.12.3
Rubygems 2.6.4
Ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
GEM_HOME /Users/abdulahmad/.rvm/gems/ruby-2.3.0
GEM_PATH /Users/abdulahmad/.rvm/gems/ruby-2.3.0:/Users/abdulahmad/.rvm/gems/ruby-2.3.0#global
RVM 1.27.0 (latest)
Git 2.5.4 (Apple Git-61)
rubygems-bundler (1.4.4)
Bundler settings
orig_path
Set via BUNDLE_ORIG_PATH: "/Users/abdulahmad/.rvm/gems/ruby-2.3.0/bin:/Users/abdulahmad/.rvm/gems/ruby-2.3.0#global/bin:/Users/abdulahmad/.rvm/rubies/ruby-2.3.0/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/abdulahmad/.rvm/bin"
orig_gem_path
Set via BUNDLE_ORIG_GEM_PATH: "/Users/abdulahmad/.rvm/gems/ruby-2.3.0:/Users/abdulahmad/.rvm/gems/ruby-2.3.0#global"
is it trying to install system gems rather than just for my rails app? how can I fix this?
Update the global rubygems with :
sudo gem update --system --no-user-install.
Or try this:
bundle install --path ~/.gem
Other option is just uninstall bundler and install it again.

rbenv: no such command "install" even though ruby-build is installed

I'm trying to get ruby 2.1.4 installed via rbenv for a client project.
Though previously I've been able to install ruby versions through rbenv, after upgrading to Yosemite, I keep getting the following error:
rbenv: no such command 'install'
After digging around, I saw lots of tips about how "install" comes from the ruby-build plugin, which is installed via homebrew:
which ruby-build
/usr/local/bin/ruby-build
I installed rbenv via Homebrew, but when I try use which rbenv, I get:
rbenv () {
typeset command
command="$1"
if [ "$#" -gt 0 ]
then
shift
fi
case "$command" in
(rehash|shell) eval `rbenv "sh-$command" "$#"` ;;
(*) command rbenv "$command" "$#" ;;
esac
}
I have run brew update and brew upgrade rbenv ruby-builder, and it tells me everything is up to date.
Below is my full $PATH:
zsh: no such file or directory: /usr/local/var/rbenv/shims:/usr/local/var/rbenv/shims:/usr/local/bin:/usr/local/sbin:/Users/dannycox/.rbenv/shims:/Users/dannycox/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/Users/dannycox/.rbenv/shims:/Users/dannycox/.rbenv/bin
UPDATE: Found another answer with a little deeper digging on github that showed signs of promise, but failed to solve the issue with rbenv. https://github.com/sstephenson/rbenv/issues/610#issuecomment-56240018
I believe 2.1.4 is now installed on my machine, but it installed here:
Successfully installed ruby 2.1.4 into /Users/dannycox/.rubies/ruby-2.1.4
As a result, my bundler won't work with the new ruby 2.0 version and I get the following error when I try to gem install bundle:
Fetching: bundler-1.7.6.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
Still need help to identify why ruby-build isn't playing nice with rbenv...
Make sure to install optional step 5 in the instructions:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Install ruby-build, which provides the rbenv install command that simplifies the process of installing new Ruby versions.
I had similar problem, and trace the problem to ruby-build. So i updated the homebrew and reinstall the ruby-build
> brew update
> brew reinstall ruby-build
Find the ruby version
> brew ls -v ruby-build | grep 2.1.4
then install intended version ruby again
> rbenv install 2.1.4
From your perms error I think you are trying to install to the system ruby, which is the one that comes with Apple OSX. You want to use rbenv to install your own ruby and install gems into that.
Read - https://github.com/rbenv/ruby-build#readme
And use the
rbenv versions
command to show what instance of ruby you are about to install the gems into. If it's system then you need to install your own ruby instance and then use that ruby for gems.

Resources