'Could not find public_suffix-2.0.4 in any of the sources

It started when I tried to add the Google Tag Manager Gem to my local installation of Jekyll.

A little background here, I'm using homebrew and rbenv.
My ruby version is 2.4.1 or at least I think it is.

The gem didn't install and after that Jekyll started giving me this message:

Could not find public_suffix-2.0.4 in any of the sources
Run `bundle install` to install missing gems.

After running 'bundle install' I get this error:

Rubygems 2.0.14.1 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Using public_suffix 2.0.4
Using colorator 1.1.0
Using ffi 1.9.14
Using forwardable-extended 2.6.0
Using sass 3.4.22
Using rb-fsevent 0.9.8
Using kramdown 1.12.0
Using liquid 3.0.6
Using mercenary 0.3.6
Using rouge 1.11.1
Using safe_yaml 1.0.4
Using bundler 1.14.6
Using addressable 2.5.0
Using rb-inotify 0.9.7
Using pathutil 0.14.0
Using jekyll-sass-converter 1.4.0
Using listen 3.0.8
Using jekyll-watch 1.5.0
Using jekyll 3.3.0
Using jekyll-feed 0.8.0
Bundle complete! 2 Gemfile dependencies, 20 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

So I tried to update Rubygems. Silly me.

This message showed on Terminal:

/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/yaml.rb:5: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. /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:inrequire': dlopen(/usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.bundle, 9): Library not loaded: /usr/local/opt/ruby/lib/libruby.2.4.0.dylib (LoadError) Referenced from: /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.bundle Reason: image not found - /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.bundle from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.rb:8:in' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/yaml.rb:6:in <top (required)>' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems.rb:701:inload_yaml' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:340:in load_file' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:202:ininitialize' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:75:in new' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:75:indo_configuration' from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:40:in run' from /usr/local/bin/gem:21:in'

Did I mentioned I'm using homebrew and rbenv? Ok.

This morning I reinstalled Ruby (using Homebrew) and told rbenv to use that version.

So I think that my paths might be the problem but I doubt because this is the content of my paths file:

/Users/bgomes/.nvm/versions/node/v6.10.2/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

This is the content of .bash_profile:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
export export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
source ~/.nvm/nvm.sh

And this is the content of .bashrc:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
source ~/.nvm/nvm.sh

I'm out if ideas here and definitively could use your help.

Thanks.



Solution 1:[1]

Right so what solve my problem was trashing the homebrew installation of ruby, removing its symlinks, then installing rvm and installing ruby through rvm.

Took me 3 hours to find this solution.

¯\_(?)_/¯

Solution 2:[2]

Running bundle update && bundle install worked for me.

Solution 3:[3]

'docker-compose build --no-cache'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bemed
Solution 2 Filipe Brito
Solution 3 Hamidreza-Safari