Ruby on Rails: running Typhoeus on Windows 7 (64 bit) - ruby-on-rails

I can't get Typhoeus gem to work on my Windows 7 machine.
Basically, it doesn't find "native.so" file in "C:/Ruby192/lib/ruby/gems/1.9.1/gems/typhoeus-0.2.4/ext/typhoeus/". How do I fix this?
C:/Ruby192/lib/ruby/gems/1.9.1/gems/typhoeus-0.2.4/lib/typhoeus.rb:10:in
`require': 126: The specified module
could not be found. -
C:/Ruby192/lib/ruby/gems/1.9.1/gems/typhoeus-0.2.4/ext/typhoeus/native.so
(LoadError) from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/typhoeus-0.2.4/lib/typhoeus.rb:10:in
`<top (required)>' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in
`require' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in
`block (2 levels) in require' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in
`each' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in
`block in require' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in
`each' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in
`require' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler.rb:120:in`require'

What worked for me (Win7 x64) was to download the .dll from the link called Download libcurl.dll (all versions) only, found here: http://www.paehl.com/open_source/?CURL_7.35.0.
After extracting I took the .dll file from the NoSSL/SSL directory (either seems to work, I used SSL just to be sure). I copied the file into Ruby's /bin directory and Typhoeus worked.
Note: You can't use the x64 version of the .dll because Ruby is 32-bit. Typhoeus didn't react to the x64 file.
Hopefully this will help someone.

The problem seems that typhoeus requires curl as development library to successfully compile it's native.so extension.
First you need to install RubyInstaller DevKit from downloads page.
Second you will need to get curl and development headers and libraries for MinGW, which you can find instructions on our mailing list:
http://groups.google.com/group/rubyinstaller/browse_thread/thread/c8a4bdb6663cbf7c
To the record, that same post mentions how unsuccessfully was the user attempt to get the gem to work on Windows and he ended switching to curb.
PS: while others might say that *.so is UNIX/POSIX convention for shared objects, is the extension Ruby decided to use for Windows C-Extensions, like Python uses *.pyd for their extensions.

if that gem is looking for native.so then it might not work with windows, *.so is the *NIX equivalent of *.dll for windows a "shared object " or " dynamically linked library" file. So it might really need native.dll, or be a gem built on platform dependent code. Look at their documentation, this is just a shot in the dark.
then again, it says something happened in native.so ( LoadError) so maybe its begin executed, idk

Related

How can I fix a missing libcurl library for Rails on Windows 10?

I downloaded and installed Ruby 2.5.7-1 (x64) on a Windows 10 system from the following site:
https://rubyinstaller.org/downloads/
I then installed Rails and Bundler as follows:
gem install rails -v 5.2.3
gem install bundler
I then ran bundle install. This all worked fine.
However, after all that, when I try to run rails db:migrate or rails server, I get the following message:
rails aborted!
LoadError: Could not open library 'libcurl': The specified module could not be found.
.
Could not open library 'libcurl.dll': The specified module could not be found.
.
Could not open library 'libcurl.so.4': The specified module could not be found.
.
Could not open library 'libcurl.so.4.dll': The specified module could not be found.
C:/path-to-app/config/application.rb:18:in `<top (required)>'
C:/path-to-app/Rakefile:4:in `require'
C:/path-to-app/Rakefile:4:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
When I Google this error, everything seems to point to the following SO post and top answer:
How to solve 'libcurl' not found with Rails on Windows
I downloaded several versions of libcurl.dll, placed them in the C:\Ruby25-x64\bin directory, restarted the DB server, restarted my IDE with terminal, and tried again, but I still keep getting the same error.
I've also confirmed that C:\Ruby25-x64\bin is part of my user Path variable, but I'm still getting this issue.
Does anyone have any ideas on how I can resolve this, since the SO post linked above either doesn't work (or I'm not doing something that's obvious)? Thanks.

Errors when using pre-compiled gems with native extensions on Plesk-managed machines without development options

