Gem::LoadError when using a git repo in Gemfile - ruby

I forked the sinbook gem and added the git repo to my Gemfile. But the sinatra-authentication gem, which depends on sinbook, throws Gem::LoadError.
Why isn't my version of the gem being used?
Gemfile
source :rubygems
gem 'sinatra'
gem 'sinatra-contrib'
gem 'sequel'
gem 'jruby-openssl'
gem 'rack-flash'
gem 'sinbook', git: 'https://github.com/JamesGecko/sinbook'
gem 'sinatra-authentication'
gem 'json-jruby'
gem 'coffee-script'
gem 'therubyrhino'
error
PS C:\users\james\code\portal> jruby -S bundle
Fetching gem metadata from http://rubygems.org/........
Fetching gem metadata from http://rubygems.org/..
Fetching https://github.com/JamesGecko/sinbook
Installing addressable (2.2.8)
Installing backports (2.5.1)
Installing bouncy-castle-java (1.5.0146.1)
Installing coffee-script-source (1.3.1)
Installing multi_json (1.2.0)
Installing execjs (1.3.0)
Installing coffee-script (2.2.0)
Installing dm-core (1.2.0)
Installing dm-migrations (1.2.0)
Installing dm-timestamps (1.2.0)
Installing dm-validations (1.2.0)
Installing eventmachine (0.12.10)
Installing jruby-openssl (0.7.7)
Installing json (1.5.0)
Installing json-jruby (1.5.0)
Installing rack (1.4.1)
Installing rack-flash (0.1.2)
Installing rack-protection (1.2.0)
Installing rack-test (0.6.1)
Installing rufus-tokyo (1.0.7)
Installing sequel (3.34.1)
Installing tilt (1.3.3)
Installing sinatra (1.3.2)
Using sinbook (0.1.9.jamesgecko) from https://github.com/JamesGecko/sinbook (at master)
Installing sinatra-authentication (0.4.1)
Installing sinatra-contrib (1.3.1)
Installing therubyrhino (1.73.2)
Using bundler (1.1.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
PS C:\users\james\code\portal> jruby .\app.rb
Gem::LoadError: Could not find sinbook (>= 0) amongst [addressable-2.2.8, backports-2.5.1, bouncy-castle-java-1.5.0146.1, bundler-1.1.4, coffee-script-2.2.0, coffee-script-source-1.3.1, dm-core-1.2.0, dm-migrations-1.2.0, dm-timestamps-1.2.0, dm-validations-1.2.0, eventmachine-0.12.10-java, execjs-1.3.0, jruby-openssl-0.7.7, jruby-win32ole-0.8.5, json-1.5.0-java, json-jruby-1.5.0-java, multi_json-1.2.0, rack-1.4.1, rack-flash-0.1.2, rack-protection-1.2.0, rack-test-0.6.1, rake-0.9.2.2, rufus-tokyo-1.0.7, sequel-3.34.1, sinatra-1.3.2, sinatra-authentication-0.4.1, sinatra-contrib-1.3.1, therubyrhino-1.73.2, tilt-1.3.3]
to_specs at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/dependency.rb:247
activate_dependencies at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/specification.rb:777
each at org/jruby/RubyArray.java:1611
activate_dependencies at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/specification.rb:766
activate at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/specification.rb:750
try_activate at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems.rb:212
require at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/custom_require.rb:59
require at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/custom_require.rb:55
(root) at .\app.rb:7
app.rb
require 'sinatra'
require 'sinatra/reloader'
require 'json'
require 'digest/sha1'
require 'rack-flash'
require 'sinatra-authentication'
use Rack::Session::Cookie, secret: 'foobar'
use Rack::Flash
# ...

Add require "bundler/setup" to app.rb. It it needed to load the bundled environment. More info may be found in the bundler documentation.
Since you're using Sinatra, you may also want to look into using config.ru.

Related

Calling "brew" in Ruby system call and bundler error

I'm trying to write a rubygem that does some stuff with homebrew. I'm calling on brew to do some stuff using system(). When I include certain gems in using bundler, I get some errors doing things inside system().
As an example, a basic Gemfile with rake:
~/tmp/foo cat Gemfile
source 'https://rubygems.org'
gem 'rake'
Inside irb after running a bundle install:
irb(main):001:0> system("brew", "info", "ack")
Could not find rake-12.0.0 in any of the sources
Run `bundle install` to install missing gems.
=> false
I can do a bundle install inside the call and receive the same results:
rb(main):007:0> system("bundle", "install")
Using rake 12.0.0
Using bundler 1.14.6
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Bundled gems are installed into /Users/laura/.bundle.
=> true
irb(main):008:0> system("brew", "version")
Could not find rake-12.0.0 in any of the sources
Run `bundle install` to install missing gems.
=> false
Without the rake gem included I do not receive any errors:
~/tmp/foo cat Gemfile
source 'https://rubygems.org'
gem 'git'
~/tmp/foo bundle install
Fetching gem metadata from https://rubygems.org/.
Fetching version metadata from https://rubygems.org/
Resolving dependencies...
Using git 1.3.0
Using bundler 1.14.6
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Bundled gems are installed into /Users/surminus/.bundle.
~/tmp/foo
~/tmp/foo irb
irb(main):002:0> system("brew", "info", "ack")
ack: stable 2.16, HEAD
Search tool like grep, but optimized for programmers
https://beyondgrep.com/
/usr/local/Cellar/ack/2.14 (4 files, 184.7KB)
Built from source on 2016-12-16 at 16:24:07
/usr/local/Cellar/ack/2.16 (4 files, 190.7KB) *
Built from source on 2017-03-17 at 20:25:45
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ack.rb
=> true
I know it's probably related to some conflict between homebrew, rake and bundler, but I can't for the life of me figure out what's going on. I only need to rake tasks for some development specific tasks so I can remove it, but I'm interested to find out why this occurs, or if indeed calling brew this way is $bad.
EDIT: I was asked for output of gem list --local in the bundle directory. Seems to be system gems. With bundle exec:
~/tmp/foo bundle exec gem list --local
*** LOCAL GEMS ***
bundler (1.14.6)
rake (12.0.0)
Without bundle exec:
~/tmp/foo gem list --local
*** LOCAL GEMS ***
activemodel (5.0.1)
activesupport (5.0.1)
addressable (2.5.0)
bigdecimal (1.2.8)
bundler (1.14.6, 1.14.5, 1.13.6)
CFPropertyList (2.2.8)
coderay (1.1.1)
commander (4.4.2)
concurrent-ruby (1.0.3)
did_you_mean (1.0.0)
diff-lcs (1.3, 1.2.5)
domain_name (0.5.20161129)
facter (2.4.6 ruby universal-darwin)
fileutils (0.7)
git (1.3.0)
hiera (1.3.4)
highline (1.7.8)
http-cookie (1.0.3)
i18n (0.7.0)
io-console (0.4.5)
json (2.0.2, 1.8.3)
json_pure (2.0.1, 1.8.3)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (3.2016.0521)
minitest (5.10.1, 5.8.3)
mocha (1.2.1, 1.1.0)
myosx (0.2.2, 0.2.0, 0.1.0)
net-telnet (0.1.1)
netrc (0.11.0)
oauth (0.5.1)
power_assert (0.2.6)
pry (0.10.4)
psych (2.0.17)
public_suffix (2.0.4)
puppet (3.8.7)
puppet-lint (1.1.0)
puppet-syntax (2.3.0, 2.1.0)
puppetlabs_spec_helper (1.1.1)
rake (12.0.0, 11.1.2, 10.5.0, 10.4.2)
rdoc (4.2.1)
rest-client (2.0.0)
rmagick (2.16.0)
rspec (3.5.0, 3.4.0)
rspec-core (3.5.4, 3.4.4)
rspec-expectations (3.5.0, 3.4.0)
rspec-mocks (3.5.0, 3.4.1)
rspec-puppet (2.4.0)
rspec-support (3.5.0, 3.4.1)
ruby-trello (1.6.0)
slop (3.6.0)
test-unit (3.1.5)
thread_safe (0.3.5)
tzinfo (1.2.2)
unf (0.1.4)
unf_ext (0.0.7.2)

Travis CI won't install eventmachine?

I'm just getting started with CI on my open-source project, and it's all going swimmingly, however Travis is continually failing when it gets to pieces of code that require eventmachine. Eventmachine is specified in the gemspec as both runtime and development dependency (same as wisper), but Travis will not install Eventmachine, causing every build to fail - however, it does install wisper. What's going on? :(
Most recent build that failed
GemSpec Dependencies
..
spec.add_development_dependency 'bundler', '~> 1.5'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '~> 2.4'
spec.add_development_dependency 'wisper'
spec.add_development_dependency 'eventmachine'
spec.add_runtime_dependency 'wisper'
spec.add_runtime_dependency 'eventmachine'
Travis YML
rvm:
- 1.9.3
# we don't support 1.9.2
# - 1.9.2
- jruby
- rbx
script: "bundle exec rake"
Rake default task
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new :spec
task :default => :spec
Log
$ gem --version
2.2.2
$ bundle --version
Bundler version 1.5.3
Applying fix for NPM certificates
install
$ bundle install --deployment
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Installing rake (10.1.1)
Installing wisper (1.3.0)
angler at /home/travis/build/DanPantry/angler did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
duplicate dependency on wisper (>= 0), (>= 0) use:
add_runtime_dependency 'wisper', '>= 0', '>= 0'
Using angler (0.0.1) from source at .
Installing timers (1.1.0)
Installing celluloid (0.15.2)
Installing nio4r (1.0.0)
Installing celluloid-io (0.15.0)
Installing diff-lcs (1.2.5)
Installing formatador (0.2.4)
Installing rb-fsevent (0.9.4)
Installing rb-inotify (0.9.3)
Installing listen (2.7.1)
Installing lumberjack (1.0.4)
Installing thor (0.18.1)
Installing guard (2.5.1)
Using bundler (1.5.3)
Installing guard-bundler (2.0.0)
Installing rspec-core (2.14.8)
Installing rspec-expectations (2.14.5)
Installing rspec-mocks (2.14.6)
Installing rspec (2.14.1)
Installing guard-rspec (4.2.8)
Cannot write a changed lockfile while frozen.
Your bundle is complete!
It was installed into ./vendor/bundle
$ bundle exec rake
/home/travis/.rvm/rubies/ruby-1.9.3-p484/bin/ruby -S rspec ./spec/remote_spec.rb
/home/travis/build/DanPantry/angler/lib/angler.rb:5:in `require': cannot load such file -- eventmachine (LoadError)
NOTE: Even without add_runtime_dependency, Travis just won't install EventMachine.
The important part of your log is this
angler at /home/travis/build/DanPantry/angler did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
duplicate dependency on wisper (>= 0), (>= 0) use:
add_runtime_dependency 'wisper', '>= 0', '>= 0'
Fix your gemspec, then bundler can install gems specified there. I simple solution would be to remove the development dependency to wisper and rely solely on the runtime_dependency for it.

Octopress --> Heroku error env: bundle: no such file or directory

I have an Octopress blog running on Heroku using a buildpack (https://github.com/jgarber/heroku-buildpack-ruby-octopress). It was working fine up until a few days ago, when I started getting the error below on deployment (everything works fine on local). I reverted to a working git and tried to deploy again but no dice.
env: bundle: no such file or directory error.
Here is the deployment log
-----> Deleting 0 files matching .slugignore patterns.
-----> Fetching custom git buildpack... done
-----> Octopress app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://rubygems.org/..
Installing rake (10.1.1)
Installing RedCloth (4.2.9)
Installing chunky_png (1.2.9)
Installing fast-stemmer (1.0.2)
Installing classifier (1.3.4)
Installing fssm (0.2.10)
Installing sass (3.2.13)
Installing compass (0.12.2)
Installing directory_watcher (1.5.1)
Installing haml (3.1.8)
Installing kramdown (0.14.2)
Installing liquid (2.3.0)
Installing maruku (0.7.0)
Installing posix-spawn (0.3.8)
Installing yajl-ruby (1.1.0)
Installing pygments.rb (0.3.7)
Installing jekyll (0.12.1)
Installing rack (1.5.2)
Installing rack-protection (1.5.1)
Installing rdiscount (1.6.8)
Installing rubypants (0.2.0)
Installing sass-globbing (1.0.0)
Installing tilt (1.4.1)
Installing sinatra (1.4.4)
Installing stringex (1.4.0)
Using bundler (1.3.2)
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
Removing bundler (1.3.0.pre.5)
-----> Building Octopress site
env: bundle: No such file or directory
-----> Discovering process types
Procfile declares types -> (none)
Gemfile
source "http://rubygems.org"
gem 'rake'
gem 'jekyll', '~> 0.12'
gem 'rdiscount', '~> 1.6.8'
gem 'pygments.rb', '~> 0.3.4'
gem 'RedCloth', '~> 4.2.9'
gem 'haml', '~> 3.1.7'
gem 'compass', '~> 0.12.2'
gem 'sass-globbing', '~> 1.0.0'
gem 'rubypants', '~> 0.2.0'
gem 'stringex', '~> 1.4.0'
gem 'liquid', '~> 2.3.0'
gem 'sinatra', '~> 1.4.2'
group :development do
gem 'rb-fsevent', '~> 0.9'
end
Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
RedCloth (4.2.9)
chunky_png (1.2.9)
classifier (1.3.3)
fast-stemmer (>= 1.0.0)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
directory_watcher (1.5.1)
fast-stemmer (1.0.2)
fssm (0.2.10)
haml (3.1.8)
jekyll (0.12.1)
classifier (~> 1.3)
directory_watcher (~> 1.1)
kramdown (~> 0.14)
liquid (~> 2.3)
maruku (~> 0.5)
pygments.rb (~> 0.3.2)
kramdown (0.14.2)
liquid (2.3.0)
maruku (0.7.0)
posix-spawn (0.3.8)
pygments.rb (0.3.7)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.5.2)
rack-protection (1.5.1)
rack
rake (10.1.1)
rb-fsevent (0.9.3)
rdiscount (1.6.8)
rubypants (0.2.0)
sass (3.2.13)
sass-globbing (1.0.0)
sass (>= 3.1)
sinatra (1.4.4)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
stringex (1.4.0)
tilt (1.4.1)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
RedCloth (~> 4.2.9)
compass (~> 0.12.2)
haml (~> 3.1.7)
jekyll (~> 0.12)
liquid (~> 2.3.0)
pygments.rb (~> 0.3.4)
rake
rb-fsevent (~> 0.9)
rdiscount (~> 1.6.8)
rubypants (~> 0.2.0)
sass-globbing (~> 1.0.0)
sinatra (~> 1.4.2)
stringex (~> 1.4.0)
I have searched up and down but nothing seems to work for me. Any help would be much appreciated.
I removed and add the BUILDPACK_URL again.
heroku config:remove BUILDPACK_URL
heroku config:set BUILDPACK_URL=https://github.com/nicholasmott/heroku-buildpack-octopress.git
And created a Procfile with content:
web: bundle exec rackup config.ru -p $PORT
I don't know which resolves the problem, but now it works.
I tried
Simply set the url again: Nothing.
Freeze the ruby version: Nothing.
Create a Profile without bundle: Nothing.
Then I removed the Buildpack and I got my site down. I added again the buildpack and I created a Procfile and after that it just runs :)
Try creating another application and Git remote using an updated version of the buildpack. It takes into account the way Heroku wants you to specify Ruby version in the Gemfile, which is new since Jason wrote his original buildpack.
I had a similar thing happen to me on my jekyll site when I updated my gems.
I had to roll back my heroku to the "stock" heroku buildpack. Then everything started to work again.

JRuby "no such file to load"

Using jruby-1.6.7 via rvm and gem version 1.8.24 I created a new project containing a Gemfile:
source 'http://rubygems.org'
gem 'google-api-client'
and a main.rb:
require 'google/api_client'
After
gem install bundler
bundle install
gem list
I get
addressable (2.2.8)
autoparse (0.3.1)
bouncy-castle-java (1.5.0146.1)
bundler (1.1.4)
extlib (0.9.15)
faraday (0.8.1, 0.7.6)
ffi (1.0.11 java)
google-api-client (0.4.3)
jruby-launcher (1.0.14 java)
jruby-openssl (0.7.7)
json (1.7.3 java)
jwt (0.1.4)
launchy (2.1.0 java)
multi_json (1.3.6)
multipart-post (1.1.5)
rack (1.4.1)
rake (0.9.2.2)
rubygems-bundler (1.0.2)
rubygems-update (1.8.24, 1.7.2)
rvm (1.11.3.3)
signet (0.3.4)
spoon (0.0.1)
But when I run ruby main.rb, it results in an error:
LoadError: no such file to load -- google/api_client
require at org/jruby/RubyKernel.java:1033
(root) at main.rb:1
On MRI everything seems to be working fine. The problem does not seem bound to any specific gem.
Can someone help me with this?
Unless you have JRUBY_OPTS=--1.9 in your environment, or you pass the --1.9 flag on the command line, JRuby will default to 1.8 mode, which means that you explicitly have to require 'rubygems' in main.rb before you load your gems.

Which version of Padrino runs fine in Ruby 1.8.6?

Padrino 0.10 gem installed activesupprt 3.0.9 which requires ruby >= 1.8.7.
I am Working on Ruby 1.8.6 can any one suggest me which version of Padrino works fine with Ruby 1.8.6 ?
I don't want upgrade Ruby version atleast for 5-6 months. This my current gemfile
source :rubygems
# Server requirements
# gem 'thin' or mongrel
# Project requirements
gem 'rake'
gem 'rack-flash'
# Component requirements
#gem 'haml'
gem 'SystemTimer', :require => "system_timer"
gem 'mongoid'
gem 'bson_ext', :require => "mongo"
gem "state_machine"
# Test requirements
gem 'rspec', :group => "test"
gem 'rack-test', :group => "test", :require => "rack/test"
gem 'mongoid-rspec', :group => "test"
# Padrino
gem 'padrino', '0.10.0'
v. 0.9.8 should work with ruby 1.8.6.
v. 0.9.9 worked fine for ruby 1.8.6
Installing rake (0.9.2)
Installing SystemTimer (1.2.3) with native extensions
Installing activesupport (2.3.5)
Installing bson (1.0.9)
Installing bson_ext (1.3.1) with native extensions
Using bundler (1.0.7)
Installing diff-lcs (1.1.3)
Installing durran-validatable (2.0.1)
Installing fuzzyhash (0.0.11)
Installing i18n (0.6.0)
Installing mongo (1.0.9)
Installing will_paginate (2.3.16)
Installing mongoid (1.9.0)
Installing rack (1.3.1)
Installing tilt (1.3.3)
Installing sinatra (1.2.6)
Installing thor (0.14.6)
Installing usher (0.8.3)
Installing padrino-core (0.9.9)
Installing padrino-gen (0.9.9)
Installing padrino-helpers (0.9.9)
Installing padrino-admin (0.9.9)
Installing tmail (1.2.7.1) with native extensions
Installing padrino-mailer (0.9.9)
Installing padrino (0.9.9)
Installing rack-flash (0.1.2)
Installing rack-test (0.6.0)
Installing rspec-core (2.6.4)
Installing rspec-expectations (2.6.0)
Installing rspec-mocks (2.6.0)
Installing rspec (2.6.0)
Installing state_machine (1.0.2)
Your bundle is complete! It was installed into ./vendor/bundle_gems
I need to set the version of mongoid ~> 1.9.0 and removed mongoid-rspecs as it required active support 3.0, but active support 3.0 required ruby >= 1.8.7

Resources