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
EDIT:
False alarm.
I was able to resolve the issue. Apparently I was to sudo happy and that broke the install of the gem.
I had to gem uninstall padrino, then gem install padrino.
Now it works flawlessly.
BTW, padrinorb is shaping up to be a nice balance between Sinatra and Rails.
// original post below:
Not sure what I did wrong.
I'm trying to test out Padrino, however I'm running into an issue straight away.
I'm following the steps starting with sudo gem install padrino adding sudo for good measure.
Then following along I did padrino g project myapp -d datamapper -b as their site states.
The problem is that it returns an error, so I decided to just run padrino as is with no args.
Error as well (it's long):
$ padrino
/Users/viper1092/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find padrino-core (>= 0) amongst [RedCloth-4.2.9, RedCloth-4.2.8, actionmailer-3.2.3, actionpack-3.2.3, activemodel-3.2.3, activerecord-3.2.3, activeresource-3.2.3, activesupport-3.2.3, addressable-2.2.7, albino-1.3.3, arel-3.0.2, blankslate-2.1.2.4, builder-3.0.0, bundler-1.1.3, bundler-1.0.22, chunky_png-1.2.5, chunky_png-1.2.1, classifier-1.3.3, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.3.1, compass-0.12.1, compass-0.11.5, crack-0.1.8, daemons-1.1.3, directory_watcher-1.4.1, directory_watcher-1.4.0, erubis-2.7.0, eventmachine-0.12.10, execjs-1.3.0, faraday-0.7.6, fast-stemmer-1.0.1, fast-stemmer-1.0.0, ffi-1.0.11, ffi-1.0.9, fssm-0.2.9, fssm-0.2.7, haml-3.1.4, haml-3.1.2, heroku-2.24.1, heroku-2.20.1, hike-1.2.1, httparty-0.7.8, i18n-0.6.0, jekyll-0.11.2, jekyll-0.11.0, journey-1.0.3, jquery-rails-2.0.2, json-1.6.6, json-1.5.4, koala-1.3.0, kramdown-0.13.5, kramdown-0.13.3, launchy-2.1.0, launchy-2.0.5, liquid-2.3.0, liquid-2.2.2, mail-2.4.4, maruku-0.6.0, mime-types-1.18, mime-types-1.17.2, multi_json-1.2.0, multi_json-1.0.3, multipart-post-1.1.5, netrc-0.7.1, polyglot-0.3.3, posix-spawn-0.3.6, pygments.rb-0.2.11, pygments.rb-0.1.3, rack-1.4.1, rack-1.3.2, rack-cache-1.2, rack-protection-1.2.0, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.2.3, railties-3.2.3, rake-0.9.2.2, rake-0.9.2, rb-fsevent-0.9.1, rb-fsevent-0.4.3.1, rdiscount-1.6.8, rdoc-3.12, rest-client-1.6.7, rubypants-0.2.0, rubypython-0.5.3, rubypython-0.5.1, rubyzip-0.9.7, rubyzip-0.9.6.1, sass-3.1.15, sass-3.1.5, sass-rails-3.2.5, sinatra-1.3.2, sinatra-1.2.6, sprockets-2.1.2, sqlite3-1.3.5, stringex-1.3.2, stringex-1.3.0, syntax-1.0.0, term-ansicolor-1.0.7, thin-1.2.11, thor-0.14.6, tilt-1.3.3, tilt-1.3.2, treetop-1.4.10, tzinfo-0.3.33, uglifier-1.2.4] (Gem::LoadError)
from /Users/viper1092/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/viper1092/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
from /Users/viper1092/.rvm/rubies/ruby-1.9.2-p290/bin/padrino:18:in `<main>'
Then if I take a look at gem list:
$ gem list
*** LOCAL GEMS ***
polyglot (0.3.3)
posix-spawn (0.3.6)
pygments.rb (0.2.11, 0.1.3)
Those are the only "p"s I have.
When I ran sudo gem install padrino initially:
Successfully installed padrino-mailer-0.10.6
Successfully installed bundler-1.1.3
Successfully installed padrino-gen-0.10.6
Successfully installed padrino-cache-0.10.6
Successfully installed padrino-admin-0.10.6
Successfully installed padrino-0.10.6
21 gems installed
I'm on Mac OS X 10.7.3 running RVM 1.10.2 with ruby 1.9.2 selected.
I've tried just gemming Padrino 3 times as gem install padrino with no sudo just for fun and it reports that it installs, but padrino (with or without args) fails with same error. Again, running gem list does not mention padrino or padrino-core.
Any advice?
(I have the full verbosity and it's quite lengthy)
I was able to resolve the issue. Apparently I was to sudo happy and that broke the install of the gem.
I had to gem uninstall padrino, then gem install padrino.
Now it works flawlessly.
I suppose sudo installing changes some system-wide /usr deal, idk.
Thanks if you looked over my question.
BTW, padrinorb is shaping up to be a nice balance between Sinatra and Rails.
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"
-- UPDATE --
Ok its fixed. This is what I did. remove all ruby and rubygems completely. then install ruby1.9.1-full and rubygems1.9.1 then install the twitter gem.
Hi guys,
I am having trouble working with the Twitter gem. I am using ruby 1.8.7
After installing when I try to run a simple script I get this error
ruby twitter.rb
./twitter.rb:5: uninitialized constant Twitter (NameError)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from twitter.rb:2
I running this on a Ubuntu box. I checked with gem -list and I see the Twitter (1.1.0) is listed there.
this is the code I am trying to run
require "rubygems"
require 'twitter'
puts Twitter.user_timeline("test").first.text
Any ideas ?
I believe it only works with Ruby 1.9 If you want to use twitter gem try version 0.9 with Ruby 1.8.x
This works for me:
ruby-1.9.2-p0 > require 'twitter'
=> true
ruby-1.9.2-p0 > puts Twitter.user_timeline("test").first.text
TExES Pedagogy and Professional Responsibilities EC-12 Teacher Certification Test Prep Study Guid… - by Sharon A Wynne http://amzn.to/f3kF74
=> nil
which version of ruby are you using?
gouravtiwari21's comment seems to fix the problem, but it's wrong to suggest that the twitter gem requires 0.9.0 if you want to run it using Ruby 1.8.x.
You can check out the version compatibility here:
http://travis-ci.org/#!/jnunemaker/twitter
It shows the twitter gem working with Ruby installs as low as 1.8.7.
For me, it was an issue with having the correct dependent gems, as well as the correct versions.
Here's how I got it working:
I ran:
sudo gem list
And compared the versions of specific gems with what I found here:
https://github.com/jnunemaker/twitter/blob/master/HISTORY.md (I simply searched for the word 'dependency' to see which versions twitter cared about.
I also found this diff:
https://github.com/jnunemaker/twitter/commit/ac8114c1f6ba2da20c2267d3133252c2ffc6b6a3
And I compared the gems listed there with what I had installed, and I just made sure my system lined up with what I was seeing in the version notes. Oftentimes what happened is that I had multiple versions of a gem, and for some reason, the lower version was taking precedence.
I'm not sure why I still have to add
gem 'twitter', '1.7.1'
to my Gemfile, but alas, that's the last step required in order to get this stuff working.
Don't forget to restart your server, and you should be good!
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.