Fresh Rails 3.1 install failing...uninitialized constant JSON::ParserError - rvm

I am using RVM and have installed rails 3.1.0 multiple times but once I begin using it I get the same error over and over again.
From a fresh install of rails 3.1.0 I do the following:
rails new fishapp
cd fishapp
bundle install
rails g scaffold Fish name:string
bundle exec rake db:migrate
But each time I go to http://localhost:3000/fish I get:
Showing /Users/me/code/rails31/fishapp/app/views/layouts/application.html.erb where line #6 raised:
uninitialized constant JSON::ParserError
(in /Users/me/code/rails31/fishapp/app/assets/javascripts/fish.js.coffee)
Extracted source (around line #6):
3: <head>
4: <title>Fishapp</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
I must have broke something trying to get rails installed or something as I don't otherwise understand why it would fail of a fresh install. Any ideas?

Initially I simply commented out line #6 (just so I could keep working).
<%#= javascript_include_tag "application" %>
Eventually I needed javascript, so I had to return to this issue. I kept the line above commented out, and just hard-coded this one immediately below it:
<script src="/assets/application.js" type="text/javascript"></script>
The page loaded fine, so I viewed the page's source, and looked at
http://0.0.0.0:3000/assets/application.js
... only to find a similar error:
throw Error("NameError: uninitialized constant JSON::ParserError
(in /Users/me/Dev/fishapp/app/assets/javascripts/products.js.coffee)")
So I decided to load a rails console and see if I could load the JSON gem, but got an error with iconv:
ruby-1.9.2-p290 :001 > require 'json'
LoadError: no such file to load -- iconv
Meanwhile loading the rails gem produced:
ruby-1.9.2-p290 :004 > require 'rails'
=> false
So I searched around and found this:
http://beginrescueend.com/packages/iconv/
Follow those instructions, and your problem will be resolved! For the record, those instructions are:
rvm pkg install iconv
rvm remove 1.9.2
rvm install 1.9.2 --with-iconv-dir=$rvm_path/usr
I'm leaving the steps I took in case others search Google for similar errors.

You could try to do some of these to see if it helps,
Check your Gemfile to ensure you have gem coffee script there.
Check your Gemfile.lock file to make sure all your dependencies are satisfied. You should probably have multi_json under activesupport.
You could also try to doing an rvm get head before installing rails 3.1 and doing your bundle install to see if that helps.

Related

use forked version of a gem - rails 3.020 & ruby 1.9.2

I am trying to use this fork of a gem:
https://github.com/hoyaemt/capistrano-syntax-checking
In my gemfile I have:
gem "capistrano-syntax-checking", :git => "git://github.com/hoyaemt/capistrano-syntax-checking.git"
When I run bundle install, I get:
Could not find gem 'capistrano-syntax-checking (>= 0) ruby' in git://github.com/hoyaemt/capistrano-syntax-checking.git (at master).
Source does not contain any versions of 'capistrano-syntax-checking (>= 0) ruby'
I have read a bunch of postings but nothing I try seems to work here. Any ideas?
thanks
Joel
The original version is missing the gemspec file. It may be missing other things but I was able to get the bundler to run.
Add a gemspec file to the root of your fork. See here for a simple example and just create capistrano-syntax-checking.gemspec file.

require gem issue

I have installed google api client with the following code and it installed successfuly.
gem install google-api-client
I am using rails 3.0.3 so i also included the above line bundler and ran bundle install which went successfully.
I have also rvm installed. And created a gemset.
And when I run the following command in the terminal:
gem environment | grep INSTALLATION | awk '{print $4}'
It gives me the following result
/home/jamal/.rvm/gems/ruby-1.9.3-p194
When i try to execute the following code in scintilla outside the project directory. It gives me an error.
require 'rubygems'
require 'google/api_client'
ERROR:
usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- google/api_client (LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
What is the main reason of this kind of error?
Possible chances are your editor does not loading the specific gemset in which you install the gem.
Please provide output of gem list google-api-client -d in your questions. So that I can figure it out exactly what is going one.
EDIT:
Another issue which usually occurs are the dual installation of ruby. When we do have a system level installation and a rvm installation, many editor got confused in it. They load up original system installed ruby which do have prefixes like 1.8.7, 1.9.1and available in /usr/share/bin/. Where was you had installed the gem in rvm profile. To overcome this problem you must run your code from terminal after choosing the right gemset
I had that google/api_client (LoadError) message but, it concerned another Google gem.
gem 'google_drive', '~> 0.3.10'
gem 'google-api-client'
I just removed the , '~> 0.3.10' part in case of it was a compatibility problem. That did the trick:
Using google-api-client 0.7.1 (was 0.9.4)
Installing google_drive 1.0.6 (was 0.3.11)

thoughtbot / paperclip Gem installation

Im not going to start by saying i'm a newbie etc. Jokes, been learning Rails for nearly month using Lynda.com. I use Mac, Mac OS X Lion 10.7.
I am trying to intall Paperclip Gem but i can't seem to figure out what i'm doing wrong.
I followed the instructions on https://github.com/thoughtbot/paperclip/wiki/Installation
I added this line to my config/environment.rb
config.gem 'paperclip', :source => 'http://rubygems.org'
and i then tried to run
rake gems:install
I get an error message:
(in /Users/fred/Ruby/food)
rake aborted!
undefined local variable or method `config' for main:Object
/Users/fred/Ruby/food/Rakefile:4:in `require'
(See full trace by running task with --trace)
I then tried the following as an alternative when the above failed
script/plugin install git://github.com/thoughtbot/paperclip
I get the following error
-bash: script/plugin: No such file or directory
My question is how do install this gem? I have read a lot of other posts that say i should include gem 'paperclip', "~> 2.3" is this the same as what i did above?
Best to use bundler. Steps are
Install bundler: gem install bundler
Add to Gemfile: config.gem 'paperclip'
cd to where the Gemfile is and run: bundle install. This will install all the gems mentioned in the Gemfile
Ps. I assume that you are not using rvm. Also, you may need to prefix sudo to the command in step 1 above in case the command does not work for you due to a permission problem.

Rails 3.1 engine rake task doesnt work

I created a new engine with Rails 3.1.rc1
➜ (ruby-1.9.2-p180#rails3-pre) rails git:(master) be bin/rails plugin new ../first_engine --mountable
rails g scaffold project title:string
Scaffold is generated and now when I run
bundle exec rake db:migrate
I get the following error:
rake aborted!
Don't know how to build task 'app:db:migrate'
Tasks: TOP => db:migrate
Before rc1, it was working. But what happened now? I couldn't figure it out!
Here is the gist with all the steps and backtraces https://gist.github.com/990641
Can anyone put me the right direction?
In you Gemfile or RVM Global Gemset file. Change rake to include the version. e.g.
gem 'rake', '0.8.7'
Just using rake will not work until Rails comes out with a fix. Let us know how you get on. All the best.

ruby on rails gem error - No such file to load

I am trying to use the koala gem per these instructions: https://github.com/arsduo/koala/wiki
I did a gem install koala. I see the gem in the list of installed gems.
The instructions say to add
require 'rubygems'
require 'koala'
It doesn't say where. I tried it to add the lines to the beginning of one of my controllers.
Then I also tried it in the initializer file:
C:\Documents and Settings\mtariq\blog\config\initializers\koala.rb
I always get the same error:
no such file to load -- koala
I installed the gem.. so what 'file' is it trying to load?
Any help would be appreciated. I know I must be doing something stupid but can't find any clues.
Mariam
Assuming you are running rails 3, just add the koala gem to your Gemfile, then run 'bundle install'. No need to require any library.
# Gemfile
gem 'koala'