Fixing Ruby on OS X Yosemite - ruby-on-rails

I am getting the following error:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/yaml.rb:4:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- psych (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/yaml.rb:5:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/bin/hub:190:in `<main>'
I've tried the suggestions on Stack Overflow which are related libyaml and psych. However, many of those require rvm commands which return the following error:
rvm reinstall 2.0
/Users/richardburton/.rvm/src/ruby-2.0.0-p247 has already been removed.
Removing /Users/richardburton/.rvm/rubies/ruby-2.0.0-p247 - please wait
Error running '__rvm_rm_rf /Users/richardburton/.rvm/rubies/ruby-2.0.0-p247',
please read /Users/richardburton/.rvm/log/1401921952_ruby-2.0.0-p247/remove.rubies.log
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.0.0-p247.
Obviously there are a rvm binaries available at this stage. Any tips or suggestions on how I can get Ruby 2.0 up and running would be much appreciated.
Thanks!

The first error you are receiving is referencing your system ruby, and you're reinstalling with rvm. Try running which ruby. Most likely this can be fixed by updating your path. I wouldn't recommend reinstalling the system ruby, so I'd definitely recommend getting whatever was causing the first error to work with rvm.
If that still isn't working, I'd next try using rbenv instead of rvm. I'm personally a fan of rbenv and have had no issues with my Ruby using it. It's super easy to get up and running, and could be a good temp fix.
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile # or whichever profile you are using
$ source ~/.bash_profile # or whichever profile you are using
$ rbenv install <version number>
$ rbenv global <version number>
Links to rbenv info:
rbenv: https://github.com/sstephenson/rbenv
ruby-build: https://github.com/sstephenson/ruby-build#readme

rvm package install libyaml
rvm reinstall 1.9.3 --with-libyaml-dir=/home/rails/.rvm/usr
I had the same error and this worked for me
Source: https://serverfault.com/questions/442150/how-to-fix-ruby-installation-is-missing-psych-for-yaml-output-on-centos

I've bumped into the same issue and I have tried two solutions:
1) Using ruby-build to build ruby-2.0-p451 with prefix /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr --> DOES NOT WORK (GOT SEGMENTATION FAULT)
2) Replace with the stock version shipped with OSX 10.9 ---> WORKS!!
Please see my snippet on how to do it here: https://gist.github.com/joneslee85/73ece54ba5b3a17e8bb2
Now I can go to sleep. Good luck!

Related

I have trouble every bundle install with my rails. How to fix it

With guide on gorails I set up homebrew, rbenv and rails. But then when I work with other project from github and when I do bundle install It doesn't work.
Here is the error, I am looking for the answer but still don't find
/Users/user/.rbenv/versions/2.2.2/bin/rails:23:in `load': cannot load such file -- /Users/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rails-4.2.4/bin/rails (LoadError)
from /Users/user/.rbenv/versions/2.2.2/bin/rails:23:in `<main>'
Thanks
Seems like a rehash failure, run: rbenv rehash
If that works, see here for why.

Homebrew not working after I installed 'sudo gem install rails'

After running any homebrew command I get the same error over and over......
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- extend/module (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /usr/local/Library/Homebrew/global.rb:1:in <top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /usr/local/Library/brew.rb:16:in'
The best idea – use rvm.
First of all reinstall homebrew.
Then install rvm:
\curl -sSL https://get.rvm.io | bash -s stable
Then you need to provide ruby version and gemset. Go to app folder and create files .ruby-version and .ruby-gemset (including dot). Then add version and gemset in this files. Simple way to do it via console. In console, go to app directory, then:
echo ruby-2.1.3 >> .ruby-version
echo gemsetname >> .ruby-gemset
Of course, provide ruby version that you need. Gemsetname is often equal to app name. So, if your app is called coolapp, your gemsetname should be coolapp. Smth like this:
echo coolapp >> .ruby-gemset
Now, leave app directory and try to enter it again via console:
cd /path/to/your/app
RVM will generate everything you need automatically and you will see stmth like this:
ruby-2.1.3 - #gemset created /Users/username/.rvm/gems/ruby-2.1.3#coolapp
ruby-2.1.3 - #generating coolapp wrappers..........
Boya! This approach will provide same version and gemset name for every developer because files will be included in git. And that will decrease bug level. Everything you need from this moment, just use:
bundle install
And everything should goes right!
I would recommend using rbenv or rvm to manage your development Ruby version and gems. Editing OS X's system Ruby could cause difficult-to-diagnose problems.
Also, you shouldn't need to sudo to install gems. You need to be very careful when sudoing a command since, again, it could cause difficult-to-diagnose problems with the operating system down the road.
So, I'd recommend you re-install homebrew, then install rbenv from git, then gem install away.

Running rails server

I am coming up against issues running a rails server on a local environment. I am on Mac OS X 10.10. I think they relate to the osx-gcc-installer.
Running in Terminal:
$ rails server
Results in:
Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3
Cool, so then I run:
$ rvm install 1.9.3-p550
Which results in:
-bash: rvm: command not found
This solves that:
$ source ~/.bashrc
So I run this again:
$ rvm install 1.9.3-p550
Which produces this:
Warning, new version of rvm available '1.26.1', you are using older version '1.26.0'.
You can disable this warning with: echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable auto-update with: echo rvm_autoupdate_flag=2 >> ~/.rvmrc
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-1.9.3-p550.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
password required for 'softwareupdate -l':
Checking requirements for osx.
Installing requirements for osx.
Updating system.....
Installing required packages: gcc48, libyaml, libksba......
Error running 'requirements_osx_brew_libs_install gcc48 libyaml libksba',
showing last 15 lines of /Users/<user>/.rvm/log/1415842393_ruby-1.9.3-p550/package_install_gcc48_libyaml_libksba.log
++ case "$1" in
++ [[ -t 1 ]]
++ return 1
++ printf %b 'There were package installation errors, make sure to read the log.
Try `brew tap --repair` and make sure `brew doctor` looks reasonable.
Check Homebrew requirements https://github.com/Homebrew/homebrew/wiki/Installation\n'
There were package installation errors, make sure to read the log.
Try `brew tap --repair` and make sure `brew doctor` looks reasonable.
Check Homebrew requirements https://github.com/Homebrew/homebrew/wiki/Installation
++ case "$_system_version" in
++ return 1
Requirements installation failed with status: 1.
So, as it suggests, I try:
brew tap --repair
Which says:
Pruned 0 dead formulae
Tapped 161 formulae
And run:
brew doctor
Which gives two warnings both mentioning osx-gcc-installer (which I stupidly installed as part of the Team Treehouse instructions for setting up a dev environment):
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.
Warning: You seem to have osx-gcc-installer installed.
Homebrew doesn't support osx-gcc-installer. It causes many builds to fail and
is an unlicensed distribution of really old Xcode files.
Please run `xcode-select --install` to install the CLT.
I run:
xcode-select --install
And get this:
Usage: xcode-select -print-path
or: xcode-select -switch <xcode_folder_path>
or: xcode-select -version
Arguments:
-print-path Prints the path of the current Xcode folder
-switch <xcode_folder_path> Sets the path for the current Xcode folder
-version Prints xcode-select version information
Which doesn't seem to have done anything so I fetch the CLT from https://developer.apple.com/downloads/index.action# (which I'm pretty sure I had beforehand), install, and reboot.
Do I really need to reinstall my OS to solve this problem? That seems like overkill and I'm hoping somebody has another solution.
Update
On the suggestion of a commenter, I tried this:
$ rvm use 1.9.3 --default
Which returned:
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.
So I tried the steps here and
$ source ~/.rvm/scripts/rvm
And re-ran:
$ rvm use 1.9.3
Which resulted in
ruby-1.9.3-p550 is not installed.
To install do: 'rvm install ruby-1.9.3-p550'
So I checked which versions I had using
$ rvm list
And got
rvm rubies
ruby-1.9.3-p0-falcon [ x86_64 ]
ruby-1.9.3-p545 [ x86_64 ]
Then ran:
$ rvm use 1.9.3-p0-falcon --default
And tried:
$ rails server
Which resulted in:
Could not find bcrypt-ruby-3.0.1 in any of the sources
Run `bundle install` to install missing gems.
But bundle install outputs:
/Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/1.9.1/x86_64-darwin13.1.0/openssl.bundle, 9): Library not loaded: ##HOMEBREW_CELLAR##/openssl/1.0.1j/lib/libcrypto.1.0.0.dylib (LoadError)
Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Reason: image not found - /Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/1.9.1/x86_64-darwin13.1.0/openssl.bundle
from /Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/1.9.1/openssl.rb:17:in `<top (required)>'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/vendor/net/http/persistent.rb:201:in `<class:Persistent>'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/vendor/net/http/persistent.rb:191:in `<top (required)>'
from /Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/vendored_persistent.rb:3:in `<top (required)>'
from /Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/<username>/.rvm/rubies/ruby-1.9.3-p0-falcon/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/fetcher.rb:1:in `<top (required)>'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/cli.rb:247:in `install'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/vendor/thor/command.rb:27:in `run'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/vendor/thor/invocation.rb:121:in `invoke_command'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/vendor/thor.rb:363:in `dispatch'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/vendor/thor/base.rb:440:in `start'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/cli.rb:10:in `start'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/bin/bundle:20:in `block in <top (required)>'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/gems/bundler-1.5.3/bin/bundle:20:in `<top (required)>'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/bin/bundle:23:in `load'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon#global/bin/bundle:23:in `<main>'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon/bin/ruby_executable_hooks:15:in `eval'
from /Users/<username>/.rvm/gems/ruby-1.9.3-p0-falcon/bin/ruby_executable_hooks:15:in `<main>'
Which looks a bit more serious, but at least it isn't telling me to reinstall my OS.

LoadError: dlopen(digest/sha1.bundle): Symbol not found: _rb_Digest_SHA1_Finish

Ruby stopped working on my brother's machine recently.
gem commands
rails server
rails console
All failed with the following error:
$ irb
irb(main):001:0> require 'digest/sha1'
LoadError: dlopen(~/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/digest/sha1.bundle, 9): Symbol not found: _rb_Digest_SHA1_Finish
Referenced from: ~/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/digest/sha1.bundle
Expected in: flat namespace
in ~/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/digest/sha1.bundle - ~/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/x86_64-darwin12.2.0/digest/sha1.bundle
from ~/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from ~/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from (irb):1
from ~/.rbenv/versions/2.0.0-p0/bin/irb:12:in `<main>'
He tried different versions of Ruby. Reinstalling everything with rvm. Running rvm implode and reinstalling rvm. Switching to rbenv. Several Rubies installed via ruby-build. brew install ruby.
All had the same problem.
If he uninstalled all rubies, the OS supplied version in /usr/bin/ruby worked. But it's 1.8.7.
After hours of troubleshooting, we arrived at the solution below. I hope it helps you avoid some pain.
Possible solutions:
$ unset C_INCLUDE_PATH and reinstall Ruby
This is the solution that worked for me.
$ echo $C_INCLUDE_PATH
If C_INCLUDE_PATH is set, it will break Ruby builds. Remove it from your environment; either temporarily with $ unset C_INCLUDE_PATH, or permanently (might be in .bashrc, .profile, .bash_profile); then reinstall ruby.
It might be related to OpenSSL, RVM, XCode's Command Line Tools (gcc), or other build issues.
See this answer if the previous solution didn't work.
For anyone, like me, coming here because of an error like this:
LoadError: dlopen(/Users/sebkomianos/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin13.0.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /Users/sebkomianos/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin13.0.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
One solution (taken from here) might be to reinstall your version of ruby. eg: rbenv install 2.0.0-p247

RubyGems Dependency Error

My ruby version is => ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
and I'm using Ubuntu 10.10. I installed every stuff following this blogpost. It was working fine on bash but when I installed zsh shell and oh-my-zsh then it started raising following dependency error:
/home/manish/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)
from /home/manish/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /home/manish/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
from /home/manish/.rvm/gems/ruby-1.9.2-p290/bin/rails:18:in `<main>'
Please tell me if there is any way to fix this.
P.S. => I have installed bundler gem. I also tried to uninstall rvm and reinstall but didn't worked.
Oh crap this sucks. I already had rvm script
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
in my ~/.zshrc
but it use to say following error in my zsh shell every time:
cd:cd:10: string not in pwd: ..
then i rewrote the same script again following the previous one i.e. running same script twice in ~/.zshrc, it WORKED. I still could not figure it out why it raises string not in pwd.... error on first script and runs the second one.
But yay! feels good to finally use zsh on my Ubuntu also :)
From looking at your rvm info it seems that this isn't quite right:
homes:
gem: "not set"
ruby: "not set"
I would have another crack at reinstalling rvm, it shouldn't be that difficult. If you're having problems then you can ask on the channel #rvm on the freenode IRC network.
Other things to try would be rvm reload followed by rvm 1.9.2.

Resources