learn-rails bundle install error parsing Gemfile - ruby-on-rails

I'm totally noob, and doing the Learn Ruby On Rails Book One from start. I've got stuck a couple of times, but have resolved it myself by google, stackoverflow, etc... (I don't want to be a burden) But this I can't get by.
I'm on the Gemfile "chapter". First I just tried to copy the exact as it is in the book:
source 'https://rubygems.org' ruby '2.0.0'
gem 'rails', '4.0.1'
# Rails defaults
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0' gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
# learn-rails
gem 'activerecord-tableless'
gem 'compass-rails', '~> 2.0.alpha.0' gem 'figaro'
gem 'gibbon'
gem 'google_drive'
gem 'high_voltage'
gem 'simple_form'
gem 'zurb-foundation'
group :development do
gem 'better_errors' gem 'quiet_assets' gem 'rails_layout'
end
Which gives me this result:
[!] There was an error parsing `Gemfile`: syntax error, unexpected tIDENTIFIER, expecting gem 'rails', '4.0.1'...https://rubygems.org' ruby '2.0.0'
... ^. Bundler cannot continue.
# from /Users/MYUSERNAME/Projects/learn-rails/Gemfile:1
# -------------------------------------------
end 'better_errors' gem 'quiet_assets' gem 'rails_layout'
I then tried to change a few things like versions and so on, like this:
source 'https://rubygems.org'
ruby ’2.3.3’
gem 'rails', ’5.0.1’
# Rails defaults
gem 'sqlite3'
gem 'sass-rails', '~> 5.0’
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2’
gem 'jquery-rails'
gem 'turbolinks’
gem 'jbuilder', '~> 2.5’
# learn-rails
gem 'activerecord-tableless'
gem 'compass-rails', '~> 2.0.alpha.0'
gem 'figaro'
gem 'gibbon'
gem 'google_drive'
gem 'high_voltage'
gem 'simple_form'
gem 'zurb-foundation'
group :development do
gem 'better_errors'
gem 'quiet_assets'
gem 'rails_layout'
end
This gives me this result:
[!] There was an error parsing `Gemfile`: no .<digit> floating literal anymore; put 0 before dot - ruby ’2.3.3’
^
/Users/MYUSERNAME/Projects/learn-rails/Gemfile:2: syntax error, unexpected tFLOAT, expecting '('
ruby ’2.3.3’
^. Bundler cannot continue.
# from /Users/MYUSERNAME/Projects/learn-rails/Gemfile:2
# -------------------------------------------
# source 'https://rubygems.org'
> ruby ’2.3.3’
# gem 'rails', ’5.0.1’
# -------------------------------------------
I've tried a few things I found when searching, like changing the ' to " on the ruby version, putting a '0.2.3.3' or just '.2.3.3', doing a bundle update, etc. I don't know what the the "no . floatin..." means? Or what the "expecting '('" is?
I really have searched and tried various solutions (got like 4-5 different saved "Gemfile" from trying whatever I found on the net).
Sorry if this just takes up space in the interwebs, but I just don't get it. If the original (from the book) doesn't even work, then why is it even there?
(I only changed my personal name to MYUSERNAME here, because it's my full, actual name, and maybe I'm paranoid but may so be. So that is not a fault)
Thanks,
Ethonrails

Make sure you use ' not ’ it's a different kind of apostrophe. (Everywhere in your Gemfile, I see a couple of instances ruby ’2.3.3’, gem 'sass-rails', '~> 5.0’)
Here is a version of your Gemfile that works:
source 'https://rubygems.org'
ruby '2.3.3'
gem 'rails', '5.0.1'
# Rails defaults
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.5'
# learn-rails
gem 'activerecord-tableless'
gem 'compass-rails', '~> 2.0.alpha.0'
gem 'figaro'
gem 'gibbon'
gem 'google_drive'
gem 'high_voltage'
gem 'simple_form'
gem 'zurb-foundation'
group :development do
gem 'better_errors'
# gem 'quiet_assets' (not compatible with rails 5 atm)
gem 'rails_layout'
end
Tip: Try to use a code editor with syntax highlighting for Ruby, that should make future syntax errors easier to spot.

Try to replace ` characters to '

Instead of back quote (`), use single quote (') in your Gemfile.
As you are learning ruby on rails, I would like to suggest this link which may be useful to you, http://guides.rubyonrails.org/getting_started.html

Related

Why is bundler looking for mysql2 -v '0.4.4' --source 'https://rubygems.org/'

Below is my Gemfile but i haven't specified the mysql2 version but for some reason it's looking for 0.4.4. It must be a dependency of another gem. I was just assigned thAny ideas?
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'mysql2', group: :production
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
gem 'active_model_serializers', '~> 0.10.0.rc5'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'acts_as_better_tree'
gem 'rest-client', '~> 1.8'
gem 'apipie-rails', :github => 'Apipie/apipie-rails'
gem 'devise'
gem 'petergate'
gem 'pry-rails'
gem 'annotate'
gem 'slim-rails'
gem 'bootstrap-sass'
gem 'font-awesome-sass'
gem 'carrierwave'
gem 'carrierwave-base64'
gem 'carrierwave-aws'
gem 'authorizenet'
gem 'figaro'
gem 'roo', '~> 2.3.2'
gem 'roo-xls', '~> 1.0'
gem 'mini_magick', '~> 4.5'
gem 'html5shiv-rails'
gem 'cocoon'
gem 'will_paginate'
gem 'wicked_pdf'
gem 'wkhtmltopdf_binary'
gem "minitest-rails"
gem "minitest-reporters"
gem 'airbrake', '~> 5.6'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'capistrano'
gem 'capistrano-passenger'
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-rails-console'
gem 'capistrano-rvm'
gem 'better_errors'
gem 'pry'
end
group :development, :test do
gem 'sqlite3'
gem 'byebug'
end
$ gem dependency mysql2 --reverse-dependencies
It'll list each version of mysql2 and then the gems that depend on that version.
I believe the problem is with the rails version and mysql2 version. Change the Gemfile line that contains gem 'mysql2' to gem 'mysql2', '~> 0.4.0'
I have gem 'rails', '4.2.6' installed but apparently there is some compile error with mysql2 and that version of rails.
"For Rails 4.x please pin the gem to mysql2 '~> 0.4.0'" - sodabrew
After doing this the bundle install ran and I was able to run rails c without errors.

All Heroku Commands Are Broken due to Ruby Version

Everytime I run a heroku command I receive this error:
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.2
This has been happening since I pushed several changes (adding sidekiq and making changes to my clock.rb file, also: a new model I need to migrate the db for)
Does anyone know why this might be happening? It only started after I added ruby '2.1.2' to the gemfile. But before that I was getting this funky segmentation fault error.
Here's my gemfile:
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'clockwork'
gem 'httparty'
gem 'omniauth-facebook'
gem 'parse-ruby-client'
gem 'parse_resource', '~> 1.8.0'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem 'sidekiq'
gem 'foundation-rails'
group :development, :test do
gem 'pry-rails'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'shoulda-matchers'
gem 'valid_attribute'
gem 'capybara'
gem 'dotenv-rails'
gem 'better_errors'
gem 'binding_of_caller'
end
group :production do
gem 'rails_12factor'
gem 'thin'
end
It's seems to related bundler issue. Go through here https://github.com/sstephenson/rbenv/issues/400 same sort of issue also here get fixed with :
# Rakefile
task :freedom do
Bundler.with_clean_env { sh "heroku" }
end
Hope this help you!
I had two applications using Ruby. In your terminal, change to the directory of the application, then check the Ruby version you are using. Update it appropriately.

Gemfile syntax error: when trying bundle install

source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass', '~> 3.0.3.0'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :doc do
gem 'sdoc', require: false
end
// When I try to bundle install --without production I get an error message.
This line looks a bit wrong gem 'bootstrap-sass', '~> 3.0.3.0'
Usually you would expect the semantic versioning to go to three levels only
I suspect the problem isn't being picked up when bundling locally.
The bundle install command installs the gems based on the Gemfile.lock file in your project. Try running a bundle update instead - this may resolve any version conflicts you may be having in your Gemfile (depending on if you've made any updates).

Gemfile:22: syntax error, unexpected tIDENTIFIER, expecting end-of-input

When I run bundle install against the gemfile source below, I get a gemfile syntax error that points to the 'better errors' gem which is the second to last line.
When I run ruby -c Gemfile. I get the following message
Gemfile:22: syntax error, unexpected tIDENTIFIER, expecting end-of-input
gem 'better_errors'
Any ideas?
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
# Rails defaults
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
# learn-rails
gem 'activerecord-tableless'
gem 'bootstrap-sass'
gem 'figaro'
gem 'gibbon'
gem 'google_drive'
gem 'high_voltage'
gem 'simple_form', '>= 3.0.0.r
group :development do
gem 'better_errors'
gem 'quiet_assets'
end 
Thank you for any assistance and time.
You missed the closing ' here :
gem 'simple_form', '>= 3.0.0.r <~~~
group :development do
gem 'better_errors'
gem 'quiet_assets'
end
Corrected
gem 'simple_form', '>= 3.0.0.r'
group :development do
gem 'better_errors'
gem 'quiet_assets'
end
After your version number specification for gem "simple_form":
">= 3.0.0.r\ngroup :development do\n gem "
(which is already invalid), you cannot continue another token better_errors without having a comma (which would be invalid anyway).

Backbone JS and Rails 3.2 Error in Production Server

I got an issue here. I'm working on an app built with Rails and Backbone. In my development environment, everything's run well, but when I deployed it to the production server, this error showed in my firebug :
TypeError: this._reset is not a function
...;return a.success=function(d,e,f){ba.add?"add":"reset",c&&c(b,...
Could anyone help me on this?
Revision 1
I've precompiled the assets and this is my Gemfile :
source 'https://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'devise', '1.5.3'
gem 'friendly_id'
gem 'pry'
gem "paperclip", "~> 2.5.0"
gem "kaminari"
#gem "ckeditor", "3.7.0.rc3"
gem "tinymce-rails"
gem "puma"
gem "tlsmail"
gem "rails-erd"
gem "juggernaut"
gem "thin"
#gem 'execjs'
#gem 'therubyracer'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Anyway, I got this new fact. I tried run the app in production mode in my local machine and it ran well, but not in my server. Is there anything that I forgot to install in my server?
It seems that you install backbone manually.
I recommend using something like backbone-rails gem to help integrating rails and backbone gracefully. Something like https://github.com/codebrew/backbone-rails (there are also other gem around, but codebrew implementation is one of the most popular).
This is to ensure consistent dependency across machines.
Don't forget to read about asset pipeline, most of my problem with js and rails in production comes from my lack of understanding regarding rails 3 asset pipeline: http://guides.rubyonrails.org/asset_pipeline.html
And if you're serious about integrating backbone and rails, https://learn.thoughtbot.com/products/1-backbone-js-on-rails is an indispensable resource (at US$ 49)
EDITED:
This is my typical Gemfile when creating backbone.js & rails app:
group :assets do
gem 'haml-rails', '~> 0.3.4'
gem 'sass-rails', '~> 3.2.5'
gem 'bootstrap-sass', '~> 2.0.3.1'
gem 'compass', '~> 0.12.1'
gem 'compass-rails', '~> 1.0.2'
gem 'coffee-rails', '~> 3.2.2'
gem 'jquery-rails', '~> 2.0.2'
gem 'jquery-ui-rails', '~> 1.1.0'
gem 'handlebars_assets', '~> 0.4.4'
gem 'rails-backbone', '~> 0.7.2'
# javascript
gem 'haml_coffee_assets', '~> 1.2.0'
gem 'execjs', '~> 1.4.0'
gem 'therubyracer', '~> 0.10.1'
gem 'uglifier', '~> 1.2.4'
gem 'yajl-ruby', '~> 1.1.0'
end

Resources