My step is,
Execute RubyInstaller.exe file
install ruby
installed Path: c:\ruby193
install DevKit
gem install libxml-ruby --platform x86-mswin32-60
make test.rb file
require 'rubygems'
require 'xml'
ruby test.rb
print error msg
Error message:
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
126: The specified module could not be found - C:/Ruby193/lib/ruby/gems/1.9.1/gems/lib
xml-ruby-1.1.3-x86-mswin32-60/lib/libxml_ruby.so (LoadError)
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libxml-ruby-1.1.3-x86-mswin32-6 0/lib/libxml.rb:9:in `<top (required)>'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libxml-ruby-1.1.3-x86-mswin32-6 0/lib/xml.rb:11:in `<top (required)>'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from test.rb:2:in `<main>'
i want solution in this problem
plz. help me.
Had similar problem on Windows 7x64 with libxml-ruby 2.3.3 (Ruby 2, 1.9.3 and 1.9.2). As per this solution:
https://github.com/xml4r/libxml-ruby/issues/42#issuecomment-7040881
I managed my problem was also solved. Solution (thanks to the original author):
Locate 'libxml.rb' in libxml-ruby gem folder (something like 'C:\Ruby\Ruby192\lib\ruby\gems\1.9.1\gems\libxml-ruby-2.3.3-x86-mingw32\lib')
Add the following on top of the file:
ENV['PATH'] = ENV['PATH'] + ';' + File.expand_path(File.dirname(__FILE__) + '/libs')
Save and enjoy
Related
I ran into the error when I tried to run SQL through ruby script. Can someone help me figure out what could be the cause? I already looked for some similar posts but couldn't find the right solution yet.
/Users/User/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require': Could not load 'active_record/connection_adapters/redshift_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
from /Users/User/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/pg-0.17.1/lib/pg.rb:4:in `<top (required)>'
from /Users/User/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /Users/User/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activerecord4-redshift-adapter-0.2.1/lib/active_record/connection_adapters/redshift_adapter.rb:17:in `<top (required)>'
from /Users/User/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
from /Users/User/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
from /Users/User/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activerecord-4.2.10/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
from /Users/User/.rvm/gems/ruby-2.4.3/gems/activerecord-4.2.10/lib/active_record/connection_handling.rb:50:in `establish_connection'
from /Users/User/Desktop/github/tracker/app/workers/appsflyer_importer_worker_aggregate.rb:100:in `fetch_data'
from /Users/User/Desktop/github/tracker/app/workers/appsflyer_importer_worker_aggregate.rb:120:in `perform'
from -:30:in `<main>'
Here is my settings:
Gemfile
ruby '2.4.3'
gem 'activerecord4-redshift-adapter', '~> 0.2'
gem 'pg'
Ruby version
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-darwin17]
Gem list
activerecord (4.2.10, 4.2.8)
activerecord4-redshift-adapter (0.2.1)
pg (1.0.0, 0.17.1)
Script
require 'active_record'
conn = {
adapter: 'redshift',
database: '#database',
host: '#host',
port: 5439,
username: '#username',
password: '#password'
}
ActiveRecord::Base.establish_connection(conn)
sql = 'select count(*) from table'
ActiveRecord::Base.connection.execute(sql)
You're using the pg gem version 1.0.0 and it is not compatible with the version of active_record and activerecord4-redshift-adapter that you're using:
The PGconn, PGresult, and PGError constants are deprecated, and will be removed as of version 1.0.
This can be seen in the history of the pg gem.
The activerecord4-redshift-adapter uses both the PGconn and PGError constants:
def connection_active?
#connection.status == PGconn::CONNECTION_OK
rescue PGError
false
end
Although I was unable to exactly duplicate the error message that you saw, by modifying the Gemfile to use an older version of the pg gem I was able to get farther along:
gem 'pg', '~> 0.21'
My exact steps were:
create the Gemfile
create a file test.rb containing your Ruby code
run bundle install
run bundle exec ruby test.rb
This produces the following error:
/Users/test/.rvm/gems/ruby-2.4.3/gems/activerecord4-redshift-adapter-0.2.1/lib/active_record/connection_adapters/redshift_adapter.rb:568:in `initialize': could not translate host name "#host" to address: nodename nor servname provided, or not known (PG::ConnectionBad)
This is almost certainly in the right direction for the problem you're having, and should put you on the path to accomplishing your goal.
My main purpose is execute this ruby code in windows. For this purpose I installed curb gem to Windows 10 by using this method. Although installation is compeleted without any error, I am taking these messages:
C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': 126: The specified module could not be found.
C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/curb-0.9.3/curb_core.so (LoadError)
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/curb-0.9.3/lib/curl.rb:1:in `<top (required)>'
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 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/curb-0.9.3/lib/curb.rb:1:in `<top (required)>'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from ted-postrank.rb:7:in `<main>'
What is going wrong about it?
I recommend using 32bit version of ruby on windows 10 as 64bit has problems with some gems.
First download 32bit ruby installer from http://rubyinstaller.org and install it.
Then
download curl-7.27.0-devel-mingw32, extract it in C:/curl-7.27.0-devel-mingw32
copy both libcurl.dll and libidn-11.dll into the Ruby bin directory.
and install:
gem install curb --platform=ruby -- --with-curl-lib="C:/curl-7.27.0-devel-mingw32/bin" --with-curl-include="C:/curl-7.27.0-devel-mingw32/include"
I am using Ruby22-x64 just to let you know, but I successfully installed RedCloth-4.2.9 using gem install RedCloth within the command prompt. When I try to require 'rubygems' I get =>false which is normal because it's already loaded, but when I try require 'RedCloth this is the following error code I get:
irb(main):001:0> require 'RedCloth'
LoadError: cannot load such file -- 2.2/redcloth_scan
Couldn't load 2.2/redcloth_scan
The $LOAD_PATH was:
C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/RedCloth- 4.2.9
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/RedCloth-4.2.9/lib
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/RedCloth- 4.2.9/lib/case_sensitive_require
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/RedCloth-4.2.9/ext
C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0
C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/x64-msvcrt
C:/Ruby22-x64/lib/ruby/site_ruby
C:/Ruby22-x64/lib/ruby/vendor_ruby/2.2.0
C:/Ruby22-x64/lib/ruby/vendor_ruby/2.2.0/x64-msvcrt
C:/Ruby22-x64/lib/ruby/vendor_ruby
C:/Ruby22-x64/lib/ruby/2.2.0
C:/Ruby22-x64/lib/ruby/2.2.0/x64-mingw32
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 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/RedCloth- 4.2.9/lib/RedCloth.
rb:13:in `<top (required)>'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:12
8:in `require'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:12
8:in `rescue in require'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39
:in `require'
from (irb):1
from C:/Ruby22-x64/bin/irb:11:in `<main>'
irb(main):002:0>
I don't know if it is the versions of RedCloth that may be doing this? Or some sort of path error? I really am looking for some help here though! Please!
I had to change the path by creating a 2.2 folder to include redcloth_scan.so and I got it to work!
Thanks for the link #Casper
I cloned a GitHub directory because I wanted to help on an open-source project.
The link to the project is listed below, so feel free to try it out for yourself.
https://github.com/tupini07/RubyMan
According to the README, I did the following
git clone https://github.com/tupini07/RubyMan
cd projects/RubyMan
ruby main.rb
Edit
I solved the first issue by running gem install win32console, but I still run into the same problem.
Error Message
C:\Users\darkmouse\Documents\Projects\RubyMan>ruby main.rb
C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in
`require': cannot load such file -- 2.0/Console_ext (LoadError)
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/win32console-1.3.2-x86-mingw32/
lib/Win32/Console.rb:12:in `rescue in <top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/win32console-1.3.2-x86-mingw32/
lib/Win32/Console.rb:8:in `<top (required)>'
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/win32console-1.3.2-x86-mingw32/
lib/Win32/Console/ANSI.rb:13:in `<top (required)>'
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/win32console-1.3.2-x86-mingw32/
lib/win32console.rb:1:in `<top (required)>'
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from C:/Users/darkmouse/Documents/Projects/RubyMan/Board.rb:2:in `<top (required)>'
from main.rb:4:in `require_relative'
from main.rb:4:in `<main>'
Main.rb
3 require_relative 'player'
4 require_relative 'Board'
5 require_relative 'LoadLevel'
Board.rb
2 require 'win32console'
The issues are listed above.
I run a Windows 8 Operating System.
I'd prefer not to bombard the repository with issues, so I decided to ask here.
I forked this same GitHub project, RubyMan, and cloned it on Ubuntu 14.04 LTS. I installed the current stable release of Ruby 2.2.2. I ran into almost the same problem as above when I changed to the RubyMan folder and ran:
ruby Main.rb
Here is the stack trace:
/usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- colorize (LoadError)
from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/ashok/RubyMan/Board.rb:1:in `<top (required)>'
from Main.rb:3:in `require_relative'
from Main.rb:3:in `block in <main>'
from Main.rb:3:in `each'
from Main.rb:3:in `<main>'
Others who ran into a similar problem suggested on GitHub to:
sudo gem install colorize
Result:
Successfully installed colorize-0.7.7
Unfortunately, the above problem didn't go away :( I tried many other suggestions. No luck.
However, these two steps resolved the problem:
Step 1:
sudo gem update --system
Result:
RubyGems system software updated
I understand that this updates all installed gems to their latest versions.
Step 2:
sudo gem install colorize
Result:
Successfully installed colorize-0.7.7
Now I am able to launch the RubyMan program by running:
ruby Main.rb
Result:
What size will the board be?
And when I enter a number, it displays the 2D RubyMan game ready to play!
I scheduled this cronjob:
ruby twitter_bots/tweet_bots.rb
tweet_bots.rb:
#!/usr/bin/ruby
require 'rubygems'
require '/home/david/twitter_bots/twitterbot.rb'
mcnulty = TwitterBot.new('jamesmcnulty')
mcnulty.tweet
mcnulty.reply
mcnulty.close
twitterbot.rb:
require 'dbi'
require 'twitter'
class TwitterBot
...
The cron has these environmental variables:
SHELL=/bin/sh
PATH=/home/david/.rvm/gems/ruby-1.9.2-p290/bin:/home/david/.rvm/gems/ruby-1.9.2-p290#global/bin:/home/david/.rvm/rubies/ruby-1.9.2-p290/bin:/home/david/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
HOME=/home/david
LOGNAME=david
But it throws this error:
/home/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- deprecated (LoadError)
from /home/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/dbi.rb:48:in `<top (required)>'
from /home/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/david/twitter_bots/twitterbot.rb:1:in `<top (required)>'
from /home/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from twitter_bots/tweet_bots.rb:5:in `<main>'
I can see that the error comes from /home/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/dbi.rb:48 where it has require "deprecated"
But I have the deprecated gem v 2.0.1 installed. I also tried it with version 3.0.0.
When I run it manually, it works. What's wrong with the cron?
I am guessing you need the deprecated Gem.
try:
[sudo] gem install deprecated