I am aiming to have a production machine running a Ruby on Rails app. However, this production machine is managed with Plesk and allows only very rudimentary access, but was promised to be able to run Ruby on Rails apps.
Indeed it is in principle able to run Ruby on rails for an overly simple example, but running any app requiring gems with native extensions (as e.g. nokogiri, which is required already by the rails default app, generated by rails new) already fails.
Part of the log looks like this:
libruby.so.2.4: cannot open shared object file: No such file or directory - /var/www/vhosts/hosting116285.a2f45.netcup.net/test.gcsb.info/vendor/bundle/ruby/2.4.0/gems/msgpack-1.2.6-x86_64-linux/lib/msgpack/msgpack.so (LoadError)
/var/www/vhosts/hosting116285.a2f45.netcup.net/test.gcsb.info/vendor/bundle/ruby/2.4.0/gems/msgpack-1.2.6-x86_64-linux/lib/msgpack.rb:11:in `require'
...
...
...
/var/www/vhosts/hosting116285.a2f45.netcup.net/test.gcsb.info/vendor/bundle/ruby/2.4.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
I have the options to "restart the app", "install packages" (which executes a bundle install --path vendor/bundle according to documentation), and "add environment variables".
I have very limited SSH access to the machine, but no access to any compilers or libraries.
The support advised me to "precompile my gems", but did not give any specific advice how to do this. I set up a virtual development machine which is somewhat near to the production machine, but definitely not yet the same in terms of all paths and e.g. Linux kernel version. I compile with gem-compiler (https://github.com/luislavena/gem-compiler) which supposedly works fine, but the precompiled gems in bundle/cache, and install them via the Plesk interface.
However, the app keeps throwing errors. The pre-compiled gems (msgpack is one of them; originally with native extensions) seem to be linked in a wrong fashion? I have honestly no idea anymore. I already tried packing my development machine's libruby.so.2.4 onto the production machine, which reduced the errors a little but did not help to solve it.
Do you have any suggestions of an advisable strategy to circumvent the given limitations? Am I doing it right, but it is simply not possible to make it run in this environment?
Thanks in advance!
Robert

Rails Web application could not be started

Getting this error even when I create a new project. I installed Ruby and RoR through RVM
cannot load such file -- /var/lib/gems/2.3.0/gems/passenger-5.0.30/src/ruby_supportlib/phusion_passenger (LoadError)
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/var/lib/gems/2.3.0/gems/passenger-5.0.30/src/helper-scripts/rack-preloader.rb:74:in `init_passenger'
/var/lib/gems/2.3.0/gems/passenger-5.0.30/src/helper-scripts/rack-preloader.rb:155:in `<module:App>'
/var/lib/gems/2.3.0/gems/passenger-5.0.30/src/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/var/lib/gems/2.3.0/gems/passenger-5.0.30/src/helper-scripts/rack-preloader.rb:29:in `<main>'
I think I found that the problem is in the directory of the gems. I do not know how to change it on Ubuntu
I would first try to understand if you have a problem with the app or the environment.
Try to run the simplest app by:
rails new simple_app
if it doesn't work - the problem is the environment.
if it does work - probably you have some problem with the initializers or config files
Let us know how it works for you!
Have you try gem install passenger ?
or gem install bundler
Your error message:
cannot load such file -- /var/lib/gems/2.3.0/gems/passenger-5.0.30/src/ruby_supportlib/phusion_passenger (LoadError)
Suggests a permission problem with files in the gem /var/lib/gems/2.3.0/gems/passenger-5.0.30. Either, the files don't exist, or they aren't readable.
If you query the permissions for that file (make sure to append '.rb'):
ls -l /var/lib/gems/2.3.0/gems/passenger-5.0.30/src/ruby_supportlib/phusion_passenger.rb
You'll probably find it's not world readable, or at least not readable by the web server process' user. If it doesn't exist, then you should reinstall.
I saw this error on a system that had a umask of 0066, which caused passenger's gem files to be root:root with mode -rw-------.

Setting up Curb in windows

