sinatra app on localhost via unicorn: syntax error - ruby

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

Related

etc.bundle => warning: already initialized constant

When I run Ruby scripts, I get 157 lines of warning messages like this:
/Users/clay/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/x86_64-darwin19/etc.bundle: warning: already initialized constant Etc::SC_AIO_LISTIO_MAX
/Users/clay/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/x86_64-darwin19/etc.bundle: warning: already initialized constant Etc::SC_AIO_MAX
/Users/clay/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/x86_64-darwin19/etc.bundle: warning: already initialized constant Etc::SC_AIO_PRIO_DELTA_MAX
... lots more
After some digging, it seems like the Ruby/gem/bundle industrial complex is using both the RVM version of Ruby 2.6.3 and the macOS system version of 2.6.3 in order to resolve the etc gem.
My hard-won quick-fix is to uninstall the rvm-ruby's etc gem, like:
rvm use 2.6.3
gem uninstall etc
However, anytime I initiate a gem update on this version of Ruby, etc will get reinstalled, and I'm back to a torrent o' warnings. I cannot get the system-ruby to uninstall etc at all.
Is there a more permanent fix?
Deets:
rvm 1.29.9
macOS Catalina 10.15.2
It appears I can suppress installing the etc gem in my Gemfile, like this:
source 'https://rubygems.org'
ruby '2.6.3'
gem 'cocoapods', '1.9.1'
# ... other gems
gem 'etc', :require => false
Because the system etc gem is already, um, "on the path", it all seems to work for now, but yikes, do not like.

How to use Susy2 with Compass / SASS?

I'm trying to figure out how to get Susy2 working alongside compass on my local system, and I've been all over trying to find the answer.
error sass/screen.scss (Line 4 of sass/_base.scss: File to import not found or unreadable: susy.
Load paths:
/Users/jem/Desktop/base/sass
/usr/local/lib/ruby/gems/2.1.0/gems/compass-core-1.0.0.alpha.21/stylesheets
/Users/jem/.compass/extensions/compass-normalize/stylesheets
/Users/jem/.compass/extensions/compass-recipes-master/stylesheets
/Users/jem/.compass/extensions/toolkit/stylesheets
/usr/local/lib/ruby/gems/2.1.0/gems/sassy-maps-0.4.0/sass
/usr/local/lib/ruby/gems/2.1.0/gems/breakpoint-2.4.2/stylesheets
Compass::SpriteImporter
Sass::Globbing::Importer)
ArgumentError on line ["161"] of /usr/local/lib/ruby/gems/2.1.0/gems/sass-3.3.3/lib/sass/error.rb: wrong number of arguments (1 for 2)
Run with --trace to see the full backtrace
I hit this error continually (although occasionally for other gems as well). I feel like I've tried every combination of installing and uninstalling gems, ruby, bundler, etc.
Instructions continually point me toward:
Using Bundler to manage the gems (I am).
Make sure require "susy" is in my config.rb (Yup.)
Make sure I'm on the new alpha version of compass (using 1.0.0.alpha.20)
I'm not having any luck, and I can only assume it's something going on with my local system (OS 10.9, using Ruby 2.1.2 with RVM to stay separate from the system ruby). I had susy working once on a separate linux box, but when I brought the code here I keep running into these susy issues.
If you are using Bundler, your Gemfile should include:
gem "susy", "~>2.1.0"
gem "sass", "~>3.3.0"
gem "breakpoint", "~>2.4.0"
Bundler should set up all the other dependencies you need.
Since you are using RVM for your Ruby installation, are you sure that you are using the default Ruby (as per RVM) or the system Ruby which might be only Ruby 1.8.7 (rather than Ruby 2.0)?

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"

Why does my Rails app not see installed gems?

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.

Rspec bundle is broken in TextMate and rvm

I've had a difficult time since I started using rvm. I've done all the rvm/textmate set up and have the latest bundles but I still can't run Rspec test from textmate.
I have the latest bundle from github.com/rspec/rspec-tmbundle.git
and it's installed in ~/Library/Application\ Support/TextMate/Bundles/
RSpec.tmbundle
RVM default is using the system ruby 1.8.6
Rspec gem versions
gem list --local | grep spec
blue_light_special (0.2.0)
rspec (2.2.0)
rspec-core (2.2.1, 2.0.1)
rspec-expectations (2.2.0, 2.0.1)
rspec-mocks (2.2.0, 2.0.1)
rspec-rails (2.0.1, 1.3.2)
TextMate
TM_RUBY=/Users/jspooner/.rvm/bin/rvm-auto-ruby
The Error: rspec/core (LoadError)
/Users/jspooner/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/rspec/mate.rb:29:in require': no such file to load -- rspec/core (LoadError) from /Users/jspooner/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/rspec/mate.rb:29 from /tmp/textmate-command-8073.rb:2:inrequire' from /tmp/textmate-command-8073.rb:2
The best solution I've found is from Jacques Crocker.
http://groups.google.com/group/rubyversionmanager/browse_thread/thread/64b84bbcdf49e9b?fwc=1
It requires replacing the contents of textmate_ruby with the code below and never running rvm wrapper xxx textmate again.
#!/usr/bin/env sh
source ~/.rvm/scripts/rvm
cd .
exec ruby "$#"
This has also fixed the same issue with the cucumber bundle.
Did you try following the instructions here: http://rvm.io/integration/textmate/
My case is slightly different but took me more than an hour to figure out:
Turns out I ran rvm wrapper ree textmate a while after installing ree with rvm and in the mean time the ree shorthand changed from meaning ree-1.8.7-2010.01 to ree-1.8.7-2010.02
here's more details on my message:
https://gist.github.com/721987
I'm posting it here too because it's one of the first pages I landed onto while trying to figure this one out.
I've got a similar problem and figured out that my textmate ruby wrapper is pointing to a different version. I was able to get it work by putting below content in projectx/.rvmrc
rvm 1.9.2#projectx --create
rvm wrapper 1.9.2#projectx textmate
Hope this helps.

Resources