卸载rvm,卸载rvm安装的ruby以及解决相关问题

背景:系统为macos,自带ruby版本较低,因为工具需要安装flick程序

安装flick时有报错,但是最后也显示安装成功了,但是无法运行,

/usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/usr/local/lib/ruby/gems/2.3.0/gems/ffi-1.9.14/lib/ffi_c.bundle, 9): Library not loaded: /usr/local/opt/ruby/lib/libruby.2.3.0.dylib (LoadError)
  Referenced from: /usr/local/lib/ruby/gems/2.3.0/gems/ffi-1.9.14/lib/ffi_c.bundle
  Reason: image not found - /usr/local/lib/ruby/gems/2.3.0/gems/ffi-1.9.14/lib/ffi_c.bundle
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/local/lib/ruby/gems/2.3.0/gems/ffi-1.9.14/lib/ffi.rb:6:in `rescue in '
	from /usr/local/lib/ruby/gems/2.3.0/gems/ffi-1.9.14/lib/ffi.rb:3:in `'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/local/lib/ruby/gems/2.3.0/gems/sys-proctable-1.1.1-universal-darwin/lib/darwin/sys/proctable.rb:2:in `'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
	from /usr/local/lib/ruby/gems/2.3.0/gems/flick-0.3.2/lib/flick.rb:8:in `'
	from /usr/local/lib/ruby/gems/2.3.0/gems/flick-0.3.2/bin/flick:2:in `require_relative'
	from /usr/local/lib/ruby/gems/2.3.0/gems/flick-0.3.2/bin/flick:2:in `'
	from /usr/local/bin/flick:22:in `load'
	from /usr/local/bin/flick:22:in `
'


分析后觉得可能是ruby版本太低,需要升级ruby,这时走了弯路,从网上看升级ruby都需要用到rvm工具,所以装了rvm,然后 rvm install 2.4.2,安装了对应的ruby版本,然后安装了flick,命令行运行flick也没有问题,但是程序中运行时报错:

/usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': incompatible library version - /Users/haier/.rvm/gems/ruby-2.4.2/gems/ffi-1.9.23/lib/ffi_c.bundle (fatal)
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/haier/.rvm/gems/ruby-2.4.2/gems/ffi-1.9.23/lib/ffi.rb:6:in `rescue in '
	from /Users/haier/.rvm/gems/ruby-2.4.2/gems/ffi-1.9.23/lib/ffi.rb:3:in `'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/haier/.rvm/gems/ruby-2.4.2/gems/sys-proctable-1.2.0/lib/darwin/sys/proctable.rb:2:in `'
	from /Users/haier/.rvm/gems/ruby-2.4.2/gems/sys-proctable-1.2.0/lib/sys/proctable.rb:7:in `require_relative'
	from /Users/haier/.rvm/gems/ruby-2.4.2/gems/sys-proctable-1.2.0/lib/sys/proctable.rb:7:in `'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
	from /usr/local/Cellar/ruby23/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
	from /Users/haier/.rvm/gems/ruby-2.4.2/gems/flick-0.4.4/lib/flick.rb:8:in `'
	from /Users/haier/.rvm/gems/ruby-2.4.2/gems/flick-0.4.4/bin/flick:2:in `require_relative'
	from /Users/haier/.rvm/gems/ruby-2.4.2/gems/flick-0.4.4/bin/flick:2:in `'
	from /usr/local/bin/flick:22:in `load'
	from /usr/local/bin/flick:22:in `
'

提示lib库冲突,仔细看发现有两个版本的ruby,修改了默认ruby版本也没有解决。于是按照下面文章的步骤卸载rvm和后来安装的ruby:http://blog.csdn.net/maojudong/article/details/7918234

仔细删除了所有的环境变量和文件夹,重新brew upgrade ruby, 安装flick,再运行仍然报错:

/usr/local/Cellar/ruby/2.5.0_2/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem flick (>= 0.a) with executable flick (Gem::GemNotFoundException)
	from /usr/local/Cellar/ruby/2.5.0_2/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
	from /usr/local/bin/flick:23:in `
'

然后按照下面步骤执行:

$ which flick

/usr/local/bin/flick

$ rm -rf /usr/local/bin/flick

$ which flick

$ gem list

$ gem uninstall flick -v 0.4.4

$ gem install flick

再运行就可以了



你可能感兴趣的:(卸载rvm,卸载rvm安装的ruby以及解决相关问题)