Why does my Rails app not see installed gems? - ruby

Running Ubuntu 10, RVM, Passenger and apache2. Trying to configure and get Redmine running.
First, I set my default Ruby binary to /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby. That's the output of which ruby. Output of which gem is /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/gem. I think that side of things is set up properly.
I know Passenger is running, because I'm getting an error screen, with this error:
Error message:
Missing the i18n 0.4.2 gem. Please gem install -v=0.4.2 i18n
Update The error that passenger is producing is coming from the boot.rb file. I went and made a gist of the application's boot.rb file.
When I do check to see if that gem is installed, here's the output.
# gem list
# ... list truncated ...
# i18n (0.4.2)
(full gist of installed gems here)
Really? Let's first make sure passenger.conf is going to the right Ruby installation...
passenger.conf
PassengerRuby /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby
>:| So now, I go onto SSH into the application directory, and what have you, script/server starts normally. I'm a little more than confused. Clearly the Ruby installation that Passenger is configured to has the Gem it says is missing, installed, and additionally, the application doesn't falter on a start up. Which makes me think it's a Passenger problem.

Using RVM with Passenger is a bit complicated, maybe this link about using Ruby and Passenger will help.

Related

sinatra app on localhost via unicorn: syntax error

I have a Sinatra app that I continually upgrade (local only, at the moment). Problem being that I know nothing at all about Ruby — my friend made me the app and it's worked beautifully for over almost a year.
To see the site on localhost, I do this:
bundle exec unicorn -l 9000
I don't understand this, haven't needed to. I know I'm using the unicorn gem to run the app directed at port 9000 (due to an old printer conflict).
Today, I get this error:
in `evaluate': compile error (SyntaxError)
syntax error, unexpected ':', expecting $end
which refers to line 16 of my gem file, the sinatra-contrib gem:
gem "sinatra-contrib", require: "sinatra/reloader"
I've never had this error before. Haven't ever touched the gem file, and it's been working for a year. The only thing I can think I've done recently that may have affected my environment is installing a gemset called Wordless:
rvm use 1.8.7#wordless --create --default && gem install therubyracer sprockets compass coffee-script thor yui-compressor && rvm wrapper 1.8.7#wordless wordless compass ruby
I'd appreciate insights, and hopefully I can start to learn a thing or two about managing ruby gems. Thanks.
You were using Ruby 1.9 before. The line you referenced is in 1.9 format, which Ruby 1.8 does not understand.
When you installed Wordless you said:
rvm use 1.8.7#wordless --create --default
This made Ruby 1.8.7 your default interpreter. To switch back to whatever you used before do:
rvm list rubies
And then:
rvm use [the 1.9.x you found in the list above] --default

How can I restart Ruby after a gem install?

I'm running on Ubuntu. The question is so basic it feels silly but I have done some searching and can't figure out the answer.
Edit: I am running into similar issues as the following
Uninitialized constant using Twitter ruby gem
You don't need to restart Ruby after installing gems. You can for example
gem install rails
and after that you can start running rails (which uses Ruby) right away and no need to restart Ruby.
In Uninitialized constant using Twitter ruby gem link restart means ctr+c that is stop the server and rails s (for rails 3) that is start the server.

Could not find gem 'rubytree (~> 0.5.2) ruby' while installing ChiliProject on Debian

I am trying to install chiliproject on a server, following the -well done- documentation I am hitting this error
Could not find gem 'rubytree (~> 0.5.2) ruby' in any of the gem sources listed in your Gemfile.
I did a gem install rubytree
I get this message
========================================================================
Thank you for installing rubytree.
WARNING: SIGNIFICANT API CHANGE in 0.8.0 !
------------------------------------------
Please note that as of 0.8.0 the CamelCase method names are DEPRECATED.
The new method names follow the ruby_convention (separated by '_').
The old CamelCase methods still work (a warning will be displayed),
but may go away in the future.
Details of the API changes are documented in the API-CHANGES file.
========================================================================
Successfully installed rubytree-0.8.1
1 gem installed
Installing ri documentation for rubytree-0.8.1...
file 'COPYING,API-CHANGES' not found
Installing RDoc documentation for rubytree-0.8.1...
file 'COPYING,API-CHANGES' not found
That is saying the installation was succesful. So why do I get the error ?
If the error is from the API change how can I request version 0.5.2 of the rubytree gem ?
When I do a gem list --local | grep 'rubytree'
I have this output rubytree (0.8.1)
So why is the system saying could not find gem 'rubytree' ?
thank you for any help,
Depending on what version of rails you are using (and it sounds like you are using a relatively newer one, if it's prompting you for your Gemfile), then you need to use Bundler to manage your gems.
Try editing your Gemfile, adding a new line that reads:
gem "rubytree", "< 0.6"
Then open up a console, and type this command
bundle install
This should fix your problems, but if you still get errors when running a command, then try typing bundle exec prior to the command (i.e. rails server becomes bundle exec rails server).
Currently, we require rubytree exactly in version 0.5.2 or 0.5.3, as specified in our Gemfile, the 0.8.1. version you installed by hand will not suffice that requirement, which is exactly what the error message states.
What seems a bit odd is the literal ruby in the error message. Could you please make sure that you have the exact unchanged Gemfile from the source on your system? Also, could you please remove any user-installed plugins and try again? Also, which ruby (type and version) on which operating system are you using?

Having trouble installing Autotest in Rails in Ubuntu 10.10 enviroment

I'm learning how to program in Rails. I'm a complete newbie, and I'm learning from the screen-cast "Rails Tutorial: Learn by Example" by Michael Hartl.
I've been doing pretty well, until I've come to this obstacle, and I don't know how to figure it out. It's a bit frustrating to be frank, and I'd like to move forward with Rails & start making stuff :)
I installed RubyGems 1.8.5 by hitting:
$ gem update --system
and then installed ZenTest gem by hitting:
$ sudo gem install ZenTest
then I installed auto-test rails gem by hitting:
$ sudo gem install autotest-rails
and so got the message
Successfully installed autotest-rails-4.1.0
1 gem installed
Installing ri documentation for autotest-rails-4.1.0...
Installing RDoc documentation for autotest-rails-4.1.0...
So all was lookin' fine and dandy. I navigated to my app folder, and hit
$ autotest
and then got the message
/usr/local/lib/ruby/1.9.1/rubygems.rb:762:in `report_activate_error': Could not find RubyGem ZenTest (>= 0) (Gem::LoadError)
from /usr/local/lib/ruby/1.9.1/rubygems.rb:219:in `activate'
from /usr/local/lib/ruby/1.9.1/rubygems.rb:1065:in `gem'
from /usr/local/bin/autotest:18:in `<main>'
I've tried searching for an answer to why this is happening, but I can't find any. Please help me solve this problem. I'd like to move forward with learning Rails :)
EDIT Maybe I should also mention that I have RSpec installed already -- I don't know if that's of any significance -- giving you a better understanding as to whats going on with my problem -- but I thought I'd just put it out there.
Cheers.
Are you using Rails 3+? If so look for a file called Gemfile inside the rails app root directory. Open it up, add:
gem 'ZenTest'
gem 'autotest-rails'
Save, exit and then run from command line:
bundle
After this try rerunning autotest
I'm at the same point of learning RoR (in this case RoR 3.0.3, Ruby 1.9.2p180, Ubuntu 11.04). I'm also stymied by the lack of consistency. In my case:
$ "You don't have i18n installed in my application. Please add it to your Gemfile and run bundle install".
Gemfile:
gem 'ZenTest'
gem 'autotest-rails'
gem 'i18n'
$bundle install => OK
$bundle show i18n => <ruby path>/gems/i18n-0.6.0
$autotest => (same result)
Any ideas? This is NOT going to help RoR adoption, if it's so obtuse to load a basic TDD environment. (I'll step off my soapbox now.)
try in command line "bundle install"

Installing a gem from Github with Bundler

I am trying to use the instructions here to install a pre-released version of a gem with bundler.
The "bundle install" output lists the gem as getting installed, but "gem list" fails to find it.
My Gemfile:
source :gemcutter
gem 'sinatra', '1.1.0', :git => 'http://github.com/sinatra/sinatra.git'
gem 'RedCloth', '4.2.3'
Here is a gist with the rest of my sample code.
Has anyone gotten this scenario to work?
NOTE: I am also using RVM (on OS X). bundle show does list the gem (and dependencies) as existing, but I am not able to properly resolve them.
Thanks.
I would look at the load paths, and further debug from there, example:
...(master) $ irb
irb(main):001:0> $LOAD_PATH.count
=> 8
irb(main):004:0> require 'bundler/setup'
=> true
irb(main):005:0> $LOAD_PATH.count
=> 112
irb(main):006:0>
Bundler configures the load path for you, this means not all the gems are included on your load path by default.
Additionally, from the bundler git help:
Because Rubygems lacks the ability to handle gems from git, any gems installed from a git repository will not show up in gem list. They will, however, be available after running Bundler.setup.
Best regards, hope this helps
ED
Bundler might have installed it locally to your app. This could vary wildly, depending on OS and whether you are using RVM.
What is the output of bundle show sinatra?
In my case, sinatra was installed here:
/home/marshall/.rvm/gems/ruby-1.8.7-p302#3846859/bundler/gems/sinatra-9cfa74a7f352
Sinatra doesn't show in the gems list, but the server launches correctly if I execute rackup.
Gems installed via bundler on Engine Yard go to a different folder to isolate them.
it's usually /data/APP_NAME/shared/bundled_gems
To be sure, check your .bundle/config file on your APP folder at Engine Yard
It looks like there is an issue using Shotgun and Bundler (git repositories only).
If I use rackup to start up my app, all is well. I am going to investigate a little more and then file a bug with one (or both) of the projects.

Resources