I am trying to use FakeFS but keep getting an uninitialized constant error when I require 'fakefs':
C:/Ruby192/lib/ruby/gems/1.9.1/gems/fakefs-0.3.1/lib/fakefs/file.rb:26:in `<class:File>': uninitialized constant File::NOCTTY (NameError)
I was originally working in RubyMine, but to isolate the problem I wrote a simple hello world script and ran it from the command line, and still get the same error. Here is that script:
require 'rubygems'
gem 'fakefs'
require 'fakefs'
puts "Hello Cleveland!"
And here is the error and accompanying stacktrace:
>ruby foo.rb
C:/Ruby192/lib/ruby/gems/1.9.1/gems/fakefs-0.3.1/lib/fakefs/file.rb:26:in `<class:File>': uninitialized constant File::NOCTTY (NameError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/fakefs-0.3.1/lib/fakefs/file.rb:4:in `<module:FakeFS>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/fakefs-0.3.1/lib/fakefs/file.rb:3:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/fakefs-0.3.1/lib/fakefs/safe.rb:9:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/fakefs-0.3.1/lib/fakefs.rb:1:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from foo.rb:3:in `<main>'
I installed the fakefs gem via RubyMine. I'm working on Windows with Ruby 1.9. Any ideas?
It's because Windows doesn't have NOCTTY and SYNC flags. You can add this method to the base.rb file:
def RealFile.const_missing const
const_set const, 42
end
Really, I don't know it cause any problems or not in the future but you'll be able to run your script at least. And I think you should write about this at github
There is a fork with some windows fixes (this guy commented all flags at all): https://github.com/vertiginous/fakefs
Related
I'm new to Ruby coding. I'm just learning gem/bundle and require. At first, I think the gem should be like jar in Java and pip in Python. So I searched a very simple package named "haha" on rubygems.org -- https://rubygems.org/search?query=haha -- to have a test. But soon I found there always be error and I don't know why. Here's the details --
gem install "haha" -- it runs fine and I found it in the lib folder --
C:\Ruby31-x64\lib\ruby\gems\3.1.0\gems>dir |findstr haha
2022-04-25 17:34 <DIR> haha-1.1.0
2022-04-25 17:34 <DIR> haha-1.2.0
So I think this gem "haha" has been installed successfully.
Then in irb, I tried "require" to include it, then it failes --
irb(main):002:0> require "haha"
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/haha-1.2.0/lib/haha/translator.rb:1:in `<top (required)>': uninitialized constant Haha (NameError)
class Haha::Translator
^^^^
Did you mean? Hash
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/haha-1.2.0/lib/haha.rb:1:in `<top (required)>'
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
from (irb):2:in `<main>'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
from C:/Ruby31-x64/bin/irb:33:in `load'
from C:/Ruby31-x64/bin/irb:33:in `<main>'
<internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- haha (LoadError)
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from (irb):2:in `<main>'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
from C:/Ruby31-x64/bin/irb:33:in `load'
from C:/Ruby31-x64/bin/irb:33:in `<main>'
I checked the $LOAD_PATH and it looks correct --
irb(main):003:0> pp $LOAD_PATH
["C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/haha-1.2.0/lib",
"C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0",
"C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/x64-ucrt",
"C:/Ruby31-x64/lib/ruby/site_ruby",
"C:/Ruby31-x64/lib/ruby/vendor_ruby/3.1.0",
"C:/Ruby31-x64/lib/ruby/vendor_ruby/3.1.0/x64-ucrt",
"C:/Ruby31-x64/lib/ruby/vendor_ruby",
"C:/Ruby31-x64/lib/ruby/3.1.0",
"C:/Ruby31-x64/lib/ruby/3.1.0/x64-mingw-ucrt"]
I think being a package on rubygems this "haha" should be a correct one and it must be my fault somewhere so that I can't "require" it in irb. But I really don't know what's my mistake.
Please kind help.
I'am trying to use vagrant to start a Hours dev environment
I have gotten everything to be setup whitout errors.
The thing is that when i try to access the server through POW i get this error.
LoadError: cannot load such file -- bundler/setup
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
~/Desktop/1dv032/ex1/hours/Hours/config/boot.rb:4:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
I can't figure out why.
Ruby -v gives
2.3.1
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 am new to Sinatra and I am trying to make a database using SQLite3 and Datamapper. I installed both gems and also the adaptor and then tried to execute this code in a file:
#config
require 'sinatra'
require 'sinatra/contrib' if development?
require 'data_mapper'
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/recall.db")
DataMapper.finalize.auto_upgrade!
The command line gave me this error when I executed the file:
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/do_sqlite3-0.10.10-x86-mingw32/lib/do_sqlite3/1.9/do_sqlite3.so (LoadError)
and then a lot of other things which went wrong because of these errors.
I tried reinstalling many of the gems but nothing seems to have worked.
EDIT: The full error code was this:
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/do_sqlite3-0.10.10-x86-mingw32/lib/do_sqlite3/1.9/do_sqlite3.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/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_backports'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.10-x86-mingw32/lib/do_sqlite3.rb:31:in `rescue in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.10-x86-mingw32/lib/do_sqlite3.rb:26: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/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_backports'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-sqlite-adapter-1.2.0/lib/dm-sqlite-adapter/adapter.rb:1: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/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_backports'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-sqlite-adapter-1.2.0/lib/dm-sqlite-adapter.rb:1: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 C:/Ruby193/lib/ruby/gems/1.9.1/gems/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_backports'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:163:in `load_adapter'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:133:in `adapter_class'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:13:in `new'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core.rb:230:in `setup'
from test.rb:7:in `<main>'
I had this problem, using ruby 1.9.3 on windows - fixed it by downloading the sqlite3.dll from http://www.sqlite.org/download.html and putting it in C:\Ruby193\bin
Try adding:
require 'dm-sqlite-adapter'
If that doesn't fix things, you could also try changing
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/recall.db")
to
DataMapper.setup(:default, 'sqlite:recall.db')
and see if that fixes it. I really don't know the cause, but doing the above (single quotes, no "3", and no path) fixed an error I was receiving when trying a particular setup.
I am trying to run the wsdl2ruby.rb script that comes with the soap4r gem, and get the following errors:
[ral#lap etc]$ ruby /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/bin/wsdl2ruby.rb
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/charset.rb:13: warning: variable $KCODE is no longer effective
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/property.rb:68: warning: encoding option is ignored - u
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/property.rb:69: warning: encoding option is ignored - u
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/property.rb:70: warning: encoding option is ignored - u
/usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/xmlparser.rb:74:in `<top (required)>': XML processor module not found. (RuntimeError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/parser.rb:13:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:11:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/importer.rb:9:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:11:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:33:in `require'
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/bin/wsdl2ruby.rb:5:in `<main>'
I have the following gems installed:
httpclient (2.2.0.1) minitest (1.6.0)
rake (0.8.7) rdoc (2.5.8) soap4r
(1.5.8)
I have tried to install the xml parser gem which fails with loads of errors: http://pastie.org/1822127
Does anyone know what the problem is? This is my first time touching Ruby.
Is soap4r the best tool for the job for making a SOAP webservice client?
Thanks a lot!
The answer posted at
http://railsforum.com/viewtopic.php?id=41231
worked for me. That is, I edited the file rubyhome/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/xmlparser.rb and changed line 66 from:
c.downcase == name
to
c.to_s.downcase == name
and the problem appears to be solved.
You might also try the new official repo on Github that has this fix, and others applied to the master branch. You'll need to set your Gemfile to use the git repo as such:
gem 'soap4r', :git => 'git://github.com/felipec/soap4r.git'