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.
Related
I am upgrading a Rails project to Ruby 3.1.2, from 2.6.6. I initially ran into this problem, but fixed it with adding gem 'psych', '< 4' into the Gemfile. I should note that an answer there mentioned downgrading to Ruby 3.0.3, but that does not fix my issue.
After adding that, the project worked fine regarding Psych. Unfortunately, when trying to commit/push, the overcommit hook returns this error:
/.rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/runtime.rb:309:in 'check_for_activated_spec!': You have already activated psych 4.0.4, but your Gemfile requires psych 3.3.2. Prepending 'bundle exec' to your command may solve this. (Gem::LoadError)
I also tried changing overcommit's version and got this error:
Since "psych" is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports psych as a default gem.
Is there any way to fix this, or a specific overcommit version that would bypass this error?
Came across similar issue. So, posting here in case it may help somebody.
With Ruby 3, you need to add psych ~>3.0 to the Gemfile explicitly, because the default version of psych which comes bundled with Ruby 3 starts giving errors as it doesn't quite understand how to handle aliases.
If you still wish to use default psych which comes bundled in with Ruby 3. You can load your YAML files like:
YAML.load_file(file_path, aliases: true).
In my case, I had dependencies loading YAML files so I decided to downgrade the psych version instead of loading YAML file with aliases: true.
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.
I have recently updated rails and some other gems. However now I get the following error:
Sass::SyntaxError at / Mixin "exports" does not accept a content
block. (in
/Users/mikhailja/Sites/marketing/app/assets/stylesheets/application.css.scss:341)
I'm using:
ruby 2.1.2
rails 4.1.8
sass 3.2.2
sass-rails 2.0.0
foundation-rails 5.4.5.0
The problem went away for a while after trying numerous gem versions but now all of a sudden its back after getting a stack level too deep error.
I've tried the same version of foundation in a new app and it works perfectly.
Any help to get to the bottom of this problem would be very much appreciated.
According to the Foundation github repo, it has to do with a Rails and Sass compatibility issue, which creates a Foundation compatibility issue because of their codebase. Apparently sass-rails has been recently updated to deal with this, and should solve the issue, but I'm not seeing any updates when I update my gems, so best way to deal with it now is probably to downgrade.
Edit: figured it out. In your Gemfile delete the specified version of sass-rails that's autogenerated then run update and you'll get the newest version which will work with the newest version of foundation.
I found a solution. Here is what I did for anyone else experiencing this problem:
Downgraded foundation-rails gem to version 5.1.1.0 (this was my original version) at this point my rails server would not start properly.
Then updated foundation-rails to version 5.3.0.0
I'm not sure if there was just a gem version compatibility issue or if the downgrade/upgrade made the difference.
Anyway, now everything works and my tests are passing!
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.