Can't require ruby gems on windows 10 - ruby

I have installed ruby -v 2.2.4 (64x) on Windows 10 from it's official website. The setup completed successfully, but ruby isn't able to require gems. Whenever I run the following command from IRB:
require 'minitest'
It fails with the output:
LoadError: cannot load such file --
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
'require'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
'require'
from (irb):1
from C:/Ruby22-x64/bin/irb:11:in '< main>'
Gem list:
bigdecimal (1.2.6)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
test-unit (3.0.8)
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5.1
- RUBY VERSION: 2.2.4 (2015-12-16 patchlevel 230) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby22/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: C:/Ruby22/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby22/bin
- SPEC CACHE DIRECTORY: C:/Users/alexl/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby22/lib/ruby/gems/2.2.0
- C:/Users/alexl/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\Users\alexl\bin
- C:\Program Files\Git\mingw64\bin
- C:\Program Files\Git\usr\local\bin
- C:\Program Files\Git\usr\bin
- C:\Program Files\Git\usr\bin
- C:\Program Files\Git\mingw64\bin
- C:\Program Files\Git\usr\bin
- C:\Users\alexl\bin
- C:\ProgramData\Oracle\Java\javapath
- C:\Windows\system32
- C:\Windows
- C:\Windows\System32\Wbem
- C:\Windows\System32\WindowsPowerShell\v1.0
- C:\Program Files (x86)\Skype\Phone
- C:\HashiCorp\Vagrant\bin
- C:\Program Files (x86)\EaseUS\Todo Backup\bin
- C:\wamp\bin\php\php5.6.15
- C:\ProgramData\ComposerSetup\bin
- C:\Ruby22\bin
- C:\Users\alexl\AppData\Local\atom\bin
- C:\Program Files\Git\usr\bin\vendor_perl
- C:\Program Files\Git\usr\bin\core_perl
I have googled around for some time, but could not find any useful information about resolving this issue.
Edit 1
I have uninstalled the x64 version and installed the x86 one. The error still persists

Related

Could not find 'rubyzip' (~> 1.0)

When trying to execute my ruby script I receive the following error message
C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/dependency.rb:308:in `to_specs': Could
not find 'rubyzip' (~> 1.0) among 14 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=C:/Users/me/.gem/ruby/2.4.0;C:/Ruby24-
x64/lib/ruby/gems/2.4.0', execute `gem env` for more information
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/specification.rb:1442:in
`block in activate_dependencies'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/specification.rb:1431:in
`each'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/specification.rb:1431:in
`activate_dependencies'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/specification.rb:1413:in
`activate'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems.rb:220:in `rescue in
try_activate'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems.rb:213:in `try_activate'
from C:/Ruby24-
x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:126:in `rescue in
require'
from C:/Ruby24-
x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from setupscript.rb:2:in `<main>'
I run gem env and the following is returned
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.11
- RUBY VERSION: 2.4.1 (2017-03-22 patchlevel 111) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby24-x64/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: C:/Users/me/.gem/ruby/2.4.0
- RUBY EXECUTABLE: C:/Ruby24-x64/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby24-x64/bin
- SPEC CACHE DIRECTORY: C:/Users/me/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Ruby24-x64/lib/ruby/gems/2.4.0
- C:/Users/me/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => []
- REMOTE SOURCES:
- SHELL PATH:
- C:\Program Files\ConEmu\ConEmu\Scripts
- C:\Program Files\ConEmu
- C:\Program Files\ConEmu\ConEmu
- C:\ProgramData\Oracle\Java\javapath
- C:\Windows\system32
- C:\Windows
- C:\Windows\System32\Wbem
- C:\Windows\System32\WindowsPowerShell\v1.0\
- C:\Program Files (x86)\Oracle\instantclient_11_2
- C:\Program Files (x86)\WebEx\Productivity Tools
- C:\Program Files\nodejs\
- C:\Program Files (x86)\Silk\SilkTest
- C:\Program Files (x86)\Silk\SilkTest\ng\gui
- C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
- C:\Program Files\dotnet\
- C:\Ruby24-x64\bin
C:\Users\me\AppData\Local\Microsoft\WindowsApps,C:\Users\me\Documents\Automation\SeleniumBrowserDrivers\IEDriverServer_Win32_3.4.0\
- C:\Users\me\AppData\Local\Programs\Fiddler
- C:\Users\me\AppData\Roaming\npm"
My script is the sample ruby script on seleniumhq page.
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :IE
driver.get "http://google.com"
element = driver.find_element :name => "q"
element.send_keys "Cheese!"
element.submit
puts "Page title is #{driver.title}"
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { driver.title.downcase.start_with? "cheese!" }
puts "Page title is #{driver.title}"
driver.quit
Thanks,
Scott
For some reason I was unable to install rubyzip. I needed to
download the gem into my system
navigate to the folder
execute gem install --force --local *.gem
When I did the above steps the gem was installed.

