error in your Gemfile, and Bundler cannot continue - ruby-on-rails

I just setup my mac for development and used this exact gemfile previously and it worked fine. I am not sure what I am doing wrong.
Victorias-MacBook-Pro:sample_app Victoria$ bundle --without production
/Users/Victoria/Sites/sample_app/Gemfile:38:in `evaluate': compile error
/Users/Victoria/Sites/sample_app/Gemfile:28: syntax error, unexpected ':', expecting kEND
gem 'cucumber-rails', '1.2.1', require: false
^ (SyntaxError)
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/definition.rb:18:in `build'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:135:in `definition'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/cli.rb:220:in `install'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor/task.rb:22:in `send'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor/task.rb:22:in `run'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor.rb:263:in `dispatch'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor/base.rb:386:in `start'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/bin/bundle:13
/usr/bin/bundle:19:in `load'
/usr/bin/bundle:19
There was an error in your Gemfile, and Bundler cannot continue.
This is the gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'jquery-rails', '2.0.0'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.5'
group :development, :test do
gem 'mysql2'
gem 'rspec-rails', '2.9.0'
gem 'guard-rspec', '0.5.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '1.4.0'
gem 'cucumber-rails', '1.2.1', require: false
gem 'database_cleaner', '0.7.0'
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
# gem 'rb-fsevent', '0.4.3.1', require: false
# gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end

You're running Ruby 1.8 and the syntax attribute: requires ruby 1.9. You will need to change
gem 'cucumber-rails', '1.2.1', require: false
to
gem 'cucumber-rails', '1.2.1', :require => false
Or install Ruby 1.9 (maybe using RVM or rbenv) and run bundle install again. This would be a much bettter option if it's a new project.

I got the same error after updating up my Ruby/Rails environment.
gem update bundler fixed it.

I just had a similar issue while using rvm. Here is what worked for me:
Check to see what version of rails you are using with rvm (in terminal):
ruby -v (in my case opened a new terminal with version set to ruby 1.8.7, yours may not be)
Switch to the correct ruby version (In my case it should be ruby 2.1.1, yours may not be):
rvm 2.1.1 (this sets the ruby version to 2.1.1, replace with your project's ruby x.x.x)
Try re-running bundle check:
bundle check
You should get:
The Gemfile's dependencies are satisfied

The above-mentioned answers did not work for me, but commenting out capistrano gems in the Gemfile did.

If you are using RVM, check which gemset you are using: rvm current.
If it says, for example, system, you may need to select the correct gemset (I did). Use rvm list gemsets if you can't remember what it's called, then select the correct gemset using rvm use [correct gemset].

I had an error similar to this but a bit more specific,
An error occurred while installing safe_yaml (1.0.5), and Bundler cannot continue
In this case, we have to install 'safe_yaml' as
gem install safe_yaml
The answer by #weiphi (https://stackoverflow.com/a/16820392/7668403) could help in such case if need to upgrade.

Related

Syntax error when i run 'rake db:setup' while using ruby 1.9.3

I get a syntax error when i try to run 'rake db:setup'. I didn't face any problems when i ran 'bundle install' I'm trying to get the Typo app (from the saasbook) running. I'm using Ruby 1.9.3 and rails '3.0.10'
ubuntu:~/environment/typo (master) $ rake db:setup
/home/ubuntu/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:24:in `eval': /home/ubuntu/.rvm/rubies/ruby-1.9.3-p551/bin/rake:4: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '(' (SyntaxError)
exec "$bindir/ruby" -x "$0" "$#"
^
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:24:in `<main>'
This is my Gemfile
env = ENV["RAILS_ENV"] || 'development'
dbfile = File.expand_path("../config/database.yml", __FILE__)
source 'https://rubygems.org'
ruby "1.9.3"
gem 'thin'
gem 'rails', '~> 3.0.10'
gem 'require_relative'
gem 'htmlentities'
gem 'json'
gem 'bluecloth', '~> 2.1'
gem 'coderay', '~> 0.9'
gem 'kaminari'
gem 'RedCloth', '~> 4.2.8'
gem 'addressable', '~> 2.1', :require => 'addressable/uri'
gem 'mini_magick', '~> 1.3.3', :require => 'mini_magick'
gem 'uuidtools', '~> 2.1.1'
gem 'flickraw-cached'
gem 'rubypants', '~> 0.2.0'
gem 'rake', '~> 0.9.2'
gem 'acts_as_list'
gem 'acts_as_tree_rails3'
gem 'recaptcha'
gem 'pg'
group :development, :test do
gem 'ruby-debug19'
gem 'factory_girl', '~> 2.2'
gem 'webrat'
gem 'rspec-rails', '~> 2.0'
gem 'simplecov', :require => false
# gem 'sqlite3'
gem 'cucumber'
gem 'cucumber-rails', :require => false
gem 'cucumber-rails-training-wheels'
gem 'database_cleaner'
gem 'capybara'
end
How do i resolve this?
There is a problem with rake. Reinstall rake using the same version specified in the Gemfile can solve the problem.
gem install rake -v 0.9.2
Ruby(1.9.3) on Rails(3.0.10) is not compatible with Postgresql 10. You have to use Postgresql 9 or a lower version with Rails 3. I was running the app on AWS Cloud9 - Ubuntu 18. By default sudo apt-get install postgresql will install postgresql 10. So using an older version might work.
PS - Switching to AWS Linux from Ubuntu and running the app worked.

Error while running bundle install in CentOS

I am getting the following error while running bundle install. I am getting this error while installing i18n gem. I am getting this error in Cent OS machine only.I didn't get this error in Windows machine.
[root#centos5_9 IDEA]# bundle install
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
System.java:-2:in `arraycopy': java.lang.ArrayIndexOutOfBoundsException
from DefaultResolver.java:111:in `makeTime'
from DefaultResolver.java:277:in `create'
from DefaultResolver.java:317:in `handleScalar'
from DefaultResolver.java:435:in `orgHandler'
from DefaultResolver.java:455:in `node_import'
from org/yecht/ruby/DefaultResolver$s_method_1_0$RUBYINVOKER$node_import.gen:65535:in `call'
from CachingCallSite.java:146:in `call'
from RubyLoadHandler.java:40:in `handle'
from Parser.java:300:in `addNode'
from DefaultYAMLParser.java:676:in `yyparse'
from Parser.java:290:in `yechtparse'
from Parser.java:284:in `parse'
My gem file contains following code.
source 'http://rubygems.org'
gem 'rails', '3.2.13'
gem "xml-simple", "=1.0.12"
gem "fastercsv", "=1.5.3"
gem "hpricot", "=0.8.2"
gem "newrelic_rpm", "=3.1.1"
gem "mime-types", "=1.16"
gem "writeexcel", "=0.6.4"
gem "i18n"
#gem "warbler","=1.3.0"
gem "rmagick4j","=0.3.7"
gem "starling","=0.10.1"
gem "jruby-memcache-client","=1.7.0"
gem "tzinfo","=0.3.29"
gem "jruby-jars","=1.5.6"
gem "jruby-rack","=1.0.5"
gem "activerecord-jdbc-adapter","=1.2.9"
gem "activeresource","=3.2.13"
gem "activesupport","=3.2.13"
gem "bouncy-castle-java","=1.5.0147"
gem "bundler","=1.3.5"
gem "columnize","=0.3.2"
gem "eventmachine","=0.12.10"
gem "jdbc-mysql"
gem "jruby-openssl","=0.8.8"
gem "jruby-prof","=0.1.0"
gem "memcache-client","=1.8.5"
gem "rack","=1.4.5"
gem "rake","=0.8.7"
gem "rspec","=1.3.0"
# gem "ruby-debug-base","=0.10.3.2"
gem "rubyzip","=0.9.4"
gem "sources","=0.0.1"
gem "mogli","=0.0.25"
gem "facebooker2","=0.0.8"
gem "json","=1.5.1"
gem "multi_json","=1.0.3"
gem "net-ldap", "=0.2.2"
gem "multi_xml","=0.4.1"
gem "httparty","=0.8.1"
gem 'exception_notification', :require => 'exception_notifier'
gem 'safe_attributes'
gem 'will_paginate'
gem 'delayed_job_active_record'
gem "daemons"
gem 'jruby-rack-worker', :platform => :jruby, :require => nil
#gem "ffi", "~> 1.9.0"
#gem 'spoon'
gem "resque"
# 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 'therubyrhino'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
platforms :jruby do
# gem "ruby-debug", "= 0.10.3"
# This is needed by now to let tests work on JRuby
# TODO: When the JRuby guys merge jruby-openssl in
# jruby this will be removed
#gem "jruby-openssl"
group :db do
gem "activerecord-jdbcmysql-adapter", "=1.2.9"
end
end
I am using rails 3.2.13.Please help us on this.
Thanks,
Initially reinstall the bundler at root or set up the ruby and rails environment:-
$ gem install bundler / brew gem install bundler
$ rvm use <ruby/jruby version>#<rails_version> if you are using rvm
Now go in your application directory and then run
$ bundle install
$ bundle update ( to get the latest version gem )
and you can try https://rubygems.org # some time it will work

cannot load railtie after upgrade to rails 4 per ruby.railstutorial.org

OS is Ubuntu 12.04, 64 bit.
New to rails. Relatively new to Ruby. Following the ruby.railstutorial.org tutorial, chapter 3.
The tutorial has been updated to use ruby 2.0.0 and Rails 4.0.0.rc1. Previously the gemfile was specifying Rails 3.2.13 and not specifying Ruby version. After moving to the latest Gemfile in the tutorial, ruby 2.0.0 and Rails 4.0.0.rc1, I'm getting the following error when running rails commands. Example here is rails server
user#machine:~/bin/railslearn/sample_app$ rails server
/home/paul/bin/railslearn/sample_app/config/application.rb:7:in `require': cannot load such file -- active_resource/railtie (LoadError)
from /home/paul/bin/railslearn/sample_app/config/application.rb:7:in `<top (required)>'
from /home/paul/.rvm/gems/ruby-2.0.0-p195#railstutorial_rails_4_0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:78:in `require'
from /home/paul/.rvm/gems/ruby-2.0.0-p195#railstutorial_rails_4_0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:78:in `block in <top (required)>'
from /home/paul/.rvm/gems/ruby-2.0.0-p195#railstutorial_rails_4_0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:75:in `tap'
from /home/paul/.rvm/gems/ruby-2.0.0-p195#railstutorial_rails_4_0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:75:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I did get some ideas from Rails: Could not find railties, outlined below, but haven't yet found a fix.
Here's the details.
Yesterday (in my browser) the Gemfile for Chapter 3 was as follows. Everything worked fine.
$ cat Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails', '2.0.2'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
# gem 'guard-rspec', '1.2.1'
# gem 'guard-spork', '1.2.0'
# gem 'childprocess', '0.3.6'
# gem 'spork', '0.9.2'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'cucumber-rails', '1.2.1', :require => false
gem 'database_cleaner', '0.7.0'
# gem 'launchy', '2.1.0'
# gem 'rb-fsevent', '0.9.1', :require => false
# gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
This morning the Gemfiles in the tutorial are using ruby 2.0.0 and rails 4.0.0.rc1. I'd like to get this setup working, so I don't have conflicts with the updated tutorial. New Gemfile is as follows.
$ cat Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0.rc1'
group :development, :test do
gem 'sqlite3', '1.3.7'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.0.0'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.0.rc1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '2.2.1'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
end
First I changed the ruby version in the Gemfile to ruby '1.9.2' because that's what I was running, and think I had an error with bundle update. I didn't take notes.
Then changed the ruby version back to '2.0.0' in the Gemfile and:
$ rvm install 2.0.0
$ rvm use 2.0.0 --default
$ bundle update
$ bundle install
Now I'm getting the cannot load railtie error with rails commands.
From Rails: Could not find railties, I tried the following
$ gem uninstall railties
Select gem to uninstall:
1. railties-4.0.0.rc1
2. railties-3.2.13
3. All versions
> 2
You have requested to uninstall the gem:
railties-3.2.13
rails-3.2.13 depends on railties (= 3.2.13)
If you remove this gem, these dependencies will not be met.
Y # uninstall railties-3.2.13
still getting the error
$ gem uninstall rails # to uninstall rails-3.2.13
$ gem uninstall railties # to also uninstall railties-4.0.0.rc1
$ rvm reinstall 2.0.0
$ rvm 2.0.0 --default
$ bundle update # using the Gemfile with ruby 2, rails 4
$ bundle install
$ gem list | grep rail
coffee-rails (4.0.0)
jquery-rails (2.2.1)
rails (4.0.0.rc1)
railties (4.0.0.rc1)
rspec-rails (2.13.1)
sass-rails (4.0.0.rc1)
sprockets-rails (2.0.0.rc4)
still getting the error
Going back through the original setup from the tutorial in chapter one (now updated for ruby 2, rails 4.)
$ rvm use 2.0.0#railstutorial_rails_4_0 --create --default
$ gem update --system 2.0.0
$ gem install rails --version 4.0.0.rc1 --no-ri --no-rdoc
$ bundle update # using Gemfile with ruby 2, rails 4
$ bundle install
still getting the error
ug!!!
Any ideas?
ActiveResource was an API added in Rails 2.x to support an XML (and later JSON) API so that Rails sites could "talk" to one another. It was a very hot topic when the idea of RESTful APIs made its way into the framework. Over time it became more of a novelty and infrequently maintained so it was pulled from the core in Rails 4.x.
You have two options at Rails 4.x. If you did not intend to use ActiveResource (I'd assume this is the case if you're new to Rails and working on a tutorial) then you can simply remove or comment out the railtie that's pulling it into the framework. Open up 'config/application.rb' and comment out the seventh line.
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
# require "active_resource/railtie" <--- comment out this line
If you WANT to use ActiveResource, then just add it to the Gemfile for the project. Previously it was included by the rails gem as a dependency; now you'll have to add it explicitly if you want to use it.
'activeresource' is available as a separate gem from Rails 4
I had same error.
what I made is:
in Gemfile I changed version of rails: gem 'rails', '4.2.0'
Then on command line executed this command: bundle install.
To see what generators available to us type rails g or rails generate on CLI.

Migrating to rails 3.1 gives DEPRECATION WARNING: class_inheritable_attribute is deprecated

Since i migrated from Rails 3.0 to Rails 3.1 i get these warnings :
DEPRECATION WARNING: class_inheritable_attribute is deprecated, please
use class_attribute method instead. Notice their behavior are slightly
different, so refer to class_attribute documentation first. (called
from require at
/Users/vincentdaubry/.rvm/gems/ruby-1.9.2-p318#global/gems/bundler-1.1.3/lib/bundler/runtime.rb:74)
I do not have any reference to class_inheritable_attribute in my code.
I guess one of the gem i'm using is producing this error, but how can i know which one ? Or is there something else to do to fix this warning ?
EDIT 2 :
None of the gem i'm using has any reference to class_inheritable_attribute (i tried to ack "class_inheritable_attribute" in the gem directory).
If i deploy my app on another computer on rails 3.1.3 that doesn't use RVM i dont get the warning, so i think it comes from RVM. Does it sound reasonable ?
I tried to update RVM with rvm get stable but i still get the warning..
Any ideas ?
EDIT :
Here is my gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'paperclip', '2.4.5'
gem 'pdf-toolkit', '0.5.0'
gem 'omniauth-facebook', '1.2.0'
gem 'delayed_job', '2.1.4'
gem 'devise', '1.5.3'
gem 'mini_magick', '3.4'
gem 'faraday', '0.6.1' #WARNING : this faraday version is specify, because on 0.7.5 this breaks facebook connection
gem 'acts-as-taggable-on', '2.2.2'
gem 'kaminari', '0.13.0'
gem 'forem', :git => "git://github.com/radar/forem.git"
gem 'forem-redcarpet', :git => "git://github.com/radar/forem-redcarpet"
gem 's3_swf_upload', :git => 'https://github.com/nathancolgate/s3-swf-upload-plugin.git'
gem 'aws-s3', '0.6.2', :require => 'aws/s3'
gem 'jquery-rails', '1.0.13'
gem 'dalli', '1.1.4'
gem 'bson', '1.5.2'
gem 'bson_ext', '1.5.2'
gem 'exception_notification_rails3', '1.2.0', :require => 'exception_notifier'
######################################################################
# unused
######################################################################
#gem 'newrelic_rpm', '3.3.1'
#gem 'mongo', '1.5.2'
#gem 'mongoid', '2.4.0'
#gem "rdiscount"
######################################################################
# Environment specific
######################################################################
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'mocha'
end
group :production do
gem "pg"
end
Thanks,
Vincent
You can grep by code of all installed gems to find all entries of class_inheritable_attribute. When you find it, try to update it.
It's bundler depreacation. Try update bundler. So far it works well with bundler 1.0.22

why bundler is populating ./libv8 not into the rvm folder

I am using ubuntu and rvm 1.8.6, ruby 1.9.2, bundler (1.1.rc, 1.0.21), it was working ok. But recently, I cleared my gemset and run bundle install again to get freshen up because some stupid things I did on my own.
But the bundler puts all the gems under ./libv8 folder inside my project folder, it's quite weird to me. And my rvm folder is getting nothing. Is it because of the "therubyracer"? The following is my gemfile:
gem 'rails'
gem 'rspec'
gem 'rake', '>=0.9.2'
gem 'mongoid'
gem 'bson_ext'
gem 'hpricot'
gem 'jquery-rails', '>= 1.0.12'
gem 'therubyracer'
gem "bcrypt-ruby", :require => "bcrypt"
gem 'gdata'
#gem 'SystemTimer', '1.2.3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
Take a look at the .bundle/config file in your app's root.
Check if the BUNDLE_PATH variable is set, and in case it is, delete it.
Bundler will go back to rubygem's default behaviour, which is installing gems in $GEM_HOME.
You probably executed bundle install --path ./libv8 once and forgot about it.

Resources