Inconsistent rails gem errors - ruby-on-rails

Every other time I run a rake command, or start the server (script/server) I get gem install errors;
Missing these required gems:
image_science >= 0
youtube_it >= 0
But, if I ignore that (the gems are installed) and try again, then on the 2nd or 3rd attempt, it will work fine, no errors.
It seems like maybe there are multiple rails or rake installs, but which rails shows only '/usr/bin/rails' as does which rake
I'm wondering if maybe my app could have different requirements in different places? Is that possible?
Rails version is 2.3.15
EDIT
More output
You're running:
ruby 1.8.7.358 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
rubygems 1.8.24 at /Library/Ruby/Gems/1.8, /Users/<snip>/.gem/ruby/1.8, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Thanks in advance.

Related

Why does this happen when i try to update rails to 4.0.0?

I pulled someone's project from github, and we seem to be using different rails versions. When i update the rails gem, it seems to go fine, but when i check the version it still shows the previous one and won't run the rails server.
me#ubuntu:~/Documents/RailsProjects/vega$ gem install rails
--version=4.0.0
Successfully installed rails-4.0.0
Parsing documentation for rails-4.0.0
Done installing documentation for rails after 0 seconds
1 gem installed
me#ubuntu:~/Documents/RailsProjects/vega$ rails -v
Rails 3.2.6
You have multiple Rails versions installed and it's reporting the first one it finds.
Does the project have a gemfile? If so just let bundle handle this for you:
bundle install
bundle exec rails s

Can't boot WEBrick, the folder for Rails gem is empty

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.

'rails s' throwing error

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

Rails: gem.config & rake gems:install -- no such file to load

I'm trying to use config/environment.rb to install a ruby gem dependency (because I don't have sudo access to our server; ergo, can't just call gem install hpricot).
I've tried including sundry arguments (:version, :source, :lib) but I still get rake aborted! no such file to load -- hpricot
Update: It turns out that when I remove the plugin which requires hpricot, then I can execute rake gems:install successfully. But that's not very helpful. It means that if I ever move my app, I run into a problem of being unable to rake its gems (because I will have reinstalled the plugin and added features that depend on it).
How is this supposed to work?
Sys: WinXP, Ruby 1.8.7, Rails 2.3.5
Rails is trying to load the gem before executing the rake task. This is a known issue with rails 2.x. The only solution I know of is to switch to using bundler to manage gems or manage then manually.
Bundler can be used with rails 2 but it requires some modifications to your application and deployment scripts. This is a good place to start: http://gembundler.com/rails23.html
rake gems:install has been deprecated because it never really worked. You can imagine having a gem installer with dependencies to the very gems it's trying to install is a bad idea.
It's advisable to use bundler instead if that's an option.
Bundler allows you to install gems to any destination you want, something specifically intended to side-step the whole "requires sudo" problem you describe. It's often as easy as this:
bundle install --path ~/my_gems/
You can make your Rails 2.3.x application use Bundler by following a few simple steps and from there your life will be a lot easier.

why isn't rails (or script/console) seeing my current version of 'gem'?

I'm having trouble getting a working rails console, and I'm not sure why. I've tried to distil my issue and the console output below sums it up :
capistrano#dev:/webapps/cts/current$ ./script/console
Loading development environment (Rails 2.3.4)
Rails requires RubyGems >= 1.3.2 (you have 1.3.0). Please 'gem update --system' and try again.
capistrano#dev:/webapps/cts/current$ gem --version
1.3.5
Most likely you have gem installed in 2 different places, and the user Rails is running as has a different default path than your user, so it is finding a different version of gem.

Resources