ruby gem not found although it is installed (Ubuntu 14)

I know this question has been asked before, yet I've not been able to remedy it with the existing advice.
My gem environment is as follows:
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.3 (2014-10-27 patchlevel 550) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.9.1
- /home/egge/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I installed the my gem:
gem list --local | grep active
activesupport (4.1.7)
activesupport-inflector (0.1.0)
But when I run ruby, it can't find it:
/usr/bin/ruby1.9.1 -e 'require "active_support/inflector"'
-e:1:in `require': cannot load such file -- active_support/inflector (LoadError)
from -e:1:in `<main>'
I am at a loss as to why this setup isn't working.
I found a workaround. I'm not sure what the cause of my issue is, but apparently there is some change with Ruby 1.9.2+. The following works fine:
/usr/bin/ruby1.9.1 --disable-gems -e 'require "rubygems"; require "active_support/inflector"'

Ruby 1.9.3 - cannot load such file for some reason

Ruby 1.9.3
Very simple code and very simple question I can't deal with:
gem list --local
nokogiri (1.5.5)
gem q --local
nokogiri (1.5.5)
But a ruby script (not Rails):
require 'nokogiri'
doc = Nokogiri.XML("some valid xml....")
gives me
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- nokogiri (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/alex/test.rb:3:in `<main>'
[Finished in 0.1s with exit code 1]
I'm aware that it's not necessary to use require 'rubygems', but even when I do that, it does not work either.
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/alex/.rvm/gems/ruby-1.9.3-p194
- RUBY EXECUTABLE: /home/alex/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /home/alex/.rvm/gems/ruby-1.9.3-p194/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/alex/.rvm/gems/ruby-1.9.3-p194
- /home/alex/.rvm/gems/ruby-1.9.3-p194#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
gem which nokogiri
/home/alex/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri.rb
It happens because of the wrong Sublime Text build system. The right one is here How to run ruby files in sublime-text-2
you need to add Nokogiri to the Gemfile (with the line gem 'nokogiri').

Ruby gems home on Windows

I installed ruby for windows and then rubygems but am getting the following error when trying to use rubygems to install bundler.
C:\Users\tgandrews\Ruby\rubygems-1.8.24>gem install bundler --verbose --debug
Exception `NameError' at C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:177 - uninitialized constant Gem::Commands::InstallCommand
Exception `Errno::ENOENT' at C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:54 - No such file or directory - Z:/
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - Z:/
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:54:in `stat'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:54:in `initialize'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:43:in `new'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:43:in `fetcher'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:110:in `find_gems_with_sources'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:228:in `find_spec_by_name_and_version'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:259:in `install'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:121:in `block in execute'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:115:in `each'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:115:in `execute'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/command.rb:278:in `invoke'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:147:in `process_args'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:117:in `run'
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:65:in `run'
C:/Ruby193/bin/gem:30:in `<main>'
My gem env returns the following
C:\Users\tgandrews\Ruby\rubygems-1.8.24>gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby193/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby193/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby193/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby193/lib/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
This might be caused by a network drive and incorrect configuration of environment variables like HOME, HOMEDRIVE and/or HOMEPATH
Please see the following section of RubyInstaller troubleshooting section:
https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#wiki-network_drive_home

Installing The ruby-gmail rubygem on Mac OS Snow Leopard

I'm working off these instructions: http://github.com/dcparker/ruby-gmail
From the home directory I do a standard install and good stuff happens:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ sudo gem install ruby-gmail
Successfully installed ruby-gmail-0.2.1
1 gem installed
Installing ri documentation for ruby-gmail-0.2.1...
Installing RDoc documentation for ruby-gmail-0.2.1...
I head over to my ~/www dir where I run scripts that include other rubygems successfully and create a gmail directory. I create a script that includes rubygems and gmail, but does nothing else:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ pwd
/Users/johnnygoodman/www/gmail
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ ls
test-send.rb
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ cat test-send.rb
require 'rubygems'
require 'gmail'
I run this script and the errors begin:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ ruby test-send.rb
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- mime/message (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/ruby-gmail-0.2.1/lib/gmail/message.rb:1
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/ruby-gmail-0.2.1/lib/gmail.rb:168
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from test-send.rb:2
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$
Here's my gem env:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/johnnygoodman/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://rubygems.org/
- http://gems.github.com
The path that the errors give when I run the script is not the same as the GEM PATHS given in the env output. However, I don't know how to make them match or if that's the significant thing here.
sudo gem install mime
the problem with the Asif solution is than mime/message is necessary for atach any file to the mail, if you comment this line u are unable do it

Resources