I'm trying to use feedzirra with Rails 3 On Windows 7, but have been having real issues getting Curl and Curb installed. I found this question Install Ruby Curb gem in windows XP which enabled me to get the gem installed successfully, but now when I try and start my rails server I get the following error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/curb-0.8.1/lib/curb.rb:1:in `require': 193: %1 is not a valid Win32 application. - C:/Ruby193/lib/ruby/gems/1.9.1/gems/curb-0.8.1/lib/curb_core.so (LoadError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/curb-0.8.1/lib/curb.rb:1:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/feedzirra-0.0.24/lib/feedzirra.rb:4:in `require'
...
the file curb_core.so does exist, but windows doesn't know how to open it and says it's not a valid Win32 application. Any ideas how I can get this to work? Or does anyone know of any other good RSS readers for rails, that don't use Curb?
Thanks
Ben,
Not sure if you're still looking to use Feedzirra, but to get it to work on my machine (Windows 7), I had to copy both libcurl.dll and libidn-11.dll into the Ruby bin directory. After that it worked with no problem.
Try copying libcurl.dll form your curl installation to ruby /bin directory. Solved the problem for me.

Ruby on Rails Win7 x64?

I've just upgraded to Win7 x64 Professional and wanted to recommence developing my Rails Apps, however I'm getting the following error :
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://127.0.0.1:3344
D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:271:in `require_frameworks': 193: %1 is not a valid Win32 application. - D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/1.8/i386-mswin32/openssl.so (RuntimeError)
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:134:in `process'
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
from D:/nu codes/R/Aptana/tempproj/config/environment.rb:9
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from D:/nu codes/R/ruby-1.8.7-p174-i386-mswin32/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from D:/nu codes/R/Aptana/tempproj/script/server:3
from -e:1:in `load'
from -e:1
Process finished with exit code 1
while trying to run the server. I've alleviated all the errors regarding OpenSSL and Iconv by copying the required .dll s into my ruby\bin directory. I'm stumped about this one, could it be that I'm running x64 now ? I have no idea, at least the other stack traces named the .dll which was causing it.
Gem listing :
*** LOCAL GEMS ***
actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
authlogic (2.1.3)
cgi_multipart_eof_fix (2.5.0)
gem_plugin (0.2.3)
mongrel (1.1.5)
mysql (2.8.1)
rack (1.0.1)
rails (2.3.5)
rake (0.8.7)
I'm also running MySQL v5.1.41-community. I will try installing MySQL 5.0.
Update : I must say that I never do use OpenSSL in the Project, so I must say I am quite baffled that it is required in the first place. Trying to see if it was a Rails error, I've created a dummy app (rails bla) and rails wouldn't even create the default skeleton since some random error ( "raise NotImplementedError, "No random device" ) popped up at "activesupport/lib/active_support/secure_random.rb" . I've googled that and replaced it with another version from github. That created the skeleton, but trying to run the server I get the same error, even if it's the Rails default dummy app. I will try to hack into that file again, again no idea what OpenSSL is doing here in the first place and requiring DLLs.
At a loss, any help would be appreciated.
Thanks in advance !
It was a DLL problem after all, went 1.8.6, x32 MySQL and OpenSSL, unpacked every dll mentioned in this excellent blog post and it's all running smoothly again, gosh ! And yes, I've answered my own question after all :-) Thank you !
This helped me from https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#wiki-fraps_violation
After investigation, having tools that alter loading DLLs (like FRAPS or Detours) can affect loading Ruby’s extensions.
It is recommended you disable/uninstall FRAPS.
That fixed it for me.
For Rails or DataMapper or whatever to talk to MySQL you need a 32-bit driver in Rails\bin. The driver is called libmysql.dll. Even if you have a 64-bit server you need a 32-bit driver.
64-bit driver will fail will ruby/gems/1.8/gems/do_mysql-0.10.2-x86-mingw32/lib/do_mysql/1.8/do_mysql.so: 193: %1 is not a valid Win32 application.
a wrong 32-bit version will crash with memory allocation error or something weird like that
LoadError: 193: %1 is not a valid Win32 application.
I got this msg when I tried to load mysql ruby gem in irb.
The problem: The libmysql.dll MUST be the same version of mysql found in history.txt of
the ruby mysql gem
The fix: (1) Go the the readme.txt and history.txt for the mysql gem and verify the mysql
version.
(2) Install the corresponding mysql version.
(3) Copy the libmysql.dll file from the mysql bin dir to the ruby bin dir.
(4) Return to ruby irb and enter "require 'rubygems'" then "require 'mysql'"
(5) Say "yeaaah" when you see "true"!
Note: You may not really need to install the needed mysql version to get the proper
libmysql.dll file. I just found it easier to just install it. If you are like me, this problem was so vexing I thought of giving up on writing the program. So, I hope this solution restores your confidence.
See if this helps: http://www.technipages.com/error-193-1-is-not-a-valid-win32-application.html
From what is mentioned in this article, do you have a folder called "nu" in your D:/ drive? If yes, try renaming it and check if the server runs fine.

Resources