Resolving a dependency mess - ruby-on-rails

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.

Related

Gem conflict in Rails with Activesupport

I keep getting this message when trying to spin the server in rails.
to_specs': Could not find 'activesupport' (= 6.0.0) - did find: [activesupport-5.2.2.1] (Gem::MissingSpecVersionError)
Checked in 'GEM_PATH=/home/louis/.gem/ruby/2.5.0:/var/lib/gems/2.5.0:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.5.0:/usr/share/rubygems-integration/2.5.0:/usr/share/rubygems-integration/all', execute `gem env` for more information
I have tried uninstalling and reinstalling the gem, but I am wondering why my app is even expecting version 6.0.0, I am running rails 5.2.2.1 (and have to keep it that way) does anyone know what is happening and how I can resolve it.
Side note: I am using commands gem such and such rather than bundle for various reasons
Response to comments: The reason for not using bundle is because when I was using bundle to manage my dependencies for work, it was mismanaging the gems I had globally- so If I made a practice project and bundled, it would also change the gems for the project I work on professionally and cause conflicts- so now bundle has a different environment to my work project so I can create mini rails apps in my spare time. How do I remedy this situation? Many Thanks
can you pass the gemfile and gemfile.lock?
You have to bundle.
This will install gems and resolve dependencies.

rails uninitialized constant Sprockets::SassCacheStore

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.

Ruby 1.8.7 works. Ruby 1.9.2 produces 'Trace/BPT trap: 5'

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.

Having issues with gem version when running Cucumber

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

ZenTest autotest can't find rubygems

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/

Resources