Error Parsing 'Gemfile' - ruby-on-rails

I am working on a learning rails project on
http://railsapps.github.io/installrubyonrails-mac.html
I am on the Rails Example Applications section, but when I run
bundle install --without production
I receive this error:
[!] There was an error parsing `Gemfile`: no .<digit> floating literal anymore; put 0 before dot - ruby ‘2.3.0’
^
/Users/eric.park/workspace/learn-rails/Gemfile:2: syntax error, unexpected tFLOAT, expecting '('
ruby ‘2.3.0’
^. Bundler cannot continue.
# from /Users/eric.park/workspace/learn-rails/Gemfile:2
# -------------------------------------------
# source 'https://rubygems.org'
> ruby ‘2.3.0’
# gem 'rails', '4.2.5'
# -------------------------------------------
I am new to rails, so if anyone can explain what this error generally means, and how I can address it if it shows up again that would be really helpful.

It is the quotation problem.
Try manually typing the sentence again with either single quote or double quote.
ruby '2.3.0' or ruby "2.3.0"
This should fix it.

I found that if you copy and pasted code into a Gemfile that you say, created with textedit, unidentified syntax and formatting are also inherent with the copy, and therefore my solution was to open a completely blank document, or write it direct in VIM etc, and type from scratch - do not copy and paste code, otherwise you risk copying over unintentional formatting and imbedded syntax that you might not be able to see.

Related

Bundler is deprecating bundle console in favor of bin/console. Can anyone provide more clarity as to how bin/console should work?

I have a custom ruby gem that relies heavily on bundle console. Nothing special or fancy, just an interactive console with the set of gems defined by the Gemfile included. We use the console a lot during development.
Currently when I run the command, I receive the following deprecation message:
[DEPRECATED] bundle console will be replaced by bin/console generated by bundle gem <name>
Digging around in the bundler docs I found the following explanation:
The bundle console will be removed and replaced with bin/console.
Over time we found bundle console hard to maintain because every
user would want to add her own specific tweaks to it. In order to
ease maintenance and reduce bikeshedding discussions, we're removing
the bundle console command in favor of a bin/console script
created by bundle gem on gem generation that users can tweak to
their needs.
Can anyone with knowledge provide a more detailed explanation? This gem currently does not have a bin directory. I'm happy to make one, I'm just not sure what should be in the file. Running bundle gem as described in the note above raises an error (as expected).
This is the file that is generated at bin/console:
#!/usr/bin/env ruby
require "bundler/setup"
require "(your gem name here)"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"
IRB.start(__FILE__)
You can see the template in the rubygems GitHub repo.

I am trying to run rails server and a, coming up this this error

I am creating a rails app with a course called one month rails. Everything was working just fine until I came across this error.
[!] There was an error parsing Gemfile: syntax error, unexpected <<, expecting end-of-input - <<<<<<< HEAD
^. Bundler cannot continue.
Just put a carriage return after gem 'jquery-rails'
The error is showing that the bundle tried to read the gemfile line by line and picks up the specified gems and install it in our system. But it faces a syntax error when we provided wrong set of arguments to gem specification.
We need to hit end line and it will work fine.
gem 'jquery-rails'
gem 'turbolinks'
I hope it will fix your problem.

Gem for formatting rails source code

Is there a gem I can install that creates a rake task that, when run, beautifies up my ruby code? Indentation, rouge line breaks, that sort of thing?

How to modify the gemfile? (marshal data too short)

I'm trying to install rails but I get a "marshal data too short" error. I read in this question ( bundle update fails : marshal data too short ) that I can update the Gemfile to make it work.
My problem is that I really have no idea how to modify this "Gemfile".
Thx.
Damn, it was so simple... to update the gemfile, you only got to execute these two command lines:
gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
Then you can execute your installation normally:
gem install rails
Go to the root of your application, and look for Gemfile. The root of the application is where you run rails server from, in case you were wondering :)
Open Gemfile using your favorite text editor, and try changing the rubygems source from HTTP to HTTPS.
Locate the following:
source 'http://rubygems.org'
Replace it with:
source 'https://rubygems.org'
You might want to check out this thread: Marshal data too short

ExecJS coffee script not showing line numbers for compile errors (Rails asset pipeline)

In one of my Rails apps, ExecJS is not showing line numbers for coffeescript compilation errors. My compile error message will look like this:
ExecJS::RuntimeError in Referrals#new
Showing ~/MyApp/app/views/layouts/application.html.erb where line #6 raised:
SyntaxError: unexpected IDENTIFIER
(in ~/MyApp/assets/javascripts/utils.js.coffee)
Note that there's no line number for the coffee script source (line #6 is for the erb file).
On another one of my apps, where I'm still getting the line numbers, a syntax error looks like this:
ExecJS::ProgramError in Projects#show
Showing ~/OtherApp/app/views/layouts/application.html.erb where line #17 raised:
Error: Parse error on line 6: Unexpected 'STRING'
(in ~/OtherApp/app/assets/javascripts/projects.js.coffee)
So it seems the difference is that ExecJS::ProgramError will give me the line numbers, where as ExecJS::RuntimeError will not.
Anyone have any idea how to get the line numbers back? Why is my app creating RuntimeErrors on coffee asset compilation, while the other is giving ProgramErrors? I've checked Rails and they seem to match.
Note that if I fix the compilation errors, the app runs fine (e.g., the coffee files are actually do get compiled) -- but it'd be nice to have those line numbers point me to the compilation errors!.
EDIT
I realized that whether it's an ExecJS Runtimeerror or a ProgramError doesn't seem to matter -- in the first app, there's never a line number given and in the second, there always is.
I figured it out -- it's due to the coffee-script-source gem version. In the app that was giving line numbers, bundle show gives coffee-script-source of 1.4.0, whereas the other app had a coffee-script-source version of 1.6.1.
I didn't notice this because the coffee-rails gem doesn't tightly specify this dependency (in both my Gemfiles, I was using gem 'coffee-rails', '3.2'). To get around this, just explicitly specify the coffee-script-source gem version:
gem 'coffee-rails', '3.2.2'
gem 'coffee-script-source', '1.5.0'
and bundle update coffee-script-source.
Hopefully this helps anyone else who might run into this discrepancy.
This can also be fixed with this patch that embeds the line information in the error message for the ruby-coffee-script gem.
If you're using source maps, this patch fixes the coffee-rails-source-maps gem.

Resources