rake install fails but gem install works fine - ruby

bundle exec rake install fails, but gem install works. How to solve the problem?
I found a similar problem and he solved the problem by adding puts out in install gem method. I did same, but the error message just indicate somewhere nil.to_s is called.
rake install fails but gem install works fine, any idea why?
Error Message
be rake install --trace
** Invoke install (first_time)
** Invoke build (first_time)
** Execute build
gnf 0.1.2 built to pkg/gnf-0.1.2.gem.
** Execute install
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
rake aborted!
Couldn't install gem, run `gem install /Users/ironsand/dev/gnf/pkg/gnf-0.1.2.gem' for more detailed output
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.3/lib/bundler/gem_helper.rb:88:in `install_gem'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.3/lib/bundler/gem_helper.rb:44:in `block in install'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/Users/ironsand/.rbenv/versions/2.2.2/bin/rake:23:in `load'
/Users/ironsand/.rbenv/versions/2.2.2/bin/rake:23:in `<main>'
Tasks: TOP => install
gem install
There is no error with the command:
gem install /Users/ironsand/dev/gnf/pkg/gnf-0.1.2.gem
gnf.gemspec
coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'gnf/version'
Gem::Specification.new do |spec|
spec.name = 'gnf'
spec.version = GNF::VERSION
spec.authors = ['ironsand']
spec.email = ['ironsand#example.com']
spec.licenses = ['MIT']
spec.summary = %q{GFN}
spec.description = %q{GFN}
spec.homepage = 'http://github.com/ironsand/foobar'
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host.
if spec.respond_to?(:metadata)
spec.metadata['allowed_push_host'] = 'http://mygemserver.com'
else
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
end
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
spec.add_development_dependency 'bundler', '~> 1.10'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec'
spec.add_dependency 'selenium-webdriver'
end
Environments
% rake --version
rake, version 11.1.2
% bundle --version
Bundler version 1.10.3
% ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin13]
Is there any idea what causes this error?

I'm not sure what causes this error, but by updating the version of my gem the error don't occur anymore.

Related

After running bundle install I got this message "cannot load such file -- appium_lib"

I was running my codes without any issues while I was only automating my wep app.
Now I wanted to start automating my mobile app and after running bundle install I'm getting this error. I don't know where else I can find the solution for this error.
I guess is some gem that is not correct installed but already removed all gems and it didn't work.
cannot load such file -- appium_lib (LoadError)
/Users/brunobacelar/Curatio/Automation/ui_tests/iOS/features/support/env.rb:3:in `require'
/Users/brunobacelar/Curatio/Automation/ui_tests/iOS/features/support/env.rb:3:in `<top (required)>'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/glue/registry_and_more.rb:121:in `require'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/glue/registry_and_more.rb:121:in `load_code_file'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/runtime/support_code.rb:81:in `block in load_files!'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/runtime/support_code.rb:80:in `each'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/runtime/support_code.rb:80:in `load_files!'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/runtime.rb:260:in `load_step_definitions'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/runtime.rb:72:in `run!'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/lib/cucumber/cli/main.rb:29:in `execute!'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/gems/cucumber-7.0.0/bin/cucumber:9:in `<top (required)>'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/bin/cucumber:23:in `load'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/bin/cucumber:23:in `<main>'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `eval'
/Users/brunobacelar/.rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `<main>'
env.rb
# frozen_string_literal: true
require 'appium_lib'
require 'rubygems'
require 'pry'
# creating an array from the data in the YML file
APPCONSTANT=YAML.load_file('/Users/brunobacelar/Curatio/Automation/ui_tests/iOS/config/appConstants.yml')
def caps { caps: {
platformVersion: "14.5",
deviceName: "iPhone SE2",
platformName: 'iOS',
automationName: 'XCUITest',
bundleId: "me.curatio.st-i",
udid: "XXXXXXXX-XXXXXXXXXXXX",
newCommandTimeOut: '3600',
xcodeOrgId: 'XXXXXXXXXXX',
xcodeSigningId: 'iPhone Developer',
noReset: true } } end
# $driver = Appium::Driver.new(caps, true) Appium::Driver.new(caps, true) Appium.promote_appium_methods Object
there you go. You've answered your own question. It cannot load appium_lib which you have specified on line3 of your env.rb.
Usually you would ensure this is inside your Gemfile or suchlike. Double check that your Gemfile.lock has the relevant gems, your ruby version is correct for where you're running and that you also are requiring the right path

