Installation messed up with Ruby: Unable to install jekyll - ruby

I was trying to setup a GitHub Page using Jekyll, which rely on Ruby (like here). Unfortunately, I think I kind of messed up with the installation (after a few sudo apt-get install ruby-full and sudo apt-get remove ruby-full ...)
Right now, I am stuck with an old version of Ruby (I think) on my computer that I am not able to update. Here is the state of my system right now:
$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
$ gem -v
3.1.2
$ gem install jekyll
ERROR: Error installing jekyll:
The last version of sass-embedded (~> 1.54) to support your Ruby & RubyGems was 1.58.0. Try installing it with `gem install sass-embedded -v 1.58.0` and then running the current command again
sass-embedded requires RubyGems version >= 3.3.22. The current RubyGems version is 3.1.2. Try 'gem update --system' to update RubyGems itself.
$ gem update --system
Updating rubygems-update
Successfully installed rubygems-update-3.4.6
Parsing documentation for rubygems-update-3.4.6
Done installing documentation for rubygems-update after 0 seconds
Parsing documentation for rubygems-update-3.4.6
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.4.6
Traceback (most recent call last):
5: from setup.rb:22:in `<main>'
4: from setup.rb:22:in `require'
3: from /home/jarret/gems/gems/rubygems-update-3.4.6/lib/rubygems.rb:1332:in `<top (required)>'
2: from /home/jarret/gems/gems/rubygems-update-3.4.6/lib/rubygems.rb:1332:in `require'
1: from /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:49:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:50:in `<class:Specification>': undefined method `rubyforge_project=' for class `Gem::Specification' (NameError)
3: from setup.rb:22:in `<main>'
2: from setup.rb:22:in `require'
1: from /home/jarret/gems/gems/rubygems-update-3.4.6/lib/rubygems.rb:1328:in `<top (required)>'
/home/jarret/gems/gems/rubygems-update-3.4.6/lib/rubygems.rb:1342:in `rescue in <top (required)>': undefined method `rubyforge_project=' for class `Gem::Specification' (NameError)
Loading the /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb file caused an error. This file is owned by your OS, not by rubygems upstream. Please find out which OS package this file belongs to and follow the guidelines from your OS to report the problem and ask for help.
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.2
- RUBY VERSION: 2.7.0 (2019-12-25 patchlevel 0) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /home/jarret/gems
- USER INSTALLATION DIRECTORY: /home/jarret/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/bin/ruby2.7
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /home/jarret/gems/bin
- SPEC CACHE DIRECTORY: /home/jarret/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/jarret/gems
- /home/jarret/.gem/ruby/2.7.0
- /var/lib/gems/2.7.0
- /usr/lib/ruby/gems/2.7.0
- /usr/share/rubygems-integration/2.7.0
- /usr/share/rubygems-integration/all
- /usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/jarret/gems/bin
- /home/jarret/miniconda3/condabin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /snap/bin
- /opt/fiji/Fiji.app
I've tried many remove/install, I've tried updated gem, ruby. Nothing unlocked me so far.

Try to replace ruby3.0, sass1.58 is too advanced and may not be compatible with ruby2.7.
Please follow these steps and run the command.
rvm install 3.0
rvm use 3.0.0 -default
rvm -v
rvm gemset update
gem install jekyll
jekyll -v

Related

Bundler failing to install

I am trying to update bundler in a project. i updated rbenv ruby 2.6.6. Then i ran bundle install and nothing happened. I followed the instructions in the error msg. Programme runs and then times out.
git:(master) ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin18]
git:(master) bundler -v
Traceback (most recent call last):
2: from /Users/maryhealy/.rbenv/versions/2.6.6/bin/bundler:23:in `<main>'
1: from /Users/maryhealy/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/Users/maryhealy/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /Users/maryhealy/code_old/yance/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
git:(master) gem install bundler
^CERROR: Interrupted
git:(master) gem install bundler:2.1.4
^CERROR: Interrupted
I tried running this in project directory
gem install bundler -v '~> 2.1'
ERROR: Loading command: install (LoadError)
dlopen(/Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/openssl.bundle
Reason: image not found - /Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/openssl.bundle
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
I have old versions of ruby as per my gem env
➜ ~ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.14.1
- RUBY VERSION: 2.4.4 (2018-03-28 patchlevel 296) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: /Users/maryhealy/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/maryhealy/.rbenv/versions/2.4.4/bin/ruby
- EXECUTABLE DIRECTORY: /Users/maryhealy/.rbenv/versions/2.4.4/bin
- SPEC CACHE DIRECTORY: /Users/maryhealy/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/maryhealy/.rbenv/versions/2.4.4/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0
- /Users/maryhealy/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/maryhealy/.rbenv/versions/2.4.4/bin
- /usr/local/Cellar/rbenv/1.1.2/libexec
- ./bin
- ./node_modules/.bin
- /Users/maryhealy/.rbenv/shims
- /Users/maryhealy/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/maryhealy/.composer/vendor/bin
- /usr/local/sbin
i have no idea how to fix the problem to update bundler. Any help appreciated?
Installing bundler
You need to install Bundler globally, not only for the current project (in the project directory). This is because Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.
Open a terminal and write
gem install bundler
You can check if the installation is successful by writing
bundle -v

How do I make ruby on OSX read the correct Gems

I am running OSX High Sierra.
I have a ruby script I'm attempting to run on OSX (it's an Avid validation tool, but I don't think that matters).
When I run it, I get the following output ( added the code to print the version and the gem path)
MacBook-Pro:DTT jon$ ./run_test.command -h -v
-----
Ruby Version : 2.5.0
Gem Path :
/Users/jon/.gem/ruby/2.5.0
/Users/jon/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
-----
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- curses (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/jon/Downloads/AAX_Tools_DSH_0p2p1x753_2/DTT/sources/DishTestTool.rb:21:in `<top (required)>'
from /Users/jon/Downloads/AAX_Tools_DSH_0p2p1x753_2/DTT/sources/bin/runsuite.rb:82:in `require_relative'
from /Users/jon/Downloads/AAX_Tools_DSH_0p2p1x753_2/DTT/sources/bin/runsuite.rb:82:in `<main>'
Note that it appears to be reading gems from version 2.3, but I am actually running 2.5.0
and if I do gem env, there is no sign of that 2.3 folder
MacBook-Pro:DTT jon$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.0 (2017-12-25 patchlevel 0) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/jon/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/jon/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /Users/jon/.rbenv/versions/2.5.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jon/.rbenv/versions/2.5.0/bin
- SPEC CACHE DIRECTORY: /Users/jon/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/jon/.rbenv/versions/2.5.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/jon/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
- /Users/jon/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/jon/.rbenv/versions/2.5.0/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- /Users/jon/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/local/bin
- /opt/X11/bin
I've tried installing ruby with rvm, then uninstalled it, removed rvm, installed it again with rbenv. Installing and updating gems (curses in particular), etc etc (I'm a newbie with ruby and moderately familiar with the workings of Unix systems, but no systems guru), but all to no avail.
Does anybody know how I get ruby to read the correct gems?
--------------- Edit ----------------
I've discovered cause of the issue
The ruby script run_test.command called another ruby script, with the line
system("#{ruby} \"#{runsuite_path.realpath}\" #{args}")
Where, crucially
ruby = '/usr/bin/ruby'
For some reason, updating ruby does not change the version of ruby executed with /usr/bin/ruby
changing that line to
ruby = '/usr/bin/env ruby'
Seems to fix the issue
Which begs two questions. Why is /usr/bin/ruby not changed to reflect the update, and can I change it manually without issues?
The ruby binary that is found at /usr/bin/ruby is the version of Ruby installed by MacOS and should be left alone. Homebrew, Chruby, RVM & RBEnv all will install rubies in different locations away from the base so that they don't overwrite it or change it. This is expected behaviour, as you don't know what could be depending on the system ruby, or what has been natively compiled against it.

Ruby gems path issue (system vs brew)

I'm having an issue with homebrew looking to the system gems when the system gems aren't in the $PATH.
Here is my gem env to show that my gems are installed in my .rvm/gems directory:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin14]
- INSTALLATION DIRECTORY: /Users/scott/.rvm/gems/ruby-2.2.2
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /Users/scott/.rvm/gems/ruby-2.2.2/bin
- SPEC CACHE DIRECTORY: /Users/scott/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/scott/.rvm/gems/ruby-2.2.2
- /Users/scott/.rvm/gems/ruby-2.2.2#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- :benchmark => false
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
- SHELL PATH:
- /Users/scott/.rvm/gems/ruby-2.2.2/bin
- /Users/scott/.rvm/gems/ruby-2.2.2#global/bin
- /Users/scott/.rvm/rubies/ruby-2.2.2/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin
- /Users/scott/.rvm/bin
- /Users/scott/.composer/vendor/bin
- /usr/local/sbin
Now here is the error message I keep getting on various commands (this in particular was from brew services start httpd22):
Error: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin14.3.0/ports/libxml2/2.8.0... OK
Running 'compile' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-apple-darwin14.3.0/ports/libxml2/2.8.0/compile.log' to see what happened.
/Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:265:in `block in execute': Failed to complete compile task (RuntimeError)
from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `chdir'
from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `execute'
from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:69:in `compile'
from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:109:in `cook'
from extconf.rb:101:in `block in <main>'
from extconf.rb:119:in `call'
from extconf.rb:119:in `block in <main>'
from extconf.rb:109:in `tap'
from extconf.rb:109:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/nokogiri-1.6.1/gem_make.out
See how it's looking to the system version of Ruby & Gems? I have XCode installed and up to date.
brew doctor yields no results and brew update is ready to brew.
I'm using OS 10.10.3. Anything I've left out, just ask.
EDIT
Here is my .zshrc $PATH export:
export PATH="$PATH:$HOME/.composer/vendor/bin"
export PATH="$PATH:/usr/local/sbin"
export PATH="$PATH:$HOME/.rvm/bin"
EDIT 2
$GEM_HOME
/Users/scott/.rvm/gems/ruby-2.2.2
$GEM_PATH
/Users/scott/.rvm/gems/ruby-2.2.2:/Users/scott/.rvm/gems/ruby-2.2.2#global
Thoughts?
looking at brew:
https://github.com/Homebrew/homebrew/blob/master/bin/brew
https://github.com/Homebrew/homebrew/blob/master/bin/brew#L22
so brew is upsetting the GEM_PATH and doing its own thing.
Found the answer, the system rubygems.rb was referencing the wrong version of Ruby. More details here: https://github.com/Homebrew/homebrew/issues/31220

Fail to install racc with ruby 1.9.x

I really have some problems with gem. I'm trying to install racc for ruby so that it can compiler some *.y files. I'm working with my own laptop with Ubuntu.
The path of my ruby is
$ which ruby
/usr/bin/ruby
I'm a freshman of ruby. I have tried to install racc with sudo apt-get install racc. But it doesn't work. By the way, what's the difference between apt-get and gem?
$ sudo gem install racc
Building native extensions. This could take a while...
ERROR: Error installing racc:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:3:in `<main>'
Gem files will remain installed in /home/jianqing/RubyGems/gems/racc-1.4.9 for inspection.
Results logged to /home/jianqing/RubyGems/gems/racc-1.4.9/ext/racc/gem_make.out
Here is some information about my system.
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i686-linux]
- INSTALLATION DIRECTORY: /home/jianqing/RubyGems
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /home/jianqing/RubyGems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/jianqing/RubyGems
- /home/jianqing/.gem/ruby/1.9.1
- /var/lib/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Any help is appreciated. I almost crazy for it.
I have already solved that. It turns out to be I need to install a full ruby with sudo apt-get install ruby-dev

Rubygems permission problem when using sudo

I use sudo to install gems and update rubygems itself but this causes the problem of all new files in /usr/lib/ruby/gems/1.8/gems to be owned by root:root with a permission of 750
This in turn causes most gems to fail to load.
For example, I recently updated rubygems and if I try gem env I get:
/usr/local/lib/site_ruby/1.8/rubygems/specification.rb:512:in `read': Permission denied - /usr/lib/ruby/gems/1.8/specifications/rubygems-update-1.6.2.gemspec (Errno::EACCES)
from /usr/local/lib/site_ruby/1.8/rubygems/specification.rb:512:in `load'
from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:116:in `load_gems_in'
from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:115:in `each'
from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:115:in `load_gems_in'
from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:112:in `reverse_each'
from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:112:in `load_gems_in'
from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:309:in `refresh!'
from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:67:in `from_gems_in'
from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:47:in `from_installed_gems'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1025:in `source_index'
from /usr/local/lib/site_ruby/1.8/rubygems/gem_path_searcher.rb:135:in `init_gemspecs'
from /usr/local/lib/site_ruby/1.8/rubygems/gem_path_searcher.rb:14:in `initialize'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:984:in `new'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:984:in `searcher'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:206:in `try_activate'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from /usr/local/lib/site_ruby/1.8/rubygems/config_file.rb:55
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/site_ruby/1.8/rubygems/gem_runner.rb:8
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/bin/gem:9
The current workaround is to chmod all files to be readable by everyone but this is getting really annoying.
Some server stats:
uname -a gives
Linux HomeBox 2.6.35 28-server #49-Ubuntu SMP Tue Mar 1 14:55:37 UTC 2011 x86_64 GNU/Linux
sudo gem env gives
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/nicklas/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
ruby -v gives
ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux]
I'd be happy to provide more info on the problem.
Update
I just cleaned out all ruby and rubygems stuff and reinstalled it. Same problem.
I use Ubuntu at home too, and after many problems with using apt to install, I discovered RVM.
RVM is super-simple to install, and gets you up and running quickly and easily. But once you start using it for a while, you'll discover that it is superior to any OS package system because it has features that allow you to:
Install multiple versions of Ruby and JRuby and easily switch between them. I can just issue rvm use 1.9.2 or rvm use jruby-1.6.2 and my path is switched automatically and everthing just works.
Install sets of gems into "gemsets" which allow you to use the same gems across multiple ruby versions, so you don't have to manually reinstall. Also, you can switch between gemsets so you can isolate experimental gem versions, etc.
My recommendation is to uninstall the native ruby package, and install RVM. You'll be glad you did.

Resources