I followed the rails tutorial to install Spork and Guard:
http://ruby.railstutorial.org/chapters/static-pages?version=3.2#sec:first_tests
Guard and Spork work when started separately, but when using it together, it hangs with the last output line "Spork is ready and listening on 8989!" without executing any tests.
I even used the argument :wait => 60 as described on https://github.com/guard/guard-spork
Any idea?
And by the way, if I should post the Gemfile or the Guardfile, is there any way to paste it without manually indenting each line by 4 spaces?
Thanks
You should be able to use the " blockquote or {} codeblock buttons to automatically highlight or indent.
Setting up my tests gave me some trouble too as I followed along with the same tutorial. I got lucky by looking for other tutorials (some are listed below) and playing around with different gems and gem versions. Some things I learned the hard way in playing around with gem versions:
1) Calling "guard" from your project directory and calling "bundle exec guard" may or may not execute the same version of the guard gem, if you have more than one version installed. I recommend reading about bundler if you suspect gem versions might be giving you trouble. I know they gave me trouble.
2) The definitive version of the gem you are using for your project is listed in Gemfile.lock, but you're not supposed to modify that file. Modify the Gemfile with specific gem versions to get the right version installed.
Type One Error,
The Carbon Emitter
I hope you realize that when you first start guard and spork together it isn't supposed to execute any tests? It waits until you change a file, and then runs the tests for that file that changed. Or if you want it to run all specs, just hit your key.
Related
I ran gem update the other day in Command Prompt with Ruby and Rails. There was a flurry of text, and it said such things as ...rdocs rails 4.0.0 (I forget exactly what it was saying) and all in all it took about 40 minutes (the rails 4.0.0 listings seemed to be longest.) However, I used bundle install after that, and I'm still using 3.3.2 rails, and worse, using old models of all the other gems (most noticeably shoulda and shoulda-matchers.) Please help me see what I did wrong, whatever it might have been. I'd like to update my gems all at once, if appropriate (I am new so I don't know if its recommended.)
If you want to update your project gems (which features updating Gemfile.lock and actually updating proper gems), you need to run:
bundle update
To run an RoR command line on a project, you have to make sure you are in that project's root folder beforehand. For example, if your projects are in c:\projects and you are working on project trythisone, you need to be in c:\projects\trythisone before you run bundle update or any similar command.
You probably don't need rdoc, anyway, so follow this advice. To be clear, in Windows 8 you would need to go to your users folder and add a file called ".gemrc". Thus, for a user called "myuser", you would have a file at: (Earlier Windows versions would be in their particular users folder)
c:\users\myuser\.gemrc
This file would contain the following text:
gem: --no-ri --no-rdoc
Marek Lipka was correct in that bundle update is needed.
What does this mean? Is my system set for UTF when it should be ASCII or something?
This problem has been nagging me on one of my machines for the past year, and I only solved it just now. The machine in question is an old ASUS laptop running 32-bit Ubuntu 12.04, Ruby 1.9.3, and RVM. I had the same problem running gem update, but only with rake 0.8.7
Sadly, I'm a bit of a newb at this stuff, so I can't quite work it all out, but I ran into two separate issues - inability to update rake beyond 0.8.7, and inability to get the documentation to process correctly. The second problem is the more difficult to understand, but, as I understand it, it results from one particular version of rdoc relying on SourceIndex, which was deprecated in November, 2011.
Both problems are gem-related - character sets in the OS, to name one potential cause, don't seem to be an issue. As best as I can tell, my version of the problem was that my paths weren't correctly set to update the gem program. I'd type "gem update --system" from the prompt and gem would tell me that it was up-to-date, but rake wouldn't update and the characters wouldn't be correctly installed in the documentation for rake, either.
In retrospect, what apparently happened was that the path was set up so that gem update would affect a different version of Ruby than the one I was using under RVM. So, the key is to update the gems you're using by running the update program without having to rely on the path.
The solution has four parts. The first is to uninstall rake.
The second is to update the gems (this also makes it possible to update rake). Usually, this can be done by just typing gem update --system Since I'm using RVM, I did this by going into ~/.rvm/gems/ruby-1.9.3-p194/bin and ran update_rubygems. I suspect that my system fell out of configuration between the path and multiple versions of Ruby. By going directly to the ~/.rvm/gems/ruby-1.9.3-p194/bin directory and running the update_rubygems command,the system was able to update both the correct rdoc gem so it correctly translated the characters, and the correct rake gem, both of which are gems in the rvm-managed version of Ruby.
The third stage is to reinstall rake.
The fourth is the usual suite of testing and hygiene commands - gem clean, gem update, gem list, etc.
I regret not having a better handle on this, but hope this helps.
I'm a beginner to Ruby on Rails tutorials and the last thing I did was create a new app, generate scaffolding without Tests (- T flag), installed RSpec, and initiated a git repo in the folder.
That was two hours ago. I open my laptop up, try to run:
rails server
Now I'm seeing this error:
/Users/reneruiz/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/
rubygems/requirement.rb:72:in 'parse': Illformed requirement ["0.7.1."] (ArgumentError)
The full stack trace is here: http://cl.ly/4pQC
I did some Google searches and I can't seem to find anyone else with the same problem.
I don't know how or where to go from here. Would seriously appreciate some help.
Check your Gemfile for version requirements that look like "0.7.1." It looks like Bundler is trying to check for a gem with a certain version and is choking on the trailing period. If you find the version in your Gemfile, fix it and then run bundle install on the command line, and see if it'll start.
Instead of only bundle install run bundle install --full-index
I am learning rails by following the Rails Tutorial under Ubuntu. I have been using spork and autotest and following the TDD as suggested by the book.
At some point (which I can't tell) the autotest stopped refreshing on it's own and so I killed it, alongside spork to reboot them both (the book does say that happens and that you should reboot them) just like I had done couple of times before.
This time spork won't load and give me this error: "I can't find any testing frameworks to use. Are you running me from a project directory?" and there doesn't seem to be any documentation whatsoever.
What could it be?
P.S. I am running it from the project directory. I already tried the bundle install and bundle update commands, I also uninstalled the spork gem with gem uninstall spork and reinstalled it with bundler... nothing (Rebooting the computer does nothing as well XD).
I am using "RSpec" to run the test alongside "autotest". It seems that at some point I accidentally removed the rspec_helper.rb file (or something like that, I can't really recall the name of the file) and that was keeping both "spork" and "autotest" off.
Just had to re-run the generate scripts for RSpec and voilà. All worked like a charm.
P.S.: For sanity run your generate script in a project copy for the the generate script could replace some other files and brake some custom-made functionality.
Having the same problems as this post, except I don't think the solution is the same unfortunately.
I'm getting this error message:
Rails requires RubyGems >= 0.9.4. Please install RubyGems
when I run a script/runner job in Cron, but it works perfectly fine when I run it in a terminal on the same server.
The rails server also runs fine. I only have trouble running script/runner's in cron. It seems to want to have a terminal attached...
Try which ruby and which gem from your cron job and also from the terminal. Are you accessing different binaries? You didn't mention which OS and which shell, but you may have a different $PATH when running headless.
The selected answer is completely correct, but something I'd suggest is to NOT use script/runner. The resources required to load the entire stack of your rails application is pretty intense for something to run regularly.
In my past experience, any cron jobs generally only have to deal with data (as opposed to say, generate static files, etc). In this case, you can very simply just load your models up, and since you've written your models the correct way (fat models), you can easily do your data processing with a few model methods.
Of course, all the above depends completely on your task, so take it with a grain of salt :)
I suppose this was a sort of answer to a problem that may not exist, and wasn't asked here, but just thought I'd throw my two cents in ;)
You wouldn't happen to be working on OSX? You should be installing a newer ruby rails and gems off macports instead. Google for the instructions...
As indicated by earlier posts, your Cron is using a different gem command source — also try which gem and gem -v. You may have a library set in your .bash_profile (or similar shell configuration or perhaps by other means, setting proper Ruby/Rails environment (i.e., Locomotive or other all-in-one environment).
To update your gem setup:
gem update --system
More information here - http://www.rubygems.org/read/book/1