Cannot load such file --mechanize - ruby

There is a class called ParseSearch.rb, which uses mechanize gem.
I made a new file that is used for Ruby Shoes(GUI) and I required all gems that are needed
require "mechanize"
require "rubygems"
require_relative "ParseSearch.rb"
In the terminal I installed the gem
$ gem install mechanize
Successfully installed mechanize-2.7.6
Parsing documentation for mechanize-2.7.6
Done installing documentation for mechanize after 0 seconds
1 gem installed
However, when I run the shoes.rb I get a error
Error in <unknown> line 0 | 2020-02-16 15:40:27 -0500
cannot load such file -- mechanize
.shoes/walkabout/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
.shoes/walkabout/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
search_shoes.rb:1:in `<main>'
.shoes/walkabout/lib/shoes.rb:353:in `eval'
.shoes/walkabout/lib/shoes.rb:353:in `visit'
.shoes/walkabout/lib/shoes.rb:139:in `show_selector'
.shoes/walkabout/lib/shoes.rb:169:in `block (4 levels) in splash'
The gem env are shown below.
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/daniel/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0
- USER INSTALLATION DIRECTORY: /.gem/ruby/2.6.0
- RUBY EXECUTABLE: /.rbenv/versions/2.6.3/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /.rbenv/versions/2.6.3/bin
- SPEC CACHE DIRECTORY: /.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /.rbenv/versions/2.6.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0
- /.gem/ruby/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /.rbenv/versions/2.6.3/bin
- /.rbenv/libexec
- /.rbenv/plugins/ruby-build/bin
- /.rbenv/shims
- /.rbenv/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /snap/bin

Related

Command not found after installing gem

After a version conflict I re-installed the middleman gem. It seems to have deleted the path as well which leads to the error
command not found: middleman
I am however not certain how to relink the command to the gem! Has anyone experienced a similar issue before and know what the best solution is to relink the two together?
Below my gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.7
- RUBY VERSION: 2.4.3 (2017-12-14 patchlevel 205) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/pimzonneveld/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: /Users/pimzonneveld/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/pimzonneveld/.rbenv/versions/2.4.3/bin/ruby
- EXECUTABLE DIRECTORY: /Users/pimzonneveld/.rbenv/versions/2.4.3/bin
- SPEC CACHE DIRECTORY: /Users/pimzonneveld/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/pimzonneveld/.rbenv/versions/2.4.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/pimzonneveld/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0
- /Users/pimzonneveld/.gem/ruby/2.4.0
- 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-document"
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
- SHELL PATH:
- /Users/pimzonneveld/.rbenv/versions/2.4.3/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- ./bin
- ./node_modules/.bin
- /Users/pimzonneveld/.rbenv/shims
- /Users/pimzonneveld/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/sbin
Installed middleman gems
*** LOCAL GEMS ***
font-awesome-middleman (4.5.0)
jquery-middleman (3.1.2)
middleman (4.2.1)
middleman-autoprefixer (2.9.0)
middleman-blog (4.0.2)
middleman-cli (4.2.1)
middleman-core (4.2.1)
middleman-sprockets (4.1.1)

Jekyll not serving locally - 'could not find jekyll'

I have little-to-no experience with ruby, but have been managing to successfully maintain a Jekyll site with github. However, for some unknown reason, when I cd into my website's directory and run jekyll serve I get the following error:
Could not find 'jekyll' (>= 0) among 7 total gem(s) (Gem::MissingSpecError)
Here is the full error message:
/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/dependency.rb:308:in `to_specs': Could not find 'jekyll' (>= 0) among 7 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/amin/.gem/ruby/2.4.0:/usr/local/lib/ruby/gems/2.4.0:/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/gems/2.4.0', execute `gem env` for more information
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/dependency.rb:320:in `to_spec'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/jekyll:22:in `<main>'
Trying gem env gives this, which looks a little messy:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/amin/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.2.0
- /Users/amin/.gem/ruby/2.2.0
- /usr/local/Cellar/ruby/2.2.2/lib/ruby/gems/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/amin/Dropbox/code/google-cloud-platform/google-cloud-sdk/bin
- //anaconda/bin
- /opt/local/bin
- /opt/local/sbin
- /opt/local/bin
- /opt/local/sbin
- /Library/Frameworks/Python.framework/Versions/3.4/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin
- /Library/TeX/texbin
My best guess is that Jekyll should be looking in usr/local/bin, and not usr/local/Cellar, but as I say, that's just a guess.
Any advice on how to get this working again would be greatly appreciated!

Gem install confusing the ruby version

