Ruby on Rails Win7 x64? - ruby-on-rails

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.

Related

How to fix "can't find executable rails for gem railties. railties is not currently included in the bundle"?

My application server is not starting and giving the error when I am trying to start the server by:
bundle exec rails server -b 0.0.0.0
Traceback (most recent call last):
4: from /root/workspace/abl-rest-client_ruby/local/ruby/2.6.0/bin/ruby_executable_hooks:24:in `<main>'
3: from /root/workspace/abl-rest-client_ruby/local/ruby/2.6.0/bin/ruby_executable_hooks:24:in `eval'
2: from /usr/local/rvm/gems/ruby-2.6.3/bin/rails:23:in `<main>'
1: from /usr/local/rvm/gems/ruby-2.6.3/gems/bundler-2.0.2/lib/bundler/rubygems_integration.rb:480:in `block in replace_bin_path'
/usr/local/rvm/gems/ruby-2.6.3/gems/bundler-2.0.2/lib/bundler/rubygems_integration.rb:460:in
`block in replace_bin_path': can't find executable rails for gem railties. railties is not
currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
I just started working on rails yesterday, so I am too new to the entire concept.
I understand the error that I am missing the railties gem but I am unable to add it.
I have tried uninstalling gems, removing gems, re-installing those, etc. as per the answers to this question 'https://stackoverflow.com/questions/9212116/rails-could-not-find-railties'
but nothing helped.
My gem list has the railties version 6.1.0 but my vendor/cache doesn't have it. I am using windows for the development and I am inside a docker container.
I don't know if not having the railties in my vendor/cache is the problem or I am missing something else.
I have already tried a couple of solutions like specifying my ruby version to rvm
rvm use -myrubyversion, re-starting bundler a couple of times, etc.
Any suggestions?
Make sure your terminal is in the root of the application and not the folder above it. That is, after you run rails new application_name_here enter cd application_name_here to get to the right folder.

MultiJson AdapterError Rails 4 Ruby 2 Passenger

I am trying to setup rails on aws (Dev env work fine). Can not get production to start up correctly. Can shell in and db looks good. I looked into my log file and I am getting the following error.
rake aborted!
MultiJson::AdapterError: Did not recognize your adapter specification (cannot load such file -- json/ext/parser).
Have MultiJson and Json gems installed and in the gemlock file.
This happens during asset compilation.
I'm not 100% sure what the problem was but I read somewhere that downgrading the multi_json gem to version 1.7.8 would fix this and it did for me. Please note that this is just what fixed my app, it might not be the same for you but hopefully it is! I did the following:
Add the following to your Gemfile:
gem 'multi_json', '1.7.8'
And then update the gem:
bundle update multi_json
Commit the new changes:
git add .
git commit -m "Downgrade multi_json gem"
And push to AWS:
git aws.push
That should resolve the issues.
If you get a complaint from bundler about mis-matched dependencies you can re-install your gems and hopefully fix the dependency issues by removing the Gemfile.lock.
To delete the Gemfile.lock run:
rm Gemfile.lock
And then run bundle install:
bundle install
Commit again and push to aws.
After dealing with a situation where I couldn't revert the version, I found another solution to the problem.
We are just missing the appropriate dependent gem. This worked for me to fix it without downgrading:
gem install json
Hopefully that also helps other people with this problem. I got here from Google, so hopefully other people will as well.
I'm having a similar problem today. Here's a bit of my log:
Started POST "/users/sign_in" for 173.228.60.113 at 2015-09-29 15:53:47 +0000
MultiJson::AdapterError (Did not recognize your adapter specification (cannot load such file -- json/ext/parser).):
activesupport (3.2.3) lib/active_support/dependencies.rb:251:in `require'
activesupport (3.2.3) lib/active_support/dependencies.rb:251:in `block in require'
activesupport (3.2.3) lib/active_support/dependencies.rb:236:in `load_dependency'
activesupport (3.2.3) lib/active_support/dependencies.rb:251:in `require'
json (1.8.3) lib/json/ext.rb:13:in `'
json (1.8.3) lib/json/ext.rb:12:in `'
json (1.8.3) lib/json/ext.rb:9:in `'
bundle show (on the ec2 instance) shows where the json gem is installed:
[ec2-user#ip-172-31-43-145 current]$ bundle show json
/usr/local/share/gems1.9/gems/json-1.8.3
Below that directory there is a file ext/json/ext/parser/parser.so
This is a native extension. I've run into issues with these not installing correctly many times before. My workaround is to install a symlink in lib/json/ext
The command looks like this:
ln -s ../../../ext/json/ext/parser/parser.so .
from the above directory.
I also put in a symlink for generator.so. The command, executed while connected to lib/json/ext was:
ln -s ../../../ext/json/ext/generator/generator.so .
There's another directory under ext/json called fbuffer, but it only has a .h file, no .so.
This resolved the issue. I knew where to look because the error message always tells you a path relative to the core gem .rb file, which in this case was ext/json/json.rb
I am not at all happy about having to do this by hand each time a gem with a native extension updates. I would very much like it if someone could tell me how to not have to do that. But in the meantime, this will fix it.

Trying to install rails- EISDIR error

I'm new to programming and am trying to set up Ruby on Rails using Michael Hartl's tutorial via Terminal on a Mac running Snow Leopard, but I'm a bit stuck on this part. I've tried using rvm 1.9.2, without any luck, and haven't been able to find anything googling. Any help would be appreciated!
Thanks!
CZom$ gem install rails -v 3.2.3
/Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:253:in `read': Is a directory - /Users/CZom/.gemrc (Errno::EISDIR)
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:253:in `load_file'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:191:in `initialize'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:78:in `new'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:78:in `do_configuration'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:51:in `run'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/bin/gem:25:in `<main>'
/Users/CZom/.gemrc should be a user specific config file that gets loaded when executing the gem command. Sounds like in your case it is a directory instead. Rubygems is complaining therefore.
Try to rename /Users/CZom/.gemrc or remove it completely if it isn't needed.

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

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

Installing SQLite3 for Ruby on Windows - what's the current easiest route?

Am brand new to Ruby looking to get Redmine to run on WinServer08 sp1
I've read a few threads here detailing the steps and workarounds required to get Ruby and SQLite to play nice with each other.
Ruby will run...sqlite3's .dll and api are in the specified directories...i've rebooted but rake -test fails.
I'd like to find out if there's a definitive step-by-step that rolls up previous workarounds of the various packages involved. - thx much!
C:\Ruby>rake -test --trace
rake aborted!
undefined local variable or method `st' for #<Rake::Application:0x4351638>
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2217:in `standard_rake_opt
ions'
C:/Ruby/lib/ruby/1.8/optparse.rb:1291:in `eval'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2217:in `standard_rake_opt
ions'
C:/Ruby/lib/ruby/1.8/optparse.rb:1291:in `call'
C:/Ruby/lib/ruby/1.8/optparse.rb:1291:in `parse_in_order'
C:/Ruby/lib/ruby/1.8/optparse.rb:1247:in `catch'
C:/Ruby/lib/ruby/1.8/optparse.rb:1247:in `parse_in_order'
C:/Ruby/lib/ruby/1.8/optparse.rb:1241:in `order!'
C:/Ruby/lib/ruby/1.8/optparse.rb:1332:in `permute!'
C:/Ruby/lib/ruby/1.8/optparse.rb:1353:in `parse!'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2313:in `handle_options'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2009:in `init'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exceptio
n_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2007:in `init'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1999:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exceptio
n_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
C:/Ruby/bin/rake:19:in `load'
C:/Ruby/bin/rake:19
The Windows version of Ruby on Rails does not ship with the Sqlite3 database, even though the database.yaml configuration file is preconfigured to use Sqlite.
This is a how to guide on how to install Sqlite3 on your Windows PC. This article assumes that you already have Ruby and Ruby on Rails installed on your PC.
First you will need to download two files from the Sqlite web site http://www.sqlite.org/download.html:
sqlite-3_5_9.zip (214.32 KiB)
A command-line program for accessing and modifing SQLite databases.
See the documentation for additional information.
sqlitedll-3_5_9.zip (213.17 KiB)
This is a DLL of the SQLite library without the TCL bindings.
The only external dependency is MSVCRT.DLL.
The first file is the Sqlite command line program used for modifing the Sqlite database. You may or may not use this.
The second file is the Windows DLL library file and Ruby uses this when Rails makes Sqlite database calls.
When both these ZIP files have been extracted you should have the following files:
sqlite3.exe
sqlite3.def
sqlite3.dll
Copy these file to the bin directory of your Ruby installation, if you followed the default Ruby installation it will be located here:
C:\ruby\bin
Now that you have the Sqlite3 files installed you need to tell Ruby how to use them. To do this you need to download the Ruby bindings for Sqlite3.
Fortunately this is easy to do, using Ruby gems. Simply at the command prompt type the following command:
gem install sqlite3-ruby
You will now need to tell Gems which version you need as you will be presented with the following output:
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i386-mswin32)
1. sqlite3-ruby 1.2.2 (mswin32)
2. sqlite3-ruby 1.2.2 (ruby)
3. sqlite3-ruby 1.2.1 (mswin32)
4. sqlite3-ruby 1.2.1 (ruby)
5. Skip this gem
6. Cancel installation
>_
Please select option 1, sqlite3-ruby 1.2.2 (mswin32). All being successful you will get some output like this:
Successfully installed sqlite3-ruby-1.2.2-mswin32
Installing ri documentation for sqlite3-ruby-1.2.2-mswin32...
Installing RDoc documentation for sqlite3-ruby-1.2.2-mswin32...
If you are using Rails 2+ you should be able to run the following rake tasks from your Rails application directory. For example say you created a Rails application located here: C:\MyApp you should be able to execute:
C:\MyApp>rake db:create
or
C:\MyApp>rake db:migrate
Good luck !
(This was taken verbatim from http://blog.emson.co.uk/2008/06/installing-sqlite3-on-windows-for-rails/)

Resources