spork-minitest error but tests pass - ruby-on-rails

I finally created a Windows environment for new Rails applications that I like. Everything was working until I decided to create a how-to for it. You can find the steps on this blog post.
I did a fresh install to make sure everything was on the up and up. After everything is said and done the tests run fine and I do get a growl popup but the autotest window shows the following error. What's going on?
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/spork-minitest-0.0.3/bin/testdrb:7:in `exit': can't convert DRb::DRbObject into Integer (TypeError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/spork-minitest-0.0.3/bin/testdrb:7:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bin/testdrb:19:in `load'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bin/testdrb:19:in `<main>'

Needed to install the gem spork-testunit

Related

Ruby-on-rails cannot connect to mysql2; Windows 10

I'm on Windows 10 and am a complete beginner programmer. I am using Ruby 2.4.2, Rails 5.1.4 and am following a Lynda course on how to run Rails 5 on Windows.
There's a part near the end where the tutor says to enter:
>rails db:schema:dump
to test whether you've established a connection to the MySQL by create a file inside the created project.
This is what I get when I enter the above command:
C:\Users\notmyactualuser\Documents\Sites\demo_project>rails db:schema:dump
rails aborted!
LoadError: cannot load such file -- mysql2/2.4/mysql2
C:/Users/notmyactualuser/Documents/Sites/demo_project/config/application.rb:7:in `<top (required)>'
C:/Users/notmyactualuser/Documents/Sites/demo_project/Rakefile:4:in `require_relative'
C:/Users/notmyactualuser/Documents/Sites/demo_project/Rakefile:4:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
The tutor doesn't address what to do with potential errors and I can't seem to find an answer. I want to build a login form using RoR and am trying to grasp the basics (clearly failing). If possible, can I get help with the above and be directed to an easy, simple, "how-to" on building a login form?
Thanks a lot.
P.S. My first post, so please go easy on me, lol.
UPDATE: So I used the command on CMD and it looks like it's successful. Can somebody point me to how to get it working with Rails?
UPDATE 2: I put in the command that Hoa requested and I got this:
ERROR: "bundle install" was called with arguments ["mysql2"]
Usage: "bundle install [OPTIONS]"
UPDATE 3: I did as Satishkakumar said and I got this:
You've installed the binary version of mysql2.
It was built using MySQL Connector/C version 6.1.6.
It's recommended to use the exact same version to avoid potential issues.
At the time of building this gem, the necessary DLL files were retrieved from:
http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.6-win32.zip
This gem includes vendor/libmysql.dll with redistribution notice in vendor/README.
======================================================================================================
Looks like it's all sorted now? Please let me know if there's any more.
I think its issue of installing mysql2 gem in system. Follow below steps to install.
In Gemfile add the line
gem 'mysql2', '0.3.21'
And run bundle install from project folder in CMD.
bundle install mysql2
This might solve your issue. Let me know in comment section if your issue still persists.

"unknown encoding name" when trying to install Ruby on Rails

I'm trying to install Ruby on Rails, but when I want to use Ruby, install bundle, or create a Rails app, I get this error:
C:/Ruby22-x64/lib/ruby/2.2.0/win32/registry.rb:71:in `find': unknown encoding name - CP720 (ArgumentError)
from C:/Ruby22-x64/lib/ruby/2.2.0/win32/registry.rb:71:in `<module:Win32>'
from C:/Ruby22-x64/lib/ruby/2.2.0/win32/registry.rb:3:in `<top (required)>'
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 dk.rb:1:in `<main>'
Welcome to Stack Overflow! Very glad that you decided to try Ruby and Rails.
Long story short, you're on Windows and there's a lot of caveats to get the Ruby on Rails stack running on this OS. I think you probably tried to install Ruby just by itself... Could you please try removing that and installing the bundle from http://railsinstaller.org/en instead? It will save you a lot of headaches like these in the long run. I've used it and it's a very well thought out package.
Let me know how it works out for you, cheers!
this is because of the default code page of your command terminal.
use the below command to change the code page to Windows-1252 and you will not longer get that error
chcp 1252

