How to fix (RubyInstaller::Runtime::DllDirectory::WinApiError) in ruby on windows? - ruby

while Implementing ruby2d in the code i get this error
It's a strange runtime issue
Ruby2d Code
require 'ruby2d'
# Set the window size
set width: 300, height: 200
# Create a new shape
s = Square.new
# Give it some color
s.color = 'red'
# Show the window
show
Error
8: from R.rb:1:in `<main>'
7: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
6: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
5: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/ruby2d-0.5.1/lib/ruby2d.rb:28:in `<top (required)>'
3: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/singleton.rb:12:in `add_dll_directory'
2: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/singleton.rb:12:in `new'
1: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/dll_directory.rb:50:in `initialize'
*C:/Ruby25-
x64/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/dll_directory.rb:83:in
`add_dll_directory_winapi': AddDllDirectory failed for
C:/Users/Salim/usr/local/bin
(RubyInstaller::Runtime::DllDirectory::WinApiError)*
Please Help me to fix

You have to run your project from the MINGW 64-bit command prompt. Not from the regular DOS prompt (Windows Command Prompt).
Make sure you follow the instructions here:
http://www.ruby2d.com/learn/windows/
Note the last paragraph:
Using Ruby 2D on Windows
When working with Ruby 2D, make sure to use a MinGW 64-bit command prompt, rather than a standard one (cmd.exe) or the “Start Command Prompt with Ruby” found in the Start menu.

Fixed this issue by creating usr/local/bin folders in the C/users/username directory
and pasted the dlls required which can ne found on Link for dll
extract it and copy the dll from bin and paste in the new bin directory that you have created .
Imp- usr/local/bin was my default dll-load directory i hope its the same for others too but please check the error message properly.

Related

Vagrant failed on all commands with a same error "code converter not found"

I installed vagrant 1.3.4 on my Windows 7 laptop then tried to type vagrant init from command line. It failed with below error. I tried other commands (even vagrant --help) but still receive a same error. I tried googling for a while to no avail. Is there anyone who can shed light on why this error happens? Any input is appreciated. Thanks
C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:268:in `[]': code converter not found (
UTF-16LE to Windows-1258) (Encoding::ConverterNotFoundError)
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:268:in `block in _all'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:267:in `each'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:267:in `_all'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:410:in `each'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:216:in `find_all'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:216:in `matching_specs'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:238:in `to_specs'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
from C:/HashiCorp/Vagrant/bin//../embedded/../embedded/gems/bin/vagrant:22:in `<main>'
After searching for a while, this seems to be an issue with Ruby and I found the answer from this here:
Error installing Rubygems on ruby command prompt in Win7
I did the same, changing my locale from Vietnam to US and issue resolved.
You can add chcp 65001 > nul at the top of vagrant.bat after #ECHO OFF

Trying to start up IE on watir-webdriver on windows xp, getting "Errno::EPERM: Operation not permitted - bind(2)", stacktrace points to 'port_prober'

So I'm on Windows XP, and I'm trying to get the watir-webdriver to run Internet Explorer 8. I've already added IEDriverServer.exe to the /bin for cygwin. I also disabled the windows firewall and anti-virus software temporarily, and am still getting this error message.
w = Watir::Browser.new :ie
#=>
Errno::EPERM: Operation not permitted - bind(2)
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/common/port_prober.rb:28:in `initialize' from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/common/port_prober.rb:28:in `new'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/common/port_prober.rb:28:in `block in free?' rom /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/common/port_prober.rb:26:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/common/port_prober.rb:26:in `free?'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/common/port_prober.rb:5:in `above'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/ie/bridge.rb:18:in `block in initialize'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/ie/bridge.rb:18:in `delete'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/ie/bridge.rb:18:in `initialize'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/common/driver.rb:35:in `new'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/common/driver.rb:35:in `for'
from /usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver.rb:67:in `for'
from /usr/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.2/lib/watir-webdriver/browser.rb:46:in `initialize'
from (irb):3:in `new'
Note the first time I ran this program, though it crashed immediately with the same error message, I got a dialog box from windows asking me if I wanted to block some action. I told it to "unblock" the action.
It seems your IE profile has some issue, better you remove IE and re-install it and then try to invoke the browser with you code, It should work.
Or try to update the IE that can also repair your browser.

Migrating Tumblr to octopress (Jekyll) - in wrong directory

