I have a rails project that runs fine in development and production and the tests pass when I do a rake test but when I try to autotest it it fails with:
Missing the Rails 2.3.3 gem. Please `gem install -v=2.3.3 rails`, blah blah
Of course the rails gem is not missing and if I comment this line out, it complains about the rest of the gems.
Trying to debug the problem, I initiated a new rails project and started copying code from the problematic one and running autotest every now and then. After a couple of minutes I had copied all the files (even the tmp folder) and autotest was not complaining at all.
The only difference between the projects is their RAILS_ROOT, one is ~/Sites/market and the other ~/Code/tempora and their .git folders though I seriously doubt it should make much of a difference.
Also I have a ~/.autotest with the following inside (which should also make no difference):
require 'autotest/growl'
require 'autotest/timestamp'
I really have no idea on where to look for debugging this anymore....
LOCAL GEMS
rails (2.3.3, 2.3.2, 2.2.2, 2.1.1, 2.1.0)
ZenTest (4.1.3, 4.1.1) - also tried with 4.1.4 yielding the same results
autotest-fsevent (0.1.1)
autotest-growl (0.1.6, 0.1.2)
autotest-rails (4.1.0)
The only thing I can think of is that autotest is looking for Rails in your ~/.gem folder in one instance and in your /Library/Ruby/Gems in another. What might sort it out is just to install RVM. Then, create an RVM environment with just the gems you need and try running in that. Learn more about RVM here: http://rvm.beginrescueend.com/
Related
I'm new to rails and trying to do some playing around with gems and such.
My case here is that I have this navigation menu on my website and I needed to get the current_page link selected.. rather than building a helper I wanted to install a gem so I went and looked for one and found this one.
I then followed what the documentation said:
In my gemfile I added
gem 'rack_current_page'
Then in the project root config.ru
require ::File.expand_path('../config/environment', __FILE__)
use Rack::CurrentPage
run Rails.application
And finally I ran:
bundle and rails s only to find out I had this error:
uninitialized constant Sprockets::SassCacheStore
The error happens when including the application stylesheet in the layout file.
I'm using the following packages / versions (only listing what might have impact - if I'm missing something let me know)
(<gem> -v)
Rails 4.2.1
Sprockets 3.0.0
Sass 3.4.13
Rack 1.5
While doing the uninstall I removed every line I added - heck I also reset my project files to head since I just started working on it anyways,
ran a fresh bundle, restarted the server, checked the site but all I'm getting is the error above..
I googled and tried to look for a similar question on SO but couldn't find any so the only thing I could really try was the uninstall and reset my git.
I'm definitely looking over something really stupid but can't really find the answer so here I am ;)
Any help is appriciated, thanks in advance and comment if I missed info that you guys need.
time of writing
I actually did a quick gem pristine --all with no results either.
EDIT 1
Okay, so with abit of guesswork and the same situation happening before resulting in the recreation of a fresh app in the (short) past I uninstalled the compass-rails gem and ran bundle afterwhich rails s to test if things started working.
It did. Then I went on and reinstalled compass-rails and it kept working... getting quite confused now :S
Okay so here goes:
I've found the problem and it was solved by actually supplying a version that works with rails 4.2.
The default gem compass-rails installs a version incompatible with sprockets.
When I added the specific version as seen here and ran another bundle the versions of most of the packages I named in the question changed.
console output after gemfile modification included:
Installing sprockets 2.12.3 (was 3.0.0)
Using sprockets-rails 2.3.1 (was 2.2.4)
Installing sass-rails 5.0.1 (was 5.0.3)
Installing compass-rails 2.0.4 (was 2.0.1)
Guess it's just waiting for compass to release a compatible version.
I'm following Michael Hartl's Ruby on Rails tutorial, and I got stuck at trying to start rails server on my Windows 7 machine.
I'm trying to do this by following instructions in Chapter 1.2.5., i.e. by typing
rails server
However, instead of booting WEBrick, this returns the instructions for usage of 'rails' command. I've been googling this for a while, and some of the answers seem to have implied that something is wrong with the rails gem.
Now, I've found the rails gem folder ("C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\rails-3.2.3"), and it's empty!
Also when I try
rails -v
it returns "Rails 3.2.16", although I've removed this version of the gem; if I try
gem list
it kept telling me that the version is 3.2.3.
This persisted until I deleted railties version 3.2.16, which resulted in
rails -v
returning 'Rails 3.2.3', but I still can't boot WEBrick.
Any help would be appreciated.
Did you run the installer?
At the time of this writing, I recommend using the Ruby 2.0.0-p353.
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353.exe?direct
Save yourself some future gem headaches and install the DevKit too.
http://rubyinstaller.org/downloads/
It should create a folder at C:\Ruby200. Start a new command prompt for the new paths to take affect.
Once Ruby is install, gem install Rails. From your other post, I recommend gem install rails -v 3.2.16
Then execute rails new project_name, then cd project_name. Then run rake db:migrate to create the initial database. At this point, you should be able to run rails server and visit localhost:3000 in your browser.
OK, I've managed to solve my problem.
I've seen a few more people having the same issue, but none of the solutions that I've found helped me, so here's what did it for me, though I'm not 100% sure what exactly was that one thing that actually did it...
I've followed the advice #scarver2 gave in response to my other question, and uninstalled both Rails and Railties gems from my crispy fresh installation of Ruby 1.9.3. (I've installed it using RailsInstaller). Then I've installed Rails 3.2.16 gem by typing
gem install rails -v 3.2.16
and this also installed the corresponding Railties 3.2.16 gem without my intervention.
Then I followed steps from chapters 1.2.3. and 1.2.5. of the tutorial, but making sure that line referencing ruby version in my Gemfile actually corresponds to the version of Ruby that I have installed.
I typed
ruby -v
in the console, to make sure that I have version 1.9.3. indeed. Confirming this, I've edited the Gemfile in my app so it says
ruby '1.9.3'
instead of ruby '2.0.0' line that's used in Listing 1.5. of the tutorial.
After that I've simply went to my app folder, and typed
bundle update
bundle install
in the console, and this time it did not return any errors as it did in my previous attempts. After that, typing
rails server
did what it should have, and my WEBrick server booted, allowing me to access my app on localhost. Yay!
Now, what I think may have gone wrong the last time was either me screwing up the Gemfile, so the gem versions and their dependencies got messed up. I also assume that ineptly trying to fix this by installing and uninstalling different versions of various gems did not quite help. What may have helped was uninstalling Rails and Railties gems, and installing Rails gem again.
I am running a Rails 2.3.11 app on two versions of Ruby both installed with RVM. Both versions of Ruby have the exact same gems with the exact same versions for each. I uninstalled every gem that is not needed in the application.
Everything works fine with Ruby 1.8.7 (RVM 1.8.7).
Ruby 1.9.2 has two gemsets. RVM 1.9.2 has a gemset for another app. RVM 1.9.2#this_app has the gems listed below. With RVM 1.9.2#this_app I get:
Trace/BPT trap: 5
The log just stops with no indication of what the error is. Is there a gem compatibility issue? Here is the list of gems:
actionmailer (2.3.11)
actionpack (2.3.11)
activerecord (2.3.11)
activeresource (2.3.11)
activesupport (2.3.11)
devise (1.0.10)
google4r-checkout (1.0.6.1)
i18n (0.6.0)
json (1.6.1)
liquid (2.2.2)
money (3.7.1)
mysql (2.8.1)
rack (1.1.2)
rails (2.3.11)
rake (0.9.2)
rmagick (2.13.1)
warden (0.10.7)
Thanks for your help.
This seems to be the list of gems installed, not what is in your Gemfile.
How are you managing the gems and gemsets? You seem to be using bundler, that's good, but how are you switching between versions of ruby and gemsets? Are you using rvm or rbenv? Do you have a Gemfile?
If you are not using bundler, it is possible to do so with rails 2.3.11, it just takes a bit of work. I would highly recommend this so you can better manage your dependencies.
I would then look at getting rid of whatever you can from the Gemfile, bundle install to update, and then try running again.
For example, I don't think you need cgi_multipart_eof_fix anymore, depending on how you are deploying.
Other gems like god, rubygems-update, and rdoc are not generally used within the app, and are likely not germane.
So I take it that you can't even boot the app successfully with ruby ./script/server? It doesn't start up and then crash on the first request?
When Ruby starts crashing on you, the first thing to look at is whether you are using any binary (not pure Ruby) gems. Just looking at the above list, I believe that json, mysql, and rmagick may be binary. Comment them out temporarily from your Gemfile (if you have to comment out part of the application code, then do it). Try starting the app with bundle exec ruby ./script/server and see if it crashes. (I think json might be required by Rails, in which case you won't be able to disable that one.)
If you are only using pure Ruby gems, and Ruby is crashing on you, then you have likely found a bug in the interpreter itself. That's nothing to get scared about; if I was you I would roll my sleeves up, dive into the C source (clone it from github.com/ruby/ruby), and fix that thang! But if you don't have skills in C you might not want to attempt it.
If you want to try to debug the interpreter, the first thing is to find the point where it is crashing. For that, litter the startup code (such as application.rb, boot.rb, etc. with puts "got to #{__FILE__}:#{__LINE__}" calls and try to pinpoint exactly where the crash is happening. If need be, you can crack open your gems and add puts calls to them too (just go into the directory where RVM keeps the Ruby code and edit away).
Once you find the point where it is crashing, you can go into the C source and find the implementation of whatever platform method or construct the crash is coming from. To get more information on what is happening internally, add debug printf calls and recompile the interpreter with make && make install. (Note that messages from C-level printfs don't seem to interleave in quite the correct order with Ruby-level puts.) Temporarily edit your PATH so the newly compiled binary in your cloned ruby/bin directory will act as the system ruby.
If you can actually figure the problem out and contribute a patch to Ruby, that will mean some pretty good bragging rights for you!
Don't really like answering my own questions, but found the full answer which wasn't provided yet.
Part of the problem was rmagick compatibility. I commented out references to rmagick in the app but was still getting the same error.
The biggest contributing factor was that RVM installs rubygems 1.8.24. Anything over rubygems 1.6.x will not work with a rails 2.3.x app. The command 'rvm rubygems 1.6.2' installed a version that was compatible.
Trying to squeeze in a fairly new gem, and its causing me to stumble around updating quite a few others including Rails as a whole from 2.3.5 to 2.3.6.
Bundler installs fine.
But when I boot up script/console, I get this :
Loading development environment (Rails 2.3.3)
/Users/macuser/Sites/hq_channel/config/../vendor/rails/railties/lib/initializer.rb:271:in `require_frameworks':RuntimeError: can't activate rack (~> 1.0.0, runtime), already activated rack-1.1.0. Make sure all dependencies are added to Gemfile.
/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:117:in `gem': can't activate rack (~> 1.0.0, runtime), already activated rack-1.1.0. Make sure all dependencies are added to Gemfile. (Gem::LoadError)
from /Users/macuser/Sites/hq_channel/vendor/rails/actionpack/lib/action_controller.rb:34
It's strange that it says Rails 2.3.3 .. not sure why..
I can't figure out where/how it's loading or trying to load Rack 1.0.0 now that I've updated it to Rack 1.1.0.
Any ideas?
If you're using Bundler and running into dependency issues using a local binary, try prefixing that script with bundle exec:
bundle exec script/console
Under the hood, this does the following:
Starts a new ruby process that calls Bundler.setup (thereby loading all your bundler deps)
Executes the command you passed bundler exec in the context of your Bundler dependencies
This tends to solve most problems. If you're still having issues after that, your best bet is to verify your shell's environment variables are correct and debug from there.
PS: If your issue is what I think it is, the problem here is that script/console is pulling your system gems instead of the ones provided by bundler, which is why you're seeing the incorrect version of Rack and getting load errors for your other gems.
I originally posted the question: What does this Cucumber error message mean?
Following the suggestion of uninstalling builder and running bundle worked, for a while. Now I am getting a similar error, but this time on rack.
When I run cucumber features I get the following (previously cucumber has worked):
can't activate rack (~> 1.2.1,
runtime) for ["actionpack-3.0.7",
"railties-3.0.7"], already activated
rack-1.3.0 for ["rack-test-0.6.0",
"cucumber-rails-0.5.0"]
(Gem::LoadError)
Deleting rack just to get cucumber to work doesn't sound like a really good idea to me. How can I fix this problem so it doesn't come back again on another dependency?
I think you could put the exact version numbers for your gems (including Cucumber) in your Gemfile and then run using bundle exec
bundle exec cucumber
This will run the Cucumber version in your Gemfile, which should always keep things working even when you upgrade your system version.
The other option is to use RVM gemsets