Ruby failed to rackup - uninitialized constant Dry::Validation::Contract - ruby

My laptop is MacOS m1 chip, when I was using rackup to run the app, it showed uninitialized constant Dry::Validation::Contract (NameError) Did you mean? Dry::Container, I have no idea about it and didn't find an answer on the Internet.
Here's my Gemfile.
# frozen_string_literal: true
source 'https://rubygems.org'
ruby '2.7.3'
# PRESENTATION LAYER
gem 'slim'
# APPLICATION LAYER
# Web application related
gem 'econfig'
gem 'puma'
gem 'roda'
# Controllers and services
gem 'dry-monads'
gem 'dry-transaction'
gem 'dry-validation'
...
Also put the Gemfile.lock here
GEM
remote: https://rubygems.org/
specs:
...
dry-validation (0.12.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (~> 0.2, >= 0.2.1)
dry-equalizer (~> 0.2)
dry-logic (~> 0.4, >= 0.4.0)
dry-types (~> 0.13.1)
...
PLATFORMS
ruby
DEPENDENCIES
...
dry-monads
dry-transaction
dry-validation
...
RUBY VERSION
ruby 2.7.3p183
BUNDLED WITH
2.2.21
Hope someone can help, thanks!

Related

Way out of date GEM file and new to ruby..where to begin?

this was a project from 2015 ... so nothing has been update or made new....just dumped on my plate.
gem query --local
*** LOCAL GEMS ***
actionmailer (4.1.2)
actionpack (4.1.2)
actionview (4.1.2)
activemodel (4.1.2)
activerecord (4.1.2)
activesupport (4.1.3, 4.1.2)
arel (5.0.1.20140414130214)
bigdecimal (1.2.8)
builder (3.2.4)
bundler (1.17.3)
concurrent-ruby (1.1.10)
did_you_mean (1.0.0)
erubis (2.7.0)
i18n (0.9.5)
io-console (0.4.5)
json (1.8.3)
after running bundle install
So I'm wondering where I should begin to start getting this worked out.
Coming from a PHP/Python background....not liking this ruby ;)
bundler could not find compatible versions for gem "actionpack":
In Gemfile:
actionpack-action_caching was resolved to 1.2.2, which depends on
actionpack (>= 4.0.0)
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
kaminari (~> 0.14) was resolved to 0.17.0, which depends on
actionpack (>= 3.0.0)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
actionpack (= 4.1.2)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
sprockets-rails (~> 2.0) was resolved to 2.3.3, which depends on
actionpack (>= 3.0)
Bundler could not find compatible versions for gem "activemodel":
In Gemfile:
paperclip (~> 4.3) was resolved to 4.3.7, which depends on
activemodel (>= 3.2.0)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
activemodel (= 4.1.2)
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
jbuilder (~> 2.0) was resolved to 2.6.4, which depends on
activesupport (>= 3.0.0)
paperclip (~> 4.3) was resolved to 4.3.7, which depends on
activesupport (>= 3.2.0)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
activesupport (= 4.1.2)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
sprockets-rails (~> 2.0) was resolved to 2.3.3, which depends on
activesupport (>= 3.0)
Bundler could not find compatible versions for gem "font-awesome-rails":
In Gemfile:
font-awesome-rails (= 4.1.0.0)
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
font-awesome-rails (< 5, >= 3.0)
Bundler could not find compatible versions for gem "i18n":
In Gemfile:
rails (= 4.1.2) was resolved to 4.1.2, which depends on
activesupport (= 4.1.2) was resolved to 4.1.2, which depends on
i18n (>= 0.6.9, ~> 0.6)
capistrano was resolved to 3.17.1, which depends on
i18n
Bundler could not find compatible versions for gem "jbuilder":
In Gemfile:
jbuilder (~> 2.0)
jpbuilder was resolved to 0.3.0, which depends on
jbuilder
Bundler could not find compatible versions for gem "jquery-rails":
In Gemfile:
jquery-rails
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
jquery-rails (< 5, >= 3.0)
Bundler could not find compatible versions for gem "mimemagic":
In Gemfile:
paperclip (~> 4.3) was resolved to 4.3.7, which depends on
mimemagic (= 0.3.0)
Could not find gem 'mimemagic (= 0.3.0)', which is required by gem 'paperclip (~> 4.3)', in any of the sources.
Bundler could not find compatible versions for gem "net-ssh":
In Gemfile:
capistrano was resolved to 3.17.1, which depends on
sshkit (>= 1.9.0) was resolved to 1.21.3, which depends on
net-scp (>= 1.1.2) was resolved to 4.0.0, which depends on
net-ssh (< 8.0.0, >= 2.6.5)
capistrano was resolved to 3.17.1, which depends on
sshkit (>= 1.9.0) was resolved to 1.21.3, which depends on
net-ssh (>= 2.8.0)
Bundler could not find compatible versions for gem "rack":
In Gemfile:
rails (= 4.1.2) was resolved to 4.1.2, which depends on
actionpack (= 4.1.2) was resolved to 4.1.2, which depends on
rack (~> 1.5.2)
passenger (>= 5.0.25) was resolved to 6.0.15, which depends on
rack
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
rack-pjax (~> 0.7) was resolved to 0.8.0, which depends on
rack (~> 1.1)
sass-rails (~> 4.0.3) was resolved to 4.0.5, which depends on
sprockets (< 3.0, ~> 2.8) was resolved to 2.12.5, which depends on
rack (~> 1.0)
devise was resolved to 4.8.1, which depends on
warden (~> 1.2.3) was resolved to 1.2.7, which depends on
rack (>= 1.0)
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (= 4.1.2)
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
rails (~> 4.0)
Bundler could not find compatible versions for gem "railties":
In Gemfile:
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
coffee-rails (~> 4.0) was resolved to 4.2.2, which depends on
railties (>= 4.0.0)
devise was resolved to 4.8.1, which depends on
railties (>= 4.1.0)
font-awesome-rails (= 4.1.0.0) was resolved to 4.1.0.0, which depends on
railties (< 5.0, >= 3.2)
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
jquery-rails (< 5, >= 3.0) was resolved to 3.1.5, which depends on
railties (< 5.0, >= 3.0)
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
jquery-ui-rails (~> 5.0) was resolved to 5.0.5, which depends on
railties (>= 3.2.16)
js-routes was resolved to 1.4.14, which depends on
railties (>= 4)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
railties (= 4.1.2)
sass-rails (~> 4.0.3) was resolved to 4.0.5, which depends on
railties (< 5.0, >= 4.0.0)
Bundler could not find compatible versions for gem "ruby":
In Gemfile:
ruby
aws-sdk was resolved to 3.1.0, which depends on
ruby (>= 2.3)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
bundler (< 2.0, >= 1.3.0) was resolved to 1.17.3, which depends on
ruby (>= 1.8.7)
byebug was resolved to 11.0.1, which depends on
ruby (>= 2.3.0)
capistrano was resolved to 3.17.1, which depends on
ruby (>= 2.0)
guard-livereload was resolved to 2.5.2, which depends on
guard (~> 2.8) was resolved to 2.18.0, which depends on
pry (>= 0.13.0) was resolved to 0.14.1, which depends on
coderay (~> 1.1) was resolved to 1.1.3, which depends on
ruby (>= 1.8.6)
devise was resolved to 4.8.1, which depends on
ruby (>= 2.1.0)
guard-livereload was resolved to 2.5.2, which depends on
guard (~> 2.8) was resolved to 2.18.0, which depends on
listen (< 4.0, >= 2.7) was resolved to 3.5.0, which depends on
ruby (>= 2.2.7)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
activesupport (= 4.1.2) was resolved to 4.1.2, which depends on
minitest (~> 5.1) was resolved to 5.15.0, which depends on
ruby (< 4.0, >= 2.2)
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
rack-pjax (~> 0.7) was resolved to 0.8.0, which depends on
nokogiri (~> 1.5) was resolved to 1.12.5, which depends on
ruby (>= 2.5.0)
paperclip (~> 4.3) was resolved to 4.3.7, which depends on
ruby (>= 1.9.2)
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
ruby (>= 1.9.3)
capistrano was resolved to 3.17.1, which depends on
rake (>= 10.0.0) was resolved to 13.0.6, which depends on
ruby (>= 2.2)
Bundler could not find compatible versions for gem "sass-rails":
In Gemfile:
sass-rails (~> 4.0.3)
rails_admin (~> 0.6.2) was resolved to 0.6.8, which depends on
sass-rails (< 6, >= 4.0)
Bundler could not find compatible versions for gem "sprockets":
In Gemfile:
sass-rails (~> 4.0.3) was resolved to 4.0.5, which depends on
sprockets (< 3.0, ~> 2.8)
rails (= 4.1.2) was resolved to 4.1.2, which depends on
sprockets-rails (~> 2.0) was resolved to 2.3.3, which depends on
sprockets (< 4.0, >= 2.8)
And the GEMFILE
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.2'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
# gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/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 'jpbuilder'
# bundle exec rake doc:rails generates the API under doc/api.
# gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
gem "passenger", ">= 5.0.25", require: "phusion_passenger/rack_handler"
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
group :development do
gem 'capistrano'
gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'capistrano-faster-assets', '~> 1.0'
gem 'capistrano-rbenv'
gem 'capistrano-passenger'
gem 'byebug'
end
# Use debugger
# gem 'debugger', group: [:development, :test]
# https://github.com/plataformatec/devise
gem 'devise'
# https://github.com/sferik/rails_admin
gem 'rails_admin', '~> 0.6.2'
# https://github.com/thoughtbot/paperclip
gem 'paperclip', '~> 4.3'
# https://github.com/42dev/bower-rails
gem 'bower-rails', '~> 0.9.0'
# https://github.com/guard/guard-livereload
gem 'guard-livereload', group: :development
# https://github.com/johnbintz/rack-livereload
gem 'rack-livereload', group: :development
# http://railsware.github.io/js-routes/
gem 'js-routes'
# https://github.com/aws/aws-sdk-ruby
gem 'aws-sdk'
# Action caching. Read more: https://github.com/rails/actionpack-action_caching
gem 'actionpack-action_caching'
# Dalli memcached client. Read more: https://github.com/mperham/dalli
gem 'dalli'
# https://github.com/bokmann/font-awesome-rails
gem 'font-awesome-rails', '4.1.0.0'
# WYSIWYG editor for admin backend. Read more: https://github.com/galetahub/ckeditor
gem 'ckeditor'```
This Rails version remembers the last mammoths so what did you expect? :)
First things first:
Double check you are not trying to build this project on the bleeding edge Ruby (3.x). Even the latest 2.x might be a problem with Rails that old. Google "Rails & Ruby compatibility" to check which Ruby version is recommended for this fossil and don't try to move too far ahead. Use some Ruby version manager to switch between versions easily (my choice is asdf, but more common rbenv or rvm work too).
If downgrading Ruby doesn't help, try removing Gemfile.lock (copy it somewhere just in case) and reinstalling dependencies. Bundler locks dependencies there to minimize the surface of dependencies' changes. This is a very good thing during the normal development cycle, but for "archeological excavations" like the one you have to work with this might be a problem. With the lock file removed bundler will re-evaluate the dependencies graph from scratch so most of the conflicts you see now should be resolved. Probably :)
Be ready that even after this, you might have conflicts that the bundler cannot resolve on its own (due to some older versions of dependencies that are unavailable anymore etc).

How do I resolve this bundle update error when trying to use jekyll?

I'm having issues getting jekyll to run to create a GitHub Page. After following the instructions as listed in the documentation, I keep getting an error after I edit the Gemfile and try to run bundle update. The error is:
Bundler could not find compatible versions for gem "terminal-table":
In snapshot (Gemfile.lock):
terminal-table (>= 2.0.0)
In Gemfile:
github-pages (~> 215) was resolved to 215, which depends on
terminal-table (~> 1.4)'
I reinstalled terminal-table using 'gem install terminal-table', and listing my gems using 'gem list' I can see that I have version 3.0.1 installed, so I don't understand the error.
Thanks.
Gemfile
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "~> 4.2.0"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.5"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", "~> 215", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
end
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo", "~> 1.2"
gem "tzinfo-data"
end
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
colorator (1.1.0)
concurrent-ruby (1.1.9)
em-websocket (0.5.2)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
eventmachine (1.2.7)
ffi (1.15.3)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jekyll (4.2.0)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 1.0)
jekyll-sass-converter (~> 2.0)
jekyll-watch (~> 2.0)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (~> 0.4.0)
pathutil (~> 0.9)
rouge (~> 3.0)
safe_yaml (~> 1.0)
terminal-table (~> 2.0)
jekyll-feed (0.15.1)
jekyll (>= 3.7, < 5.0)
jekyll-sass-converter (2.1.0)
sassc (> 2.0.1, < 3.0)
jekyll-seo-tag (2.7.1)
jekyll (>= 3.8, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.3.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.3)
listen (3.5.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.6)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
rouge (3.26.0)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
terminal-table (2.0.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.7.0)
PLATFORMS
x86_64-darwin-19
DEPENDENCIES
jekyll (~> 4.2.0)
jekyll-feed (~> 0.12)
minima (~> 2.5)
tzinfo (~> 1.2)
tzinfo-data
wdm (~> 0.1.1)
BUNDLED WITH
2.2.24
Just delete the .lock file and bundle install. You will get a new one.
I just change terminal-table (>= 2.0.0) in Gemfile.lock to terminal-table (~> 1.4). And that seems to work in my environment. Hope this can work for you!

How to use gems installed in vendor/bundle directory

I have installed gems inside my project directory in the vendor/bundle using
bundle install --path vendor/bundle
All the gems are getting properly installed.
.bundle/config file
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
bundle env
Environment
Bundler 1.10.6
Rubygems 2.4.8
Ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-linux]
GEM_HOME /home/xyz/.rvm/gems/ruby-2.0.0-p643
GEM_PATH /home/xyz/.rvm/gems/ruby-2.0.0-p643:/home/xyz/.rvm/gems/ruby-2.0.0-p643#global
RVM 1.26.11 (1.26.11)
Git 1.9.1
rubygems-bundler (1.4.4)
Bundler settings
path
Set for your local app (/home/xyz/code/project/.bundle/config): "vendor/bundle"
Set for the current user (/home/xyz/.bundle/config): "vendor/bundle"
disable_shared_gems
Set for your local app (/home/xyz/code/project/.bundle/config): "1"
Set for the current user (/home/xyz/.bundle/config): "1"
Gemfile
source 'https://rubygems.org'
gem 'creek'
gem 'faraday'
gem 'faraday_middleware'
gem 'json'
gem 'logger'
gem 'mechanize'
gem 'nokogiri'
gem 'trollop'
gem 'yajl-ruby'
gem 'simplecov', :require => false, :group => :test
gem 'test-unit'
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
creek (1.0.8)
nokogiri (~> 1.6.0)
rubyzip (>= 1.0.0)
docile (1.1.5)
domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.0)
faraday (>= 0.7.4, < 0.10)
http-cookie (1.0.2)
domain_name (~> 0.5)
json (1.8.3)
logger (1.2.8)
mechanize (2.7.3)
domain_name (~> 0.5, >= 0.5.1)
http-cookie (~> 1.0)
mime-types (~> 2.0)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.4)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
mime-types (2.6.1)
mini_portile (0.6.2)
multipart-post (2.0.0)
net-http-digest_auth (1.4)
net-http-persistent (2.9.4)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
ntlm-http (0.1.1)
power_assert (0.2.4)
rubyzip (1.1.7)
simplecov (0.10.0)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
test-unit (3.1.3)
power_assert
trollop (2.1.2)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
webrobots (0.1.1)
yajl-ruby (1.2.1)
PLATFORMS
ruby
DEPENDENCIES
creek
faraday
faraday_middleware
json
logger
mechanize
nokogiri
simplecov
test-unit
trollop
yajl-ruby
BUNDLED WITH
1.10.6
bundle show --paths
/home/xyz/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.10.6/lib/gems/bundler-1.10.6
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/creek-1.0.8
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/docile-1.1.5
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/domain_name-0.5.24
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/faraday-0.9.1
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/faraday_middleware-0.10.0
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/http-cookie-1.0.2
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/json-1.8.3
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/logger-1.2.8
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/mechanize-2.7.3
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/mime-types-2.6.1
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/mini_portile-0.6.2
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/multipart-post-2.0.0
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/net-http-digest_auth-1.4
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/net-http-persistent-2.9.4
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.6.2
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/ntlm-http-0.1.1
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/power_assert-0.2.4
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/rubyzip-1.1.7
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/simplecov-0.10.0
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/simplecov-html-0.10.0
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/test-unit-3.1.3
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/trollop-2.1.2
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/unf-0.1.4
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/unf_ext-0.0.7.1
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/webrobots-0.1.1
/home/xyz/code/project/vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.2.1
The problem is in my files when i try to use any gem say simplecov its throwing error.
My Ruby file TestExample.rb
require 'rubygems'
require 'simplecov'
....
rest of the code
.....
enter code here
When i try to run this file it gives me this error
/home/xyz/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- simplecov (LoadError)
Am i missing something here?? Maybe how i am requiring the file is wrong?
Could you try adding this line in your rb?
require 'bundler/setup'
and then run it doing
bundle exec ruby TestExample.rb
I think that should work for you.

Why is bundler requiring an extremely old version of a gem when version not specified?

I have a Gemfile that looks like this:
gem 'google-api-client', :require => 'google/api_client'
gem 'my_baseimage', '0.0.3', :git => 'https://github.com/xxx/BaseImage.git'
I have a base gem that requires a bunch of common gems across projects.
However, when I run bundle install, I see errors like this:
In Gemfile:
activerecord (>= 0) ruby depends on
activemodel (= 4.1.11) ruby depends on
activesupport (= 4.1.11) ruby
activerecord (>= 0) ruby depends on
activemodel (= 4.1.11) ruby depends on
activesupport (= 4.1.11) ruby
google-api-client (>= 0) ruby depends on
activesupport (~> 3.2) ruby
Bundler could not find compatible versions for gem "rack":
In Gemfile:
rack-contrib (= 1.1.0) ruby depends on
rack (>= 0.9.1) ruby
sinatra (>= 0) ruby depends on
rack (~> 1.4) ruby
google-api-client (>= 0) ruby depends on
rack (= 1.2.0) ruby
rack (>= 0) ruby
google-api-client hasn't required rack 1.2 since, like, version 0.1, and moreover my_baseimage requires 0.7.1. When I run a gem dependency -R, I see this:
google-api-client-0.7.1 (addressable (>= 2.3.2))
google-api-client-0.7.1 (autoparse (>= 0.3.3))
google-api-client-0.7.1 (extlib (>= 0.9.15))
google-api-client-0.7.1 (faraday (>= 0.9.0))
Gem google-api-client-0.7.1
google-api-client-0.7.1 (jwt (>= 0.1.5))
google-api-client-0.7.1 (launchy (>= 2.1.1))
google-api-client-0.7.1 (multi_json (>= 1.0.0))
google-api-client-0.7.1 (rake (>= 0.9.0, development))
google-api-client-0.7.1 (rake (>= 0.9.0, development))
google-api-client-0.7.1 (retriable (>= 1.4))
google-api-client-0.7.1 (rspec (>= 2.11.0, development))
google-api-client-0.7.1 (signet (>= 0.5.0))
google-api-client-0.7.1 (uuidtools (>= 2.1.0))
I was able to work around this issue by, in my Gemfile, specifying 0.7.1, as follows:
gem 'google-api-client', '0.7.1', :require => 'google/api_client'
gem 'my_baseimage', '0.0.3', :git => 'https://github.com/xxx/BaseImage.git'
However, I was hoping that in my project-specific gemfiles I would not have to specified gem versions, they'd just take them from my_baseimage as-is.
Can anyone suggest why it would appear that bundle install is defaulting to a very old version of google-api-client when the dependency graph specifies the one I want (0.7.1) and my_baseimage also specifies the one I want (0.7.1)?
Bundler uses rubygems, which, when not given a specific version, defaults to the last version marked 'stable', which, if the tag isn't maintained, can mean even terribly deprecated builds.

Ruby / sinatra - How to ouput JSON

I'm trying to format my output as json. Here is a test code from http://www.sinatrarb.com/contrib/json.html :
require "sinatra"
require "sinatra/json"
# define a route that uses the helper
get '/' do
json :foo => 'bar'
end
# The rest of your classic application code goes here...
It shows me an "Application Error". Maybe it comes from the other files to launch the app. I'm using heroku(cloud). So I have a Gemfile :
source 'https://rubygems.org'
gem 'sinatra', '1.1.0'
gem 'thin'
Gemfile.lock :
GEM
remote: https://rubygems.org/
specs:
daemons (1.1.9)
eventmachine (1.0.3)
rack (1.5.2)
sinatra (1.1.0)
rack (~> 1.1)
tilt (~> 1.1)
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
tilt (1.4.1)
PLATFORMS
ruby
DEPENDENCIES
sinatra (= 1.1.0)
thin
and Procfile :
web: bundle exec ruby web.rb -p $PORT
Did I miss something ?
You need to reference in your Gemfile json gem, e.g:
gem "json", "1.5.5"
And then you call .to_json on the object you want to output as JSON.

Resources