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
Related
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"'
I encountered this issue:
gabriele # osiris { ~ } [ ven nov 15 ] [ 12:57 ]
> jekyll
/var/lib/gems/1.8/gems/highline-1.6.19/lib/highline/system_extensions.rb:210: warning: Insecure world writable dir /home/gabriele in PATH, mode 040777
/var/lib/gems/1.8/gems/commander-4.1.3/lib/commander/runner.rb:365:in `require_program': program version required (Commander::Runner::CommandError)
from /var/lib/gems/1.8/gems/commander-4.1.3/lib/commander/runner.rb:364:in `each'
from /var/lib/gems/1.8/gems/commander-4.1.3/lib/commander/runner.rb:364:in `require_program'
from /var/lib/gems/1.8/gems/commander-4.1.3/lib/commander/runner.rb:52:in `run!'
from /var/lib/gems/1.8/gems/commander-4.1.3/lib/commander/delegates.rb:7:in `run!'
from /var/lib/gems/1.8/gems/commander-4.1.3/lib/commander/import.rb:10
from /usr/local/bin/jekyll:19
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- json (LoadError)
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.8/gems/jekyll-1.3.0/bin/../lib/jekyll/filters.rb:2
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.8/gems/jekyll-1.3.0/bin/../lib/jekyll.rb:43
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.8/gems/jekyll-1.3.0/bin/jekyll:7
from /usr/local/bin/jekyll:19:in `load'
from /usr/local/bin/jekyll:19
after I've installed jekyll on Ubuntu 12.04 with
sudo apt-get install ruby1.9.1-dev && sudo gem install jekyll
This is my gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/gabriele/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
How can i solve it?
Running gem install json should fix the LoadError.
Commander throws that program version required error whenever there is a problem loading in the executable (in this case, bin/jekyll). As 1.8.7 can't load an internal json library (introduced in 1.9), you'll need to install the gem.
I'm stuck, can't find the cause, it's suppossed to be simple,
This is the error message:
require': no such file to load -- ./ip (LoadError)
It's generated by this line of code:
require './ip'
As the
require 'socket'
works and I found the two libraries:
/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib/ip.rb
/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib/ip/socket.rb
tried also require 'ip'
and
require '../ip'
still same error
Backgroun info:
I installled ruby-ip so that I could invoke a method like: ip = IP.new do ...
gem installed ruby-ip
I can see the library ( I believe it's the ip.rb what I need to use;
pwd
/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib
ls
ip ip.rb
environment info
ruby -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [i386-linux]
gem list
*** LOCAL GEMS ***
builder (3.2.0)
eventmachine (1.0.1, 0.12.10)
pg (0.14.1, 0.13.2)
ruby-ip (0.9.1)
rubygems-update (2.0.0)
sqlite3 (1.3.3)
which ruby
/usr/bin/ruby
which gem
/usr/bin/gem
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.0
- RUBY VERSION: 1.8.7 (2012-10-12 patchlevel 371) [i386-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/pilar/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Are you including require 'rubygems' too? It is necessary if you are using rvm.
Example:
[fotanus#thing ~]$ gem install ip
Fetching: ip-0.3.0.gem (100%)
Successfully installed ip-0.3.0
1 gem installed
Installing ri documentation for ip-0.3.0...
Installing RDoc documentation for ip-0.3.0...
[fotanus#thing ~]$ irb
1.8.7 :001 > require 'ip'
LoadError: no such file to load -- ip
from (irb):1:in `require'
from (irb):1
1.8.7 :002 > require 'rubygems'
=> true
1.8.7 :003 > require 'ip'
=> true
1.8.7 :004 >
I have a simple script:
require 'rubygems'
require 'mechanize'
p 'Success!'
When I run the script, I get:
/Users/.../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mechanize.rb (LoadError)
from /Users/.../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from test.rb:2:in `<main>'
In desperation I installed RVM and updated ruby from system 1.8.7. Yet I am still getting the same error as before I installed rvm. I am now running:
mute:nfg ..$ ruby -v
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-darwin10.8.0]
irb reports the same:
1.9.3p385 :001 > require 'rubygems'
=> false
1.9.3p385 :002 > require 'mechanize'
LoadError: cannot load such file -- mechanize
from /Users/../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):2
from /Users/../.rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in `<main>'
I have re-installed mechanize, using sudo and without, several times from the project directory.
I have tried manually requiring the gem, along with its full path.
mute:nfg ..$ ruby -l ~/.gems/gems/mechanize-2.5.1/lib/mechanize.rb
/Users/../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mime/types (LoadError)
from /Users/../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/../.gems/gems/mechanize-2.5.1/lib/mechanize.rb:4:in `<main>'
(I have tried installing mime-types, too.)
RVM lists the gem fine:
mute:nfg ..$ rvm all do gem list
*** LOCAL GEMS ***
...
libxml-ruby (2.3.3, 1.1.2)
mechanize (2.5.1)
mime-types (1.21, 1.19)
...
As does gem:
mute:nfg ..$ gem list
*** LOCAL GEMS ***
...
libxml-ruby (2.3.3, 1.1.2)
mechanize (2.5.1)
mime-types (1.21, 1.19)
...
Curiously, the $GEM_PATHs ~/.rvm/gems/ruby-1.9.3-p385, ~/.rvm/gems/ruby-1.9.3-p385#global and ~/.rvm/gems/ruby-1.9.3-p385#project appear mostly empty (two gems in the first, none in either of the last). However, the GUI JewelleryBox confirms that all three gemsets contain Mechanize.
EDIT: Here is the result of gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-darwin10.8.0]
- INSTALLATION DIRECTORY: /Users/../.gems
- RUBY EXECUTABLE: /Users/../.rvm/rubies/ruby-1.9.3-p385/bin/ruby
- EXECUTABLE DIRECTORY: /Users/../.gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/../.gems
- /Users/../.gem
- /usr/lib/ruby/gems/1.8
- /Library/Ruby/Gems/1.8
- /usr/bin
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- "gemhome" => "/Users/../.gems"
- "gempath" => ["/Users/../.gem", "/usr/lib/ruby/gems/1.8", "/Library/Ruby/Gems/1.8", "/usr/bin"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
Can anyone help?
your environment is set to use custom paths for gems, this confuses rubygems as you install to places which are not available in PATH
run rvm get head and carefully read the outputs, it will warn you about entries in *gemrc that break rubygems / RVM
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').