I'm attempting to install vagrant-bindfs through the vagrant up, however it was failing, and the same happened with vagrant plugin install vagrant-bindfs.
So I've downloaded the gem file and attempted to install it manually, as you can see below:
------------------------------------------------------------
~/.vagrant.d/gems/gems » gem install -l ~/Downloads/vagrant-bindfs-0.4.12.gem --install-dir . --debug
NOTE: Debugging mode prints all exceptions even when rescued
Exception `LoadError' at /usr/local/Cellar/ruby/2.3.2/lib/ruby/2.3.0/resolv.rb:171 - LoadError
Exception `Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.2/lib/ruby/2.3.0/fileutils.rb:253 - File exists # dir_s_mkdir - /Users/ml/.vagrant.d/gems/gems
Exception `Gem::InstallError' at /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:611 - vagrant-bindfs requires Ruby version ~> 2.0.0.
ERROR: Error installing /Users/ml/Downloads/vagrant-bindfs-0.4.12.gem:
vagrant-bindfs requires Ruby version ~> 2.0.0.
------------------------------------------------------------
~/.vagrant.d/gems/gems » gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.8
- RUBY VERSION: 2.3.2 (2016-11-15 patchlevel 217) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/ml/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/ml/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.3.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.3.0
- /Users/ml/.gem/ruby/2.3.0
- /usr/local/Cellar/ruby/2.3.2/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- .
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/ml/.composer/vendor/bin
So as it mentions above it requires ~> 2.0.0, and the version gem is using is RUBY VERSION: 2.3.2, which should be ok.
Any idea what is happening here?

Running a script from gem in GitHub in RVM

Can anyone help me walk through what I'm doing wrong here? This is my first go w/ Ruby so any help would be appreciated:
I've installed RVM and executing it through Terminal
I'm trying to run the script detailed in this post from GitHub:
https://github.com/michiels/helpscout-export
I was successfully able to install the gem 'HelpScout'
When I run ruby export.rb MY_api_key I get this error message:
ruby: No such file or directory -- export.rb (LoadError)
Anyone have any insight? Here's my current gem environment:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 2.0.0 (2013-11-22 patchlevel 353) [x86_64-darwin15.0.0]
- INSTALLATION DIRECTORY: /Users/stevekrause/.rvm/gems/ruby-2.0.0-p353
- RUBY EXECUTABLE: /Users/stevekrause/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
- EXECUTABLE DIRECTORY: /Users/stevekrause/.rvm/gems/ruby-2.0.0-p353/bin
- SPEC CACHE DIRECTORY: /Users/stevekrause/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/stevekrause/.rvm/rubies/ruby-2.0.0-p353/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/stevekrause/.rvm/gems/ruby-2.0.0-p353
- /Users/stevekrause/.rvm/gems/ruby-2.0.0-p353#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/stevekrause/.rvm/gems/ruby-2.0.0-p353/bin
- /Users/stevekrause/.rvm/gems/ruby-2.0.0-p353#global/bin
- /Users/stevekrause/.rvm/rubies/ruby-2.0.0-p353/bin
- /Users/stevekrause/.rvm/bin
- /Library/Frameworks/Python.framework/Versions/3.5/bin
- /Users/stevekrause/anaconda/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin

Rails 4.2 and gem config broken

My OS X ruby dev environment is broken, I don't know why.
I undesrtood that the gem path is wrong, but I don't know how to fix it.
/Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'rails' (>= 0) among 14 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/muqaddar/.rvm/gems/ruby-2.0.0-p598:/Users/muqaddar/.rvm/gems/ruby-2.0.0-p598#global', execute `gem env` for more information
from /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:324:in `to_spec'
from /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /usr/bin/rails:22:in `<main>'
Here is my config with gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.6
- RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x86_64-darwin14.1.0]
- INSTALLATION DIRECTORY: /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598
- RUBY EXECUTABLE: /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/bin/ruby
- EXECUTABLE DIRECTORY: /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598/bin
- SPEC CACHE DIRECTORY: /Users/muqaddar/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598
- /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598/bin
- /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598#global/bin
- /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/bin
- /usr/local/mysql/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin
- /Users/muqaddar/.rvm/bin
I tried many things, reading lots of threads.
- reinstall rvm
- remove .vendor/bundle
- bundle install
...etc
I think the gems are not installed in the right directory. How to change that depending my rvm config ?
You should try and follow these steps if you are using a mac: http://www.installrails.com/
Note that when installing a new gem, you first have to add it to the Gemfile inside your editor. For example: gem 'bootstrap-sass', '~> 3.3.3'
After doing this navigate to your folder using terminal and type: "bundle install". This will install your added gems.

Resources