Travis CI won't install eventmachine? - ruby

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.

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)

Managing conflicting dependencies in Gemfile.lock

In my gemspec file:
I have a gem dependency called zconfig that explicitly requires net-ssh version 2.6.8
I'm also using net-sftp, which in turn requires net-ssh version >= 2.6.5
When I bundle install, bundler is smart enough to recognize the needs of both gems and correctly identifies 2.6.8 as the version of net-ssh to install.
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
...
net-ssh (2.6.8)
...
zconfig (0.2.7)
mysql (~> 2.9.1)
mysql2 (~> 0.3.13)
net-ssh (~> 2.6.8)
net-ssh-gateway (~> 1.2.0)
sequel (~> 4.1.0)
sqlite3 (~> 1.3.7)
So far, while testing on the remote server, I've been cloning the project and installing these gems with bundle install --deployment and then running the project with the locally instaled vendor gems using bundle exec ..
However, I'm now done with development and I've packaged the project as a gem and installed it on the remote server. The problem is that when executing the gem ruby doesn't adhere to my Gemfile.lock specification and uses net-ssh 2.7.0, which causes a conflict:
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1615:in `raise_if_conflicts': Unable to activate zconfig-0.2.7, because net-ssh-2.7.0 conflicts with net-ssh (~> 2.6.8) (Gem::LoadError)
Is there a way to do something like bundle exec my_gem so that it uses the Gemfile.lock specifications?
Just define the specific version of the gem to a required version by adding the following line in the gemfile:
gem 'net-ssh', '2.6.8'
or in the thinegem.gemspec:
spec.add_dependency 'net-ssh', '2.6.8'
And if you did add the gemfile.lock into the project, it shell be used during a deployment anyway.

Why is bundler using an old version of ruby, and not recognizing new gems that are installed?

In my Heroku/Sinatra app I set up my gemfile with Ruby 1.8.7 and then later used RVM to set my default to 2.0.0. Now when I try and install any new gems such Sinatra-flash or Pony, the gems aren't recognized or found when I require them in my main.rb file.
When I add gem "pony" in my gemfile I get a popup message saying:
Gem 'pony' is not available in SDK 'ruby-1.8.7-p385'
even though I've installed it. When I type gem list into the terminal, it returns all the gems I've installed that aren't being recognized as installed in my program.
If I add require 'sinatra/flash' or require 'pony' in my main.rb, I get a message:
no such file to load
I'd really appreciate any help on this, this has been driving me nuts.
Edited:
Using command sudo gem install 'gemname'
When I enter rvm info I get back
ruby :
interpreter: "ruby"
version: "2.0.0p195"
date: "2013-05-14"
platform: "x86_64-darwin12.3.0"
patchlevel: "2013-05-14 revision 40734"
full_version: "ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]"
homes:
gem: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195"
ruby: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195"
binaries:
ruby: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/bin/ruby"
irb: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/bin/irb"
gem: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/bin/gem"
rake: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195#global/bin/rake"
environment:
PATH: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195/bin:/Users/adam419/.rvm/gems/ruby-2.0.0-p195#global/bin:/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/bin:/Users/adam419/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/git/bin/[["
GEM_HOME: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195"
GEM_PATH: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195:/Users/adam419/.rvm/gems/ruby-2.0.0-p195#global"
MY_RUBY_HOME: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195"
IRBRC: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/.irbrc"
RUBYOPT: ""
gemset: ""
Edit: After I enter 'rvm use ruby-2.0.0' and then 'bundle install'
I get;
Adams-MacBook-Pro:songs adam419$ rvm use ruby-2.0.0
Using /Users/adam419/.rvm/gems/ruby-2.0.0-p195
Adams-MacBook-Pro:songs adam419$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Could not find gem 'sinatra/flash (>= 0) ruby' in the gems available on this machine.
After changing from gem "sinatra/flash" to gem "sinatra-flash" and then running bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Enter your password to install the bundled RubyGems to your system:
Using addressable (2.2.8)
Installing daemons (1.1.9)
Using data_objects (0.10.12)
Using dm-core (1.2.0)
Using dm-do-adapter (1.2.0)
Installing dm-migrations (1.2.0)
Using do_sqlite3 (0.10.12)
Using dm-sqlite-adapter (1.2.0)
Installing eventmachine (1.0.3)
Using rack (1.5.2)
Using rack-protection (1.5.0)
Using sass (3.2.9)
Using tilt (1.4.1)
Using sinatra (1.4.2)
Using sinatra-flash (0.3.0)
Installing temple (0.6.5)
Installing slim (1.3.9)
Installing thin (1.5.1)
Using bundler (1.3.5)
Your bundle is complete!
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Current Gemfile
source 'https://rubygems.org'
gem "sinatra"
gem "slim"
gem "sass"
gem "dm-core"
gem "sinatra-flash"
gem "dm-migrations"
gem "thin"
gem "pg", :group => :production
gem "dm-postgres-adapter", :group => :production
gem "dm-sqlite-adapter", :group => :development
Gemlock file dependencies
DEPENDENCIES
dm-core
dm-migrations
dm-postgres-adapter
dm-sqlite-adapter
pg
sass
sinatra
sinatra-flash
slim
thin
By using sudo gem install pony you're triggering the system Ruby install which is different from RVM's version. Do not use sudo. Just make sure that RVM is loaded, then use the correct version of your ruby:
rvm use ruby-2.0.0
Then run bundler:
bundle install
This should give you the full environment.
I had the same problem and i deleted my rubymine .idea file and now its working fine.

Why does bundler think it needs a specific version when the gemspec specifies a pessimistic constraint?

My gemspec clearly requires active_support ~> 3.0, but bundler is failing to bundle install saying that my gem requires active_support = 3.0. WTF bundler? Can anyone explain this?
$ gem install code_filter
Successfully installed activesupport-3.0.0
Successfully installed active_support-3.0.0
Successfully installed code_filter-0.1.1
$ gem dependency code_filter
Gem code_filter-0.1.1
active_support (~> 3.0, runtime)
$ bundle
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://192.168.10.22/...
Fetching gem metadata from http://rubygems.org/...........
Fetching gem metadata from http://192.168.10.22/..
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
code_filter (= 0.1.1) ruby depends on
activesupport (= 3.0.0) ruby
json_builder (~> 3.1) ruby depends on
activesupport (3.0.20)

Gem::LoadError when using a git repo in Gemfile

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.

Resources