Active Record unexpected i18n error

I am building a Ruby project that uses active record but not rails. Inside one of my tests I am trying the following:
it "fails with no driver name" do
command = "Driver"
expect {command_file.process_driver command}.to raise_error(ActiveRecord::RecordInvalid)
end
And here is the method I am trying to call
def process_driver command
driver_name = command.split[1]
Driver.create! :name => driver_name
end
I expect to be passing :name => nil to Driver.create! which should throw a RecordInvalid but instead I get I18n::InvalidLocaleData. Here is the backtrace
expected ActiveRecord::RecordInvalid, got #<I18n::InvalidLocaleData: can not load translations from /Users/me/.rbenv/versions/2.3.1/lib/r...ems/activesupport-5.1.3/lib/active_support/locale/en.yml: expects it to return a hash, but does not> with backtrace:
# ./command_file.rb:81:in `process_driver'
# ./command_file.rb:63:in `block in process'
# ./command_file.rb:51:in `each'
# ./command_file.rb:51:in `each_with_index'
# ./command_file.rb:51:in `process'
# ./spec/command_file_spec.rb:60:in `block (5 levels) in <top (required)>'
# ./spec/command_file_spec.rb:60:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:75:in `block (3 levels) in <top (required)>'
# ./spec/spec_helper.rb:74:in `block (2 levels) in <top (required)>'
And here is my Gemfile
source 'https://rubygems.org'
gem 'sqlite3', '~> 1.3', '>= 1.3.13'
gem 'activerecord', '~> 5.1', '>= 5.1.3'
gem 'pry', '~> 0.10.4'
gem 'rspec', '~> 3.6'
gem 'factory_girl', '~> 4.5'
group :test do
gem 'database_cleaner'
end
I have no locale files of my own.
Any idea what's going on? I am not attempting any kind of translation in this project. I also don't understand why a locale file provided by active_support should fail. I'd be happy to simply disable i18n somehow if that were possible but I don't know how. Any ideas what the problem is?
For what ever reason :en was not set as my default locale. I fixed that in my spec_helper.rb by adding I18n.default_locale = 'en':
I18n.default_locale = 'en' # <--- add this line
RSpec.configure do |config|
# config here...
end
I realize this doesn't fix the larger problem of why the locale file from active_support was not loading, but my challenge was simply to make the error go away, not to use i18n

Nomethod error when trying to make rr mock stubs work

I am setting up a project and have been trying to make rr mocks work but I am getting nomethod error. I have tried moving the required method as well but nothing works. This is my repo
$ rspec spec/views
F
Failures:
1) home/show.html.haml
Failure/Error: stub(view).user { user }
NoMethodError:
undefined method `stub' for #<RSpec::ExampleGroups::HomeShowHtmlHaml:0x007fc245188f08>
# ./spec/views/home/show.html.haml_spec.rb:6:in `block (2 levels) in <top (required)>'
# /Users/saadbinakhlaq/.rvm/gems/ruby-2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
# /Users/saadbinakhlaq/.rvm/gems/ruby-2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
# /Users/saadbinakhlaq/.rvm/gems/ruby-2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
# /Users/saadbinakhlaq/.rvm/gems/ruby-2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
# /Users/saadbinakhlaq/.rvm/gems/ruby-2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
# /Users/saadbinakhlaq/.rvm/gems/ruby-2.3.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
# /Users/saadbinakhlaq/.rvm/gems/ruby-2.3.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
# /Users/saadbinakhlaq/.rvm/gems/ruby-2.3.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
I have tried whatever was mentioned here rr
# Gemfile
group :test do
gem 'rr', require: false
end
# test helper
require File.expand_path('../../config/environment', __FILE__)
require 'your/test/framework' # if you are using something other than MiniTest / Test::Unit
require 'rr'
I got this working finally, I used gem 'rr', '1.1.2' instead of 1.2.0 which got auto installed when running bundler without the gem version.

