Unable to load win32/api.so from ruby script - ruby-on-rails

The command run the following :
C:\V4\framework\scripts > ruby SCM.rb
The error I get is the following :
C:/Rubby/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in require: 126: The specified module could not be found. - C:/Rubby/lib/ruby/gems/2.4.0/gems/win32-api-1.4.8-x86-mingw32/lib/win32/ruby19/win32/api.so (LoadError)
from C:/Rubby/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/Rubby/lib/ruby/gems/2.4.0/gems/win32-api-1.4.8-x86-mingw32/lib/win32/api.rb:2:in
The first few lines of the calling script looks like following :
require 'watir/win32ole'
require 'windows/com'
require 'windows/window/message'
The second line is giving the Load Error. I googled and am not able to find a solution.

I have faced the same issue , I got resolved this by download the zip file of api.dll from https://www.dll-files.com/api.dll.html and extract the zip file and then paste the 'api.dll' inside my ruby bin folder : "C:\Ruby22\bin

Related

Could not open library 'lib.dylib' on Mac

Have some issues with launching ruby tests on Mac(Monterey 12.2.1). I've launched bundle install - everything was finished successfully, after that I tried to do a command bundle exec rake db:test:refresh, and got the following error
LoadError: Couldn't load the GEOS CAPI library.
/Users/alexandra_shimanovich/.bundle/ruby/2.5.0/gems/ffi-geos-0.3.0/lib/ffi-geos.rb:1000:in `rescue in <module:FFIGeos>'
/Users/alexandra_shimanovich/.bundle/ruby/2.5.0/gems/ffi-geos-0.3.0/lib/ffi-geos.rb:982:in `<module:FFIGeos>'
/Users/alexandra_shimanovich/.bundle/ruby/2.5.0/gems/ffi-geos-0.3.0/lib/ffi-geos.rb:51:in `<module:Geos>'
/Users/alexandra_shimanovich/.bundle/ruby/2.5.0/gems/ffi-geos-0.3.0/lib/ffi-geos.rb:7:in `<top (required)>'
/Users/alexandra_shimanovich/Documents/Curb/ride_manager/config/application.rb:9:in `<top (required)>'
/Users/alexandra_shimanovich/Documents/Curb/ride_manager/Rakefile:4:in `require'
/Users/alexandra_shimanovich/Documents/Curb/ride_manager/Rakefile:4:in `<top (required)>'
/Users/alexandra_shimanovich/.rbenv/versions/2.5.5/bin/bundle:23:in `load'
/Users/alexandra_shimanovich/.rbenv/versions/2.5.5/bin/bundle:23:in `<main>'
LoadError: Could not open library '/usr/lib/': dlopen(/usr/lib/, 0x0005): tried: '/usr/lib/' (not a file), '/usr/local/lib/' (not a file).
Could not open library 'lib.dylib': dlopen(lib.dylib, 0x0005): tried: 'lib.dylib' (no such file), '/usr/local/lib/lib.dylib' (no such file), '/usr/lib/lib.dylib' (no such file), '/Users/alexandra_shimanovich/Documents/Curb/ride_manager/lib.dylib' (no such file), '/usr/local/lib/lib.dylib' (no such file), '/usr/lib/lib.dylib' (no such file)
I looked inside ffi-geos.rb
def self.search_paths
#search_paths ||= begin
if ENV['GEOS_LIBRARY_PATH']
[ ENV['GEOS_LIBRARY_PATH'] ]
elsif FFI::Platform::IS_WINDOWS
ENV['PATH'].split(File::PATH_SEPARATOR)
else
[ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}' ]
[ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/{x86_64,i386}-linux-gnu' ]
end
end
end
I know that in my computer lib files are not in /usr/local/.. but in /opt/homebrew/lib. But when I looked inside /opt/homebrew/lib I didn't find lib.dylib. There are only libgeos.3.10.2.dylib libgeos.dylib libgeos_c.1.16.0.dylib libgeos_c.1.dylib libgeos_c.dylib.
Please, help me find the right lib and somehow tell ffi-geos.rb to look in the right place, I would REALLY appreciate it! Thank you!
But when I looked inside /opt/homebrew/lib I didn't find lib.dylib
The code from ffi-geos.rb you posted is not looking for lib.dylib (or lib64.dylib), but it's adding /usr/local/lib, /usr/local/lib64, etc, to the search path to look for the specific GEOS dylibs. As your library files are in /opt/homebrew/lib, they won't be found by that automatic procedure.
The first conditional in the code shows you can set an environment variable to define the search path. So, set the library path with:
export GEOS_LIBRARY_PATH=/opt/homebrew/lib
Hope this works!

Why lua require won't search current directory?

say I've two files test.lua and m.lua in a folder, in test.lua as:
require("m")
then I run this file, howerver it raise an error:
lua: /Users/xx/works/scripts/test.lua:43: module 'm' not found:
no field package.preload['m']
no file '/usr/local/share/lua/5.3/m.lua'
no file '/usr/local/share/lua/5.3/m/init.lua'
no file '/usr/local/lib/lua/5.3/m.lua'
no file '/usr/local/lib/lua/5.3/m/init.lua'
no file './m.lua'
no file './m/init.lua'
no file '/usr/local/lib/lua/5.3/m.so'
no file '/usr/local/lib/lua/5.3/loadall.so'
no file './m.so'
As you can see the line no file './m.lua' appears but this is not true. ./m.lua exists, and file permission stuff is OK. If I hardcode the path:
package.path = package.path..';'..'/Users/xx/works/scripts/?.lua'
require('m')
It will work as expected.
What should I do to make lua search current directory fisrt (like python's import) when require a module
The current directory is the directory where you launch lua from.
The command line is missing in your example, if you used lua test.lua then it shoud work, if you used lua works/scripts/test.lua then it will not work.

How To Require Lua Socket?

I'm very new to lua development with file manipulation, and now trying to import the lua socket package into my project according to this post, but I can't run even the code below.
I guess the error message indicates I need to import not only the socket.lua but also .\socket\core (probably .dll, since it doesn't have core.lua), while a reply at the post suggested importing only the file.
I'm stuck in just the beginning... What do I have to do for the next step?
local function main()
local socket = require("socket")
end
main()
Exception in thread "main" com.naef.jnlua.LuaRuntimeException: ...n32.win32.x86_64\workspace\TestForCiv\src\socket.lua:13: module 'socket.core' not found:
no field package.preload['socket.core']
no file '.\socket\core.lua'
no file 'C:\Program Files\Java\jre1.8.0_151\bin\lua\socket\core.lua'
no file 'C:\Program Files\Java\jre1.8.0_151\bin\lua\socket\core\init.lua'
...(a bunch of no file errors continues)
Edit: I added the folder structure. Even I add the .dll file it returns the same error.
I don't know the details of you configuration, but try this
require ("src.socket")
you should require a module from the root path of the lib

Using tdbloader.bat to upload a RDF file and querying using tdbquery.bat

I want to upload an RDF file using tdbloader.bat (C:\apache-jena-2.10.0\bat, in my case).
My turtle file is located in C:\apache-jena-2.10.0, and is named test.ttl. What will be the command line to load the turtle file using tdbloader.bat? After it is loaded, what would be a command line to query with tdbquery.bat?
I have used the following command-
tdbloader.bat -loc c:\apache-jena-2.10.0 test.ttl
But it returned a FileNotFound Exception.
The file test.ttl isnt in the same directory as bat files which is causing FileNotFound exception. A correction would be to copy test.ttl to C:\apache-jena-2.10.0\bat. After doing that execute command
tdbloader.bat -loc potato test.ttl.
This would load test.ttl to a folder named potato in same directory as tdbloader.bat. Hope it helps

" require './example_user' " results in " LoadError: no such file to load -- ./example_user "

I'm following Hartl's tutorial.
The instructions say to "create the file example_user.rb in your application root directory". I'm assuming that's just under rails_projects/sample_app. I then start the console and type
require './example_user'
but get the error message
`LoadError: no such file to load -- ./example_user`.
Another answer said that you have to use the mv function to move the file to the actual root directory, but I was unable to make sense of that. Is the root directory not simply in sample_app?
Thanks for any help!

Resources