I've taken over ann application that was deployed to a server by someone else. There's something broken about the setup, some missing environment variable or similar problem but I am stumped. By the way this is obviously a Rails application, running under REE and mod_rails (passenger)
Here are some console logs that have me stumped. First, rake db:migrate claims I don't have Rails 2.3.8
$ rake db:migrate
(in /var/www/ems.trustthevote.org/ems/current)
Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`, update your
RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
However, bundler says I do:
$ bundle list
Gems included by the bundle:
[...snip]
* actionmailer (2.3.8)
* actionpack (2.3.8)
* activerecord (2.3.8)
* activeresource (2.3.8)
* activesupport (2.3.8)
[...snip...]
* rails (2.3.8)
But on the other hand, gem says no:
$ gem list rails
*** LOCAL GEMS ***
Here are some relevant environment variables:
RUBYOPT=-rauto_gem
RUBYLIB=~/.gem
And finally, here's what Ruby thinks:
$ irb
irb(main):001:0> $:
=> ["~/.gem", "/usr/lib64/rubyee/site_ruby/1.8",
"/usr/lib64/rubyee/site_ruby/1.8/x86_64-linux", "/usr/lib64/rubyee/site_ruby",
"/usr/lib64/rubyee/vendor_ruby/1.8", "/usr/lib64/rubyee/vendor_ruby/1.8/x86_64-linux",
"/usr/lib64/rubyee/vendor_ruby", "/usr/lib64/rubyee/1.8", "/usr/lib64/rubyee/1.8/x86_64
linux", "."]
irb(main):002:0>
My eyes are crossed. What am I missing?
When using a custom bundle path, make sure that you run rake commands within the bundler environment.
bundle exec rake db:migrate
Try that out.
Bundler installs the gem in a custom directory. This is the reason why the result of gem list won't show them.
Unfortunately, I'm not sure why the command $ rake db:migrate doesn't find your gems.
Related
Jonathans-MacBook-Air-2:hw3-rottenpotatoes Jonathan$ cucumber
WARN: Unresolved specs during Gem::Specification.reset:
tzinfo (~> 0.3.37)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
You have already activated activesupport 4.0.0, but your Gemfile requires activesupport 3.2.14. Using bundle exec may solve this. (Gem::LoadError)
/Users/Jonathan/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup'
/Users/Jonathan/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
/Users/Jonathan/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/Users/Jonathan/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/setup.rb:7:in `'
But it seems like I have the right rails version in this directory.
Jonathans-MacBook-Air-2:hw3-rottenpotatoes Jonathan$ rails --version
Rails 3.2.14
I'm kind of new to ruby and am confused as to why "rake cucumber" works but "cucumber" doesn't in the terminal.
I don't know how ruby and gems are set up but I have a hunch is that somehow in my working directory, ruby is told to use rails 3.2.14 but the command "cucumber" is only detecting activtesupport 4.0.0 (which I believe is tied to rails)
Thanks so much!
cucumber is a binstub, while rake cucumber is a rake task that executes the library.
Try bundle install -—binstubs first, then try cucumber.
Perhaps the binstub is somehow out of date?
If that doesn't work, just kill the binstubs by deleting the project/bin dir, and rerun bundle install -—binstubs
You have multiple versions of Rails installed and cucumber doesn't know which to use, so it's trying to load both and erroring out.
To use the one specified in your Gemfile, specify bundle exec before all commands, eg. bundle exec cucumber.
I am configuring a Rails APP. I did bundle install properly. Also using ruby 1.8.7 using RVM. Now after bundle install, it is throwing the below given error while doing rails s.
/usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find
executable rails for rails-3.2.9 (Gem::Exception)
Can anyone help me to sort out this?
Using ruby: 1.8.7
Rails Version: 3.0.3
After running bundle install, your Gemfile.lock has a list of all the gems and their versions that are needed.
However, you need to run bundle exec in order for bundler to make those gem versions available to you.
The rails script is an exception, as it invokes bundler for you, but it sounds like something isn't working in your environment.
Try executing the rails script using bundle exec like so:
bundle exec rails s
And see if that helps. Also, from the man who wrote bundler: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
You have two rails gem versions in same gemset so it is picking latest version. So you need to specify rails version for rails commands.
Try this:
$ rails _3.0.3_ server
Background:
I get errors whenever I run rake in an older project. (uninitialized constant Rake::DSL).
The rails project in question is an old project that was started with Rails 2.1 (I think), and since then I've updated the OS on my laptop a couple of times, and made updates along the way to make it run.
Right now, the rails app works fine, provided I have RAILS_GEM_VERSION set to 2.3.5. I'm not sure if the app was completely updated to Rails 2.3.5.
There is no Gemfile in my older project.
If I create a brand-new rails project (and unset RAILS_GEM_VERSION), rake runs fine.
My question: To troubleshoot, I'd like to try newer versions of rake. I'd like to know how to force one specific version to be used, since it appears I have multiple versions installed.
Info on my environment:
$ gem list rake
*** LOCAL GEMS ***
rake (0.9.2.2, 0.9.2, 0.8.7, 0.8.3)
$ rake --version
rake, version 0.8.7
So it looks like it's picking up the 0.8.7 version.
All the help files online seem to tell me to specify the rake version in the Gemfile, but there isn't one in this project. (Maybe it predates gemfiles?)
If I unset the RAILS_GEM_ENVIRONMENT variable altogether, and try to run rake, I get:
rake aborted!
can't activate rails (= 2.3.5, runtime) for [], already activated rails-3.2.8 for []
None of the environment config files in my older project set that variable either.
This may be of help. Have you tried the underscore solution?
Example:
rake _0.9.2_
you can run rake specific version by using this
bundle exec rake ...
more detail see this - bundle exec, rake
You can uninstall the current version of rake and install another desired version using commands similar to the following:
gem uninstall rake 12.3.1
gem install rake 10.5.0
(Note: you might need to run as sudo for permissions)
I had a problem where I received the following error while trying to install rake 10.5.0:
Could not find a valid gem '0.8.7' (>= 0) in any repository
I resolved this problem by adding the following line to my Gemfile:
gem 'rake', ' <11.0'
After editing Gemfile I was able to successfully downgrade rake by updating my gems:
bundle update
When I try to do rails server and thin start, both say: "Could not find activesupport-3.0.6 in any of the sources."
I have activesupport-3.0.7 installed. Do I need to revert so that activesupport matches my Rails version (3.0.6)?
Run bundle install in your rails directory (or change your Gemfile to require 3.0.7 instead of 3.0.6)
Also, when running the rails commands, you can prefix it with bundle exec to make sure it's using the correct version:
bundle exec rails server
Sounds like your Gemfile and your installed gems are out-of-sync:
Which version of Rails is listed in your Gemfile—3.0.6 or 3.0.7?
Have you run bundle install?
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/