I'm trying to migrate a blog from Tumblr to Octopress.
When I run in the octopress directory
ruby -rubygems -e 'require "jekyll/migrators/tumblr"; Jekyll::Tumblr.process("http://example.org", format="md")'
It starts running but then complains about what folder it's in
/usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/convertible.rb:27:in `read': No such file or directory - /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/migrators/../_posts/tumblr/2012-08-28-how-to-add-your-picture-to-google-results.md (Errno::ENOENT)
from /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/convertible.rb:27:in `read_yaml'
from /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/post.rb:39:in `initialize'
from /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/migrators/tumblr.rb:124:in `new'
from /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/migrators/tumblr.rb:124:in `block in rewrite_urls_and_redirects'
from /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/migrators/tumblr.rb:119:in `map'
from /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/migrators/tumblr.rb:119:in `rewrite_urls_and_redirects'
from /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/migrators/tumblr.rb:30:in `process'
from -e:1:in `<main>'
Here's a quick and dirty fix that worked for me (doesn't apply if you don't have root access, obviously), but it will get the job done.
Here's your error message for reference:
/usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/convertible.rb:27:in `read': \
No such file or directory - \
/usr/lib/ruby/gems/1.9.1/gems/jekyll0.11.2/lib/jekyll/migrators/../_posts/tumblr/2012-08-28-how-to-add-your-picture-to-google-results.md (Errno::ENOENT)
The full path in the exception is:
/usr/lib/ruby/gems/1.9.1/gems/jekyll0.11.2/lib/jekyll/migrators/../_posts/tumblr/2012-08-28-how-to-add-your-picture-to-google-results.md
Here's the solution:
1. cd to /usr/lib/ruby/gems/1.9.1/gems/jekyll0.11.2/lib/jekyll/migrators/
2. cd ..
3. ln -s %{DIRECTORY_WHERE__posts_LIVES}
4. Re-run your migration command
Just creating this symlink fixes the issue but it's an obvious and total hack.
Does the file /usr/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/_posts/tumblr/2012-08-28-how-to-add-your-picture-to-google-results.md exist? If not maybe you could just move your posts to that folder first, just as a simply workaround.

Fix for unreadable ghostscript font

I'm using the ruby Scruffy gem to create some graphs. It relies on RMagick to render the text and create the pngs. When I run my ruby script I get this error.
sh: gs: command not found
sh: gs: command not found
/Users/natebird/.rvm/gems/ree-1.8.7-2011.03/gems/scruffy-0.2.6/lib/scruffy/rasterizers/rmagick_rasterizer.rb:15:in `from_blob': unable to read font `/usr/local/share/ghostscript/fonts/n019003l.pfb' # error/annotate.c/RenderFreetype/1128: `(null)' (Magick::ImageMagickError)
from /Users/natebird/.rvm/gems/ree-1.8.7-2011.03/gems/scruffy-0.2.6/lib/scruffy/rasterizers/rmagick_rasterizer.rb:15:in `rasterize'
from /Users/natebird/.rvm/gems/ree-1.8.7-2011.03/gems/scruffy-0.2.6/lib/scruffy/graph.rb:164:in `render'
from autobench_grapher.rb:61:in `generate_graph'
from autobench_grapher.rb:30:in `run'
from autobench_grapher.rb:15:in `run'
from autobench_grapher.rb:91
You need to install ghostscript (see: gs: command not found). How you do this depends on what platform you are on.

Ruby Rspec outputs literal escape characters on windows

I'm following the ruby on rails tutorial: http://railstutorial.org/chapters/static-pages#top
I'm up to using rspec. Having installed the win32console gem, it outputs gibberish in the console, i assume it is outputting the ansi colour change codes:
>rspec spec/
?[31mF?[0m?[31mF?[0m
Finished in 0.34376 seconds
?[31m2 examples, 2 failures?[0m
1) PagesController GET 'home' should be successful
Failure/Error: Unable to find C to read failed line
?[31mundefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x22294e0>?[0m
?[90m # ./spec/controllers/pages_controller_spec.rb:7:in `block (3 levels) in <top (required)>'?[0m
2) PagesController GET 'contact' should be successful
Failure/Error: Unable to find C to read failed line
?[31mundefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x2173d28>?[0m
?[90m # ./spec/controllers/pages_controller_spec.rb:14:in `block (3 levels) in <top (required)>'?[0m
Any tips how to fix this?
Ansicon works a treat!
http://adoxa.110mb.com/ansicon/index.html
Download, extract it somewhere, and do:
ansicon -i
Then close/reopen the command prompt. Sweet!
There was a bug in beta releases of RSpec 2. If you upgrade to latest you should now see colors if you have win32console installed.
See this: http://github.com/rspec/rspec-core/issuesearch?state=closed&q=color#issue/143
UPDATE: Keep an eye on this thread:
http://groups.google.com/group/rubyinstaller/browse_thread/thread/2d2a62db7281509a/?pli=1
Update:
Rspec is still very buggy with windows coloring, especially if you're trying to use it with Autotest and/or Spork.
If you are still seeing escape codes, a quick hack is to edit the following file (exact path will depend on your version of RSpec)
%RUBY_HOME%\lib\ruby\gems\1.9.1\gems\rspec-core-2.0.1\bin\rspec
And add the following line
require 'win32console'

Resources