Is activeuuid and rails 4.1.1 compatible or there is something wrong here?

Here is a little code snippet that I am trying to use to implement gem activeuuid:
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'activeuuid'
User.rb
class User < ActiveRecord::Base
include ActiveUUID::UUID
end
Migration xxxxxxxxx_create_users.rb
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users, :id => false do |t|
t.uuid :id, :primary_key => true
t.string :email
t.timestamps
end
end
def self.down
drop_table :users
end
end
Tyring a simple query is not proving to be fisible here even after bundle or restart of console ..
2.1.1 :016 > User.all
NoMethodError: undefined method `set_primary_key' for User (call 'User.connection' to establish a connection):Class
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activeuuid-ps-0.1.2/lib/activeuuid/uuid.rb:54:in `block in <module:UUID>'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `class_eval'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `append_features'
from /home/sahil/projects/test_projects/myapp/app/models/user.rb:3:in `include'
from /home/sahil/projects/test_projects/myapp/app/models/user.rb:3:in `<class:User>'
from /home/sahil/projects/test_projects/myapp/app/models/user.rb:1:in `<top (required)>'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:443:in `load'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:443:in `block in load_file'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:633:in `new_constants_in'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:442:in `load_file'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:342:in `require_or_load'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:480:in `load_missing_constant'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:180:in `const_missing'
from (irb):16
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands/console.rb:90:in `start'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
or even
2.1.1 :029 > User.count
NoMethodError: undefined method `set_primary_key' for User (call 'User.connection' to establish a connection):Class
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activeuuid-ps-0.1.2/lib/activeuuid/uuid.rb:54:in `block in <module:UUID>'
..........
..........
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Whats happening wrong here. Am i missing some required dependency.
Found out a better solution and implemented as show at : http://www.codesapling.com/blog/2014/05/24/using-uuid-as-primary-key-in-rails4-with-postgres/

Is it bug in bundler and rspec?

I'v installed Rails 3.1 new application with some gems:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
gem 'sqlite3', '1.3.4'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'unicorn', '4.1.1'
gem execjs, 1.2.9
gem therubyracer, '0.9.9'
gem 'gravatar_image_tag', '1.0.0'
group :test do
# Pretty printed test output
gem 'turn', '0.8.3', :require => true
gem 'rspec-rails', '2.7.0'
gem 'syntax', '1.0.0'
gem 'factory_girl_rails', '1.3.0'
end
group :development do
gem 'webrat', '0.7.3'
gem 'rspec-rails', '2.7.0'
gem 'syntax', '1.0.0'
end
group :production do
end
$ bundle exec rails new calculator -T
$ cd calculator
$ bundle exec rails g rspec:install
Create file
require 'spec_helper'
describe PagesController do
render_views
before(:each) do
#base_title = "Calculator Tutorial Application | "
end
describe "GET 'home'" do
it "returns http success" do
get 'home'
response.should be_success
end
it "should have the right title" do
get 'home'
response.should have_selector("title",
:content => #base_title + "Home")
end
end
end
and run test
$ ./bin/rspec spec/controllers/pages_controller_spec.rb
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require': can't convert true into String (TypeError)
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /home/ror/calculator/config/application.rb:13:in `'
from /home/ror/calculator/config/environment.rb:2:in `require'
from /home/ror/calculator/config/environment.rb:2:in `'
from /home/ror/calculator/spec/spec_helper.rb:3:in `require'
from /home/ror/calculator/spec/spec_helper.rb:3:in `'
from /home/ror/calculator/spec/controllers/pages_controller_spec.rb:1:in `require'
from /home/ror/calculator/spec/controllers/pages_controller_spec.rb:1:in `'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from /home/ror/.gem/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'
After comment line 13 in ./config/application.rb : # Bundler.require(*Rails.groups(:assets => %w(development test))) Rspec test system works fine, but I have another problem with gravatar_image_tag which works only comment out line Bundle.requre.
All gems are installed over bundler in user home directory.
Answer from user486421 himself:
Disabling 'turn' gem in Gemfile solved the problem:
gem 'turn', '0.8.3', :require => false

Resources