rails server command not working on windows 8

I am doing Ruby on Rails Essential Training From Lynda.com and whille typing the command 'rails server' on windows command prompt, the server stops on its own and shows the following line at the end
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Following are my commands
rails new local_host -d mysql
cd C:\Users\KSHITIJ\Documents\Rails\local_host
rails server
The first two commands works just fine but the third one doesnt
Please Help Thanks
We can hardly offer suggestion with little information like this. Please provide full message which will help us inspect the problem. Paste the full message like he did in this post. Thanks!

rails console doesn't start

I`m in root of my application, and when I type
$ rails console
It looks like something is loading, but nothing happens.
And when I stop ^C I received this trace:
^C/home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `gets': Interrupt
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `verify_server_version'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:25:in `call'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:23:in `call'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/jonatas/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/jonatas/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/jonatas/Code/Ruby/jonatasteixeira/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
I have no idea whats going on..
I may be answering a bit late for this, but for the sake of the others who are looking for the answer... it's here
Basically, enter this command
spring stop
The issue , as far as I understand, is with the spring gem, specifically, it checks the server for versions, which doesn't tally up.
For my case, the problem started when when I add some new gems into the gemfile.
So once you stop spring and type in any other rails command, spring restart, and every thing should work again, at least until the same problem occurs, or the dev patched the issue.
I've not seen this before, but it looks like maybe spring is messed up in your setup for some reason? Try going into your Gemfile and look for the line that calls gem 'spring' and comment that out. Then run bundle install and try again.
This isn't a proper solution, but if it gets your rails console working again tonight then hopefully it will help you out until a proper solution is discovered.
Running spring stop did the trick for me.
For me spring gem was causing this issue running spring stop resolved this.
In my case, the same trouble is occured on my production environment.
If your environmet is also production, in the first place, you must not install spring on your production environment.
refer this
https://github.com/rails/spring/issues/318
https://github.com/rails/spring/pull/337/files
It can be resolved by this command on your production
RAILS_ENV=production bundle install --clean --without development test
I could run rails console again in Rails 5.2.1 with:
bundle clean --force
bundle install --without development test
Note: My RAILS_ENV variable is already set to production.
I had the same problem in the production environment. The spring gem was not in the development group in the Gemfile. After I correct this all worked fine.

Rails Console not loading? y (Errno::ENOENT)

