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)
Related
I have a puppet module project that fails when trying to update Gems, although it works in some computers. The Gems are used for the spec tests of the module.
Here's the command I run and the output:
X:\puppet-module-rems>gem install -g Gemfile -f
ERROR: While executing gem ... (Gem::UnsatisfiableDependencyError)
Unable to resolve dependency: user requested 'win32-service (= 0.8.7)'
The gem that it's trying to install/update is already in the system:
X:\puppet-module-rems>gem list -l
*** LOCAL GEMS ***
ast (2.3.0)
bigdecimal (1.2.4)
builder (3.2.2)
bundler (1.13.0.rc.2)
childprocess (0.5.9)
ci_reporter (2.0.0)
ci_reporter_rspec (1.0.0)
deep_merge (1.0.1)
diff-lcs (1.2.5)
facter (2.4.6 x64-mingw32)
ffi (1.9.14 x64-mingw32, 1.9.6 x64-mingw32)
ffi-win32-extensions (1.0.3)
hiera (1.3.4)
hiera-eyaml (2.1.0)
highline (1.6.21)
io-console (0.4.3, 0.4.2)
json (1.8.1)
json_pure (2.0.2)
metaclass (0.0.4)
minitar (0.5.4)
minitest (4.7.5)
mocha (1.1.0)
multi_json (1.12.1)
multi_test (0.1.2)
parser (2.3.1.2)
powerpack (0.1.1)
psych (2.0.5)
ptools (1.3.3 universal-mingw32)
puppet (3.8.1 x64-mingw32)
puppet-lint (2.0.2)
puppet-syntax (2.1.0)
puppetlabs_spec_helper (1.1.1)
rainbow (2.1.0)
rake (10.1.0)
rdoc (4.1.0)
rspec (3.5.0, 3.5.0.beta2)
rspec-core (3.5.2, 3.5.0.beta2)
rspec-expectations (3.5.0, 3.5.0.beta2)
rspec-mocks (3.5.0, 3.5.0.beta2)
rspec-puppet (2.4.0, 2.3.2)
rspec-support (3.5.0, 3.5.0.beta2)
rubocop (0.42.0)
ruby-progressbar (1.8.1)
stomp (1.3.3)
sys-admin (1.6.4)
test-unit (2.5.5, 2.1.7.0, 2.1.6.0, 2.1.5.0)
thread_order (1.1.0)
trollop (2.1.2)
unicode-display_width (1.1.0)
win32-dir (0.4.9)
win32-eventlog (0.6.6, 0.6.2)
win32-file (0.8.1)
win32-file-stat (1.5.5)
win32-process (0.7.5, 0.7.4)
win32-security (0.2.5)
win32-service (0.8.7, 0.8.6)
Here's the version of ruby I have:
X:\puppet-module-rems>ruby --version
ruby 2.1.7p400 (2015-08-18 revision 51632) [x64-mingw32]
EDITED #1
Here's the content of the Gemfile:
source 'https://rubygems.org'
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['3.8.1']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '= 1.1.1'
gem 'puppet-lint', '>= 0.3.2'
gem 'facter', '>= 1.7.0'
gem 'ci_reporter_rspec'
gem 'win32-service', '= 0.8.7'
gem 'rake', '= 10.1.0'
gem 'rspec-core', '= 3.5.2'
gem 'rspec-expectations', '= 3.5.0'
gem 'rspec-mocks', '= 3.5.0'
gem 'rspec-puppet', '= 2.4.0'
gem 'rspec-support', '= 3.5.0'
So, after further research, I found that the problem was not related to my code, files or configuration but with a problem with Rubygems.
Bottomline, I had to follow this link and manually update the certificate.
It looks like ruby wasn't able to connect to the server to check for dependencies of the gems I was requiring.
My blog is based on Jekyll Bootstrap, and I've recently set up a new machine with Windows 10.
When I start my server on my local machine for testing, it says that I should add something to my Gemfile:
$ jekyll serve -w
Configuration file: C:/Users/mark/Documents/ploeh/Blog/_config.yml
Source: C:/Users/mark/Documents/ploeh/Blog
Destination: C:/Users/mark/Documents/ploeh/Blog/_site
Generating...
done.
Please add the following to your Gemfile to avoid polling for changes:
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
Auto-regeneration: enabled for 'C:/Users/mark/Documents/ploeh/Blog'
Configuration file: C:/Users/mark/Documents/ploeh/Blog/_config.yml
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
As you can see, it tells me to add a line to my Gemfile. Unfortunately, I've already tried doing that, but it seems to make no difference:
$ cat Gemfile
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
source 'https://rubygems.org'
As you can see, the line in question is already in my Gemfile.
Moving things around in the Gemfile doesn't make any difference:
source 'https://rubygems.org'
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
Why is it saying this, and should I care? If I should care, then how can I resolve the issue?
In case it matters, here's my Ruby version:
$ ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]
Other version information:
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.6)
blankslate (2.1.2.4)
celluloid (0.16.0)
classifier-reborn (2.0.3)
coffee-script (2.4.1)
coffee-script-source (1.9.1.1)
colorator (0.1)
execjs (2.6.0)
fast-stemmer (1.0.2)
ffi (1.9.10 x64-mingw32)
hitimes (1.2.2)
io-console (0.4.3)
jekyll (2.5.3)
jekyll-coffeescript (1.0.1)
jekyll-gist (1.3.4)
jekyll-paginate (1.1.0)
jekyll-sass-converter (1.3.0)
jekyll-watch (1.2.1)
json (1.8.1)
kramdown (1.8.0)
liquid (2.6.3)
listen (2.10.1)
mercenary (0.3.5)
minitest (5.4.3)
parslet (1.5.0)
posix-spawn (0.3.11)
power_assert (0.2.2)
psych (2.0.8)
pygments.rb (0.6.3)
rake (10.4.2)
rb-fsevent (0.9.6)
rb-inotify (0.9.5)
rdoc (4.2.0)
redcarpet (3.3.2)
safe_yaml (1.0.4)
sass (3.4.18)
test-unit (3.0.8)
timers (4.0.4)
toml (0.1.2)
yajl-ruby (1.2.1)
Type gem install wdm in console and see if this resolves the issue.
After recently integrating Travis-CI and Coveralls for a github repo, I can't get Travis to build properly. I get this error:
$ ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
$ rvm --version
rvm 1.26.8 (latest-minor) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
$ bundle --version
Bundler version 1.7.6
$ gem --version
2.4.5
install.bundler
5.06s$ bundle install --jobs=3 --retry=3 --deployment
Fetching gem metadata from http://rubygems.org/..........
Installing multi_json 1.10.1
Installing docile 1.1.5
Installing simplecov-html 0.8.0
Installing tins 1.3.3
Installing thor 0.19.1
Using bundler 1.7.6
Installing rake 10.4.2
Installing simplecov 0.9.1
Installing term-ansicolor 1.3.0
Installing coveralls 0.7.8
Your bundle is complete!
It was installed into ./vendor/bundle
0.80s$ bundle exec rake
/home/travis/.rvm/rubies/ruby-2.1.5/bin/ruby test/unit_test.rb
/home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls/api.rb:5:in `require': cannot load such file -- rest_client (LoadError)
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls/api.rb:5:in `<class:API>'
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls/api.rb:2:in `<module:Coveralls>'
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls/api.rb:1:in `<top (required)>'
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls.rb:3:in `require'
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls.rb:3:in `<top (required)>'
from test/unit_test.rb:3:in `require'
from test/unit_test.rb:3:in `<main>'
rake aborted!
Clearly it's not installing the rest-client, but my Gemfile.lock (and after trying to fix it, my Gemfile) both specify it:
source 'http://rubygems.org'
gem 'coveralls', require: false
gem 'rest-client'
gem 'rake'
Gemfile.lock:
GEM
remote: http://rubygems.org/
specs:
coveralls (0.7.8)
multi_json (~> 1.10)
rest-client (~> 1.7)
simplecov (~> 0.9.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
docile (1.1.5)
ffi (1.9.6-x64-mingw32)
mime-types (2.4.3)
multi_json (1.10.1)
netrc (0.10.2)
rake (10.4.2)
rest-client (1.7.2-x64-mingw32)
ffi (~> 1.9)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
simplecov (0.9.1)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
term-ansicolor (1.3.0)
tins (~> 1.0)
thor (0.19.1)
tins (1.3.3)
PLATFORMS
x64-mingw32
DEPENDENCIES
coveralls
rake
rest-client
The only noticeable difference between Travis's env and my own is my gem version is 2.2.2 and bundler version is 1.7.12
Something I don't understand is why Travis is passing the --deployment flag when it is supposed to be automating my test - shouldn't it be in test environment? In any case, when I bundle install --deployment on my own machine, rest-client 1.7.2 is still installed unlike on Travis.
What do I do to ensure rest-client gets installed?
The problem was that bundler on windows was adding platform-specific suffixes to the Gemfile.lock file, telling Travis (running on a linux system) not to bother with the gem. The solution (and this should have been the case anyway) is to git rm Gemfile.lock and add it to the .gitignore file. It is sufficient to have the Gemfile in the project.
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.
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.