7

When doing sudo jekyll serve I get the following error:

Users/myusername/.rvm/rubies/ruby-2.4.2/lib/ruby/site_ruby/2.4.0/rubygems.rb:271:in 'find_spec_for_exe': can't find gem jekyll (>= 0.a) (Gem::GemNotFoundException)
from /Users/myusername/.rvm/rubies/ruby-2.4.2/lib/ruby/site_ruby/2.4.0/rubygems.rb:299:in 'activate_bin_path'
from /Users/myusername/.rvm/gems/ruby-2.4.2/bin/jekyll:23:in '<main>'
from /Users/myusername/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in 'eval'
from /Users/myusername/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in '<main>'

In case it helps:

  • jekyll -v returns jekyll 3.6.2
  • ruby -v returns ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin15]
  • gem -v returns 2.6.14
  • bundle -v returns Bundler version 1.16.0

On my Gem file I have:

ruby '2.4.2'

rmv list output:

ruby-2.3.5 [ x86_64 ]
=* ruby-2.4.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • try install specific 2.4.2 version of ruby 'rvm install 2.4.2', set it as default and then install the gems again and everything – xploshioOn Nov 01 '17 at 01:10
  • I just did that a few minutes ago as per what I was suggested to do [here in the comments](https://stackoverflow.com/a/47039723/1081396). – Alvaro Nov 01 '17 at 01:12
  • `rvm --default use 2.4.2`? How to install the gems and "everything" ? As you can see I'm quite lost here :) – Alvaro Nov 01 '17 at 01:12
  • rvm install 2.4.2, then, rvm --default use 2.4.2, gem install jekyll – xploshioOn Nov 01 '17 at 01:16
  • I did that. `rvm install 2.4.2` shows `Already installed ruby-2.4.2.`. I then did `rvm --default use 2.4.2` but doing `ruby -v` still showing the same as before `ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin15]`. I also did `gem install jekyll` but still having exactly the same issue when running `sudo jekyll serve` – Alvaro Nov 01 '17 at 01:19
  • post the output of 'rvm list' – xploshioOn Nov 01 '17 at 01:20
  • Check it in the question. I updated it. – Alvaro Nov 01 '17 at 01:21
  • maybe the problem that you are facing is that you tried to install ruby before, without rvm, try removing everything about ruby, I don't have much experience with mac, but google 'how to remove ruby completely from mac' or something like that, then try again with the steps that I sent before, it should work – xploshioOn Nov 01 '17 at 01:25
  • Ok thanks! I'll try tomorrow and let you know! :) – Alvaro Nov 01 '17 at 01:26
  • @xploshioOn according to [this answer](https://stackoverflow.com/q/4115803/1081396) and [this other one](https://superuser.com/questions/194051/how-to-completely-remove-ruby-ruby-gems-on-mac-os-x-10-6-4) we should never remove the system's Ruby. So... not quite sure how to proceed with the removal of the rvm ruby I installed. Any tips? – Alvaro Nov 01 '17 at 15:13

1 Answers1

6

I finally solved it by doing:

sudo rm -rf _site
bundle update
bundle exec jekyll serve

And then always using bundle exec jekyll serve instead of sudo jekyll serve or jekyll serve.

I got this solution thanks to the answers in this post.

Alvaro
  • 40,778
  • 30
  • 164
  • 336