I'm all of the sudden getting the follow error message when I try to load the rails console. I just recently switched databases to postgres, which has given me a slew of problems (although I must admit I like it a lot better than mysql!), so I'm assuming this is related to that. Any ideas?
y (Errno::ENOENT)/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require': No such file or directory - /usr/local/lib/?
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processing.rb:3:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:5:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/environment.rb:1:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/sprockets/railtie.rb:23:in `block in <class:Railtie>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `run'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `each'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:136:in `initialize!'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/benyorke/rubystore/config/environment.rb:6:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:103:in `require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:103:in `require_environment!'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I believe this might be a bug with Ruby 1.9.3-p327 that just got fixed by Ruby 1.9.3-p385. Does upgrading to 1.9.3-p385 fix it for you?
What seems peculiar in this error message, and is similar to issues I've been having, is the question mark at the end of the path: No such file or directory - /usr/local/lib/?. I've been getting similar strange error messages related to ruby's require and paths with question marks, at symbols, or other random characters at the end of paths after upgrading to 1.9.3-p327 from 1.9.3-p194 a few weeks ago. However, the issues have been extremely sporadic, and around the same time we experienced some hardware failures, so it's been tough to track down.
Today the issue started happening consistently in one specific context, so I was able to do some additional debugging. Updating to 1.9.3-p385 seems to have fixed it, but given the sporadic nature of the issues I've been experiencing, I'm not entirely 100% this is actually the fix. I'm also not entirely sure if this is the same issue you're having. The mysterious question mark in the path just makes it appear like it might be related. Here are a couple examples of the type of errors we were getting:
No such file or directory - /srv/shared/rails/internal/admin/vendor/bun#
No such file or directory - /srv/shared/rails/internal/admin/vendor?
If it's at all related to the same issues I've been experiencing, but the 1.9.3-p385 upgrade doesn't fix it, a few other notes or things to explore:
I was able to reproduce this problem today on 1.9.3-p327 and 1.9.3-p374. However, the problem didn't seem present on 1.9.3-p194, 1.9.3-p286, and 1.9.3-p385.
Are you using symlinks anywhere in in your gem load path? For example, we use Bundler to install gems into a local vendor/bundle path inside each application. But the vendor/bundle is actually a symlink to another location (this is related to a Capistrano deployment setup). I believe the symlink was possibly playing a role. In today's tests, if I wasn't using a symlink, the problem disappeared on all versions of ruby.
Do you use bundler-exec? On another occasion where this problem was happening somewhat sporadically, bypassing the aliases bundler-exec also seemed to magically fix things, but today's problem wasn't even touching bundler-exec, so I'm not too sure.
Most of the time our problem was very random (it would go away after a few attempts of running the same command), but on a few occasions, the problem would persist for an hour or more before disappearing.
Some information about our systems:
64bit RedHat Enterprise Linux 6
Bundler 1.2.3
Rubygems 1.2.5 (also happened under 1.2.4)
rbenv
But like I said, this issue also happened to coincide with some hardware disk failures and general server wonkiness on our end, so I haven't really been certain if this was a Ruby issue or what's been going on. But here's to hoping 1.9.3-p385 actually fixes it.
Sorry for not updating this thread - I have actually been working on this in the background for a few weeks now. I couldn't find ANY information on this online, so I'm going to post as detailed of a solution as I can.
The Issues
The issues I was having was that I could not access rails console, and I had to manually start the postgres server every-time I restarted my machine. My solutions to that, as I have worked with this for a few weeks were
In regards to the console I used herokus console. By pushing my app to heroku (which is free) not only could I view it on the web (any machine) but on my machine I could run
$ heroku run console
and get access to a console. Now this isn't a perfect solution in anyway as I can't manipulate data on my machine but it saved me many times
In regards to the server I ran
$ brew info postgres
which gave me the commands to manually restart the server
You should reload postgresql:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
The Solution
To be honest, I have run every command I can find dozens of times, and just today got it working. I don't know if I was making typos, doing it in an ineffective order, mixing up pg/postgres/postgresql or what but what I did below worked
When using this solution, it will erase all databases. Migrations will be able to rebuild the structure, but any data will be lost
1. Updated Homebrew
$ brew update
If you don't have home-brew, check out this page for instructions to install (saved my neck with many things, including minimagick imagemagick and postgres!): Link
2. Removed postgresql
$ brew rm postgresql --force
3. Installed postgreql
$ brew install postgresql
This is the first step to reference postgres. When looking online, I ran across commands that used postgresql, postgres, and pg. Postgresql refers to the actually PostgreSQL program. postgres and pg are ruby gems, which we will get to later
4. Ran suggested commands
After running "$ brew install postgres" there is a lot of information given to you. Make sure to read through it, as it will suggest what commands to run. Use these suggestions to find the commands I reference below.
If you need to access this information later simply run
$ brew info postgresql
To initialize the database
$ initdb file/path
Set up the autolauncher
$ cp file/path ~ LaunchAgents/file/path
Launch postgresql initially
$ launchctl load file/path
$ pg_ctl-D file/oath
5. Download Postgres.app
Although to my knowledge this seems redundant, this is what got it to work on my mac. visit http://postgresapp.com to download
6. Install gems
There are two gems - postgres and pg. I required pg in my gemfile and ran a bundle install command, however it still gave me issues until I installed postgres on my machine - even though it is not required in my gemfile, rails console wont seem to work without it atleast installed
In the gem file
gem 'pg'
Run a bundle install command in a terminal window
$ bundle install
Sudo install the postgres gem
$ sudo gem install postgres
At this point everything should be working. You should be able to restart the machine and not have any problems!

Resources