-1

I'm trying to upgrade my ruby from the one installed by package manager 2.5 (currently) to 2.6 using snap. this is how i'm doing this

sudo snap install ruby --classic

/usr/bin/ruby is symlinked to the stable ruby installed by package manager. remove it.

sudo rm /usr/bin/ruby

make sure you PATH environment variable includes /snap/bin

Now i'm going to remove ruby installed by package manager.

$ sudo apt remove --purge ruby
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  geoipupdate lame libadns1 libjs-jquery-easing libjs-jquery-fancybox
  libjs-jquery-mousewheel libjs-source-map libjs-uglify
  libnumber-bytes-human-perl nginx python-adns python-easygui
  python-levenshtein python-metaconfig ruby-did-you-mean ruby-minitest
  ruby-net-telnet ruby-power-assert ruby-test-unit ruby-xmlrpc ruby2.5-doc
  rubygems-integration u3-tool vim-gui-common
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  armitage* beef-xss* bundler* cewl* commix* dradis* ghost-phisher*
  gpp-decrypt* jboss-autopwn* libruby2.5* maltego-teeth* metasploit-framework*
  msfpc* pipal* rake* rsmangler* ruby* ruby-activesupport* ruby-addressable*
  ruby-ansi* ruby-atomic* ruby-buftok* ruby-bundler* ruby-celluloid*
  ruby-celluloid-io* ruby-cms-scanner* ruby-concurrent* ruby-daemons*
  ruby-dataobjects* ruby-dataobjects-mysql* ruby-dataobjects-postgres*
  ruby-dataobjects-sqlite3* ruby-dev* ruby-diff-lcs* ruby-dm-core*
  ruby-dm-do-adapter* ruby-dm-migrations* ruby-dm-sqlite-adapter* ruby-docile*
  ruby-domain-name* ruby-em-websocket* ruby-equalizer* ruby-erubis*
  ruby-espeak* ruby-ethon* ruby-eventmachine* ruby-execjs* ruby-ffi*
  ruby-hitimes* ruby-http* ruby-http-cookie* ruby-http-form-data*
  ruby-http-parser.rb* ruby-httpclient* ruby-i18n* ruby-json* ruby-librex*
  ruby-maxmind-db* ruby-memoizable* ruby-mime* ruby-mime-types*
  ruby-mime-types-data* ruby-mini-exiftool* ruby-mojo-magick* ruby-molinillo*
  ruby-msfrpc-client* ruby-msgpack* ruby-multi-json* ruby-multipart-post*
  ruby-mustermann* ruby-naught* ruby-net-http-digest-auth*
  ruby-net-http-persistent* ruby-netrc* ruby-nio4r* ruby-nokogiri* ruby-oj*
  ruby-opt-parse-validator* ruby-parseconfig* ruby-pkg-config*
  ruby-progressbar* ruby-public-suffix* ruby-qr4r* ruby-rack*
  ruby-rack-protection* ruby-rchardet* ruby-rest-client* ruby-rqrcode*
  ruby-rspec-expectations* ruby-rspec-support* ruby-rubydns* ruby-rushover*
  ruby-simple-oauth* ruby-simplecov* ruby-simplecov-html* ruby-sinatra*
  ruby-slack-notifier* ruby-snmp* ruby-spider* ruby-sqlite3*
  ruby-term-ansicolor* ruby-thor* ruby-thread-safe* ruby-tilt* ruby-timers*
  ruby-tins* ruby-twitter* ruby-typhoeus* ruby-tzinfo* ruby-uglifier*
  ruby-unf* ruby-unf-ext* ruby-yajl* ruby-zip* ruby2.5* ruby2.5-dev* set*
  snmpcheck* thin* twofi* u3-pwn* unicorn-magic* urlcrazy* vim-gtk* whatweb*
  wpscan*
0 upgraded, 0 newly installed, 126 to remove and 22 not upgraded.
After this operation, 748 MB disk space will be freed.
Do you want to continue? [Y/n]

basically removing ruby means removing the whole system. Is there anyway to replace ruby in a transparent way in which i'm not forced to remove all these packages? And if i replace system's recommended ruby with the latest on snap how much system stability will be degraded?

$ uname -r
4.19.0-kali4-amd64
Eyeslandic
  • 14,553
  • 13
  • 41
  • 54
pouya
  • 3,400
  • 6
  • 38
  • 53
  • I would recommend that you use `rbenv` rather than the system packages. That way you can use different versions for different projects. – Eyeslandic May 03 '19 at 22:02
  • If you care about the stability of the system after upgrading to another Ruby version, did you consider testing the new version locally? Or setting up a seconds server with all versions updated and replace the first server when you know everything is fine with the second one? – spickermann May 04 '19 at 04:32
  • @Iceman I'm not familiar with ruby and when i reconsider my solution it seems totally stupid. I needed ruby 2.6 for `devdocs` which i guess is a rails app. So by `rbenv` or `rvm` it should be possible to install ruby 2.6 in `devdocs` directory and make the blunder happy. Am i right? – pouya May 04 '19 at 06:12
  • @spickermann actually i found about `rvm` and `rbenv` just recently. If a rails app requires ruby 2.6 on a system with ruby 2.5, Can we install ruby 2.6 in the rails app directory to satisfy the bundler? – pouya May 04 '19 at 06:18
  • When using a Ruby version manager like rbenv or RVM then you usually uninstall system Ruby and use the version manager to install all version you need on our system. In you example, you would uninstall the system Ruby 2.5 version, install a version manager of your choice, use the version manager to install Ruby 2.5 and Ruby 2.6 and then tell each app individually what Ruby version to use. – spickermann May 04 '19 at 06:24
  • @spickermann Then the first question comes up again. I'm runnig kali in which many tools are dependent on ruby. So if i wanted to remove the system ruby i should wipe the whole system and i don't get the reason for removing the system ruby. If an application wants ruby and rbenv or rvm provides a sandboxed env for the app with the required ruby then why to mess with the system ruby? – pouya May 04 '19 at 06:34

1 Answers1

0

Have you tried the channel option?

The Ruby news on ruby-lang.org mentions the following:

Our snap uses the “channel” feature to release multiple Ruby series concurrently. For example, without specifying a channel, currently Ruby 2.5.3 will be installed. But if you want to use Ruby 2.4, specify the 2.4 channel as follows: sudo snap install ruby --classic --channel=2.4/stable

Maybe there's more info on Github.

Of course, rbenv and rvm as mentioned by Iceman are an option as well.

Christian
  • 4,902
  • 4
  • 24
  • 42