circleci continuous integration rails app error require stripe - ruby-on-rails

I am trying to use Circleci for continuous integration and running into an issue. I am deploying a rails 4 app using ruby 2.2.2 and rspec.
When I try to push my first build through circleci I get an error when it tries to run my test suite on the line of code in my 'spec_helper' where I am requiring the stripe gem. I use stripe in the app and test it with 'stripe-mock'
The error is below. So the failure is my line require "stripe" in spec_helper. To be clear rspec runs and passes locally, but I get this error on circleci. I double checked and I have all my environment variables on circleci set up. I've heard that sometimes a gem needs binaries set up on circleci to work. Is this perhaps the problem? How would I do this?
rspec
/home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- stripe (LoadError)
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/ubuntu/propel/spec/spec_helper.rb:20:in `block in <top (required)>'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core.rb:97:in `configure'
from /home/ubuntu/propel/spec/spec_helper.rb:18:in `<top (required)>'
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `block in requires='
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `each'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `requires='
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `each'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `process_options_into'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:21:in `configure'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:101:in `setup'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/bin/rspec:23:in `load'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/bin/rspec:23:in `<main>' rspec returned exit code 1
I should also note that I do have stripe in my gemfile as you can see here:
gem 'stripe'
And you can see where I require stripe in my rspec spec_helper here:
RSpec.configure do |config|
require 'stripe'
require 'stripe_mock'
require 'thin'
Despite having stripe in my gemfile I decided I'd try to add sudo gem install stripe to my circle.yml file to make sure it was included for testing but got the following error:
sudo gem install stripe
ERROR: Error installing stripe:
sudo gem install stripe returned exit code 1
mime-types requires Ruby version >= 1.9.2. Action failed: sudo gem install stripe
And this is even when I specify a ruby version in my circle.yml file as 2.2.2

Instead of adding sudo gem install stripe to your circle.yml file, you should add gem stripe to your Gemfile.
The CircleCI documentation says:
In all likelihood, you'll have a list of libraries and dependencies that your app requires. CircleCI automatically detects Ruby's Gemfile, … and then runs the appropriate commands to install the dependencies.
If you don't already have a Gemfile, you can:
Run gem install bundler.
Create a Gemfile listing the Rubygems your application needs to run, including stripe. It should look something like this:
source "https://rubygems.org"
gem "stripe"
Run the bundle command. This should create a Gemfile.lock file, listing specific versions of the gems you use that are compatible with each other.
Commit bot the Gemfile and Gemfile.lock to your version control system.
The Bundler Web site has a lot more information about Gemfiles.

Related

How do I run specs for the activeadmin gem

I am trying to run the specs for a local clone of the activeadmin gems current master.
I am using ruby 2.2.2 and have bundled successfully.
When I try to run one of the specs like so:
bundle exec rspec spec/unit/filters/humanized_spec.rb
I am getting the following error:
The git source https://github.com/jruby/activerecord-jdbc-adapter is not yet checked out. Please run `bundle install` before trying to start your application
Coverage report generated for RSpec to /Users/aljoscha/gem/activeadmin/coverage. 0.0 / 0.0 LOC (100.0%) covered.
/Users/aljoscha/gem/activeadmin/spec/rails_helper.rb:13:in `require': cannot load such file -- active_record (LoadError)
from /Users/aljoscha/gem/activeadmin/spec/rails_helper.rb:13:in `<top (required)>'
from /Users/aljoscha/gem/activeadmin/spec/unit/filters/humanized_spec.rb:1:in `require'
from /Users/aljoscha/gem/activeadmin/spec/unit/filters/humanized_spec.rb:1:in `<top (required)>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/rspec:22:in `load'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/rspec:22:in `<main>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
which I cannot make sense of.
Especially since activerecord-jdbc-adapter is not even in the Gemfile.
What am I missing?
Try prepending your command with bundle exec:
bundle exec rspec spec/unit/filters/humanized_spec.rb
It looks like you have a local version discrepancy causing issues.
If not, did you follow all of the steps listed on their contributing readme?
If you are still stuck, you may be experiencing an issue with bundler itself. First, try updating bundler then reinstalling gems and attempt to run rspec. If that doesn't work you may need to delete the bundle cache folder and start over.
I'm going to re-answer to emphasize how to test a gem using appraisal as mentioned in CONTIBUTING:
bundle exec appraisal install
bundle exec appraisal rails_50 rspec spec/unit/filters/humanized_spec.rb
Thank you for your interest in Active Admin.

Windows/Ruby/Rails install --- .cannot load such file -- sqlite3/sqlite3_native windows

Ruby 2.1.3p242 <2014-09-19 revision 47630> [x64-mingw32]
Rails 4.2.0.beta2
I'm running windows 8 on a 64 bit system. I have been using c9 (cloud hosted ubuntu) but want to start using RubyMine IDE on my pc to make everything faster but it's posing some problems.
I've tried pretty much every recommended way including this one:
How do I install sqlite3 for Ruby on Windows?
but I'm still getting the same error message. You help is much appreciated! Please let me know if you have any questions for me.
Full Error message when I run $rails s:
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `block in require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `each'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `block in require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `each'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler.rb:133:in `require'
from C:/Sites/aynulhabib-habib-framework-aca42deddccd/config/application.rb:7:in `<top (required)>'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:78:in `require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `tap'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `server'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands.rb:17:in `<top (required)>'
from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `require'
from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
fortunately, you don't have to switch to ruby 2.0
there is a solution to this issue, after endless trying...
https://github.com/hwding/sqlite3-ruby-win
Steps
Pre
gem uninstall sqlite3 --all
Source
Download the latest sqlite3-ruby, https://github.com/sparklemotion/sqlite3-ruby
unzip the package
Build
run command-line in the extracted dir
make sure you have your C compiler installed and added to PATH
gem install bundler
bundle install
rake native gem
you'll find a dir named 'pkg' generated
Install
enter dir 'pkg'
gem install --local sqlite3-xxx.gem ('xxx' is version code)
Check
irb
require 'sqlite3'
The issue is that binary sqlite3 gem do not include pre-compiled versions for Ruby 2.1.3
This is mentioned in the sqlite3-ruby mailing list here.
In the folder of your project open terminal and execute:
bundle update sqlite3
bundle update nokogiri
I hope i have helped you ;)
EDIT:
i always recommend using linux/mac for ruby, because some gems may get problematic, because of compiling errors with c
always use bundle to manage your gems, it is much easier*,
you can install it by:
gem install bundler
bundle install - will install all the gems in your Gemfile
the last bundler version is not compatible withe ruby bellow 2.3, so use gem install bundler -v 1.16.4
If you have extracted "exe"s and "dll"s from Sqlite download link to Ruby's bin folder and still have this problem. Try this:
bundle update
gem uninstall sqlite3
Given a choice between multiple versions of sqlite3, choose last option 'All versions'. Enter last number here
Select gem to uninstall:
1. sqlite3-1.3.13
2. sqlite3-1.3.13-x64-mingw32
3. All versions
>3
.
.
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]
>
y
gem install sqlite3 --platform=ruby
rails s
This should work.
Read through this link for more explanation if above works for you.

Ruby/Rails rspec download errors on run

I get the following error while running
saasbook#saasbook:~/Documents/ruby-calisthenics$ rspec
error message
/home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/formatters.rb:167:in `find_formatter': Formatter 'nested' unknown - maybe you meant 'documentation' or 'progress'?. (ArgumentError)
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/formatters.rb:126:in `add'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:624:in `add_formatter'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration_options.rb:106:in `block in load_formatters_into'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration_options.rb:106:in `each'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration_options.rb:106:in `load_formatters_into'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration_options.rb:24:in `configure'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:96:in `setup'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:85:in `run'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:70:in `run'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:38:in `invoke'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/exe/rspec:4:in `<top (required)>'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/bin/rspec:23:in `load'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/bin/rspec:23:in `<main>'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `eval'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `<main>'
I am a newbie to Ruby and Rails. I have been having compatibility issues across the board, any help would be appreciated!
a bit of background of the file directory im trying to run rspec in | it's a file from an online class i am taking. it contains a lib and spec file as required. but the error im getting seems to be an issue with my rspec download.
Edit the .rspec file in the root of your Rails application directory and change the following line from:
--format nested
to:
--format documentation
The nested format no longer exists in rspec-3.0.
Uninstall all previous versions of rspec and its dependencies.
gem uninstall rspec
gem uninstall rspec-core
gem uninstall rspec-mocks
gem uninstall rspec-expectations
Install the correct version of rspec in gem file install rspec.
group :development, :test do
gem 'rspec-rails', '~> 3.0.0'
end
I got this solution from this link

Rubymine and running rspec "rspec-core is not part of the bundle"

I am trying to run a rails app which was not created using rubymine. Its is a very different sort of app using rails engines loaded...When I try running tests, I get the following error message
Testing started at 12:29 ...
/Users/userbnamexxxx/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem': rspec-core is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/userbnamexxxx/.rbenv/versions/1.9.3-p327/bin/rspec:22:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
I edited the configuration and it does have bundle exec checkbox checked. Tests tuns fine in the console. I tried it another project which is a default bug standard rails app and its fine there... I am using rbenv for managing ruby versions....
Please help as I am really stuck and it would be nice to not use the terminal....
Add the gem
rspec-core
into your .Gemfile

I get a pg error when trying to destroy a controller

I work on windows, have rails 3.2.12(just upgraded) and ruby 2.0.0p0. when i try to delete a controller i get this error:
F:\my apps\meshworks-redo> rails d controller Plans
C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/pg.rb:10:in `require': cannot load such file -- 2.0/pg_ext (LoadError)
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/pg.rb:10:in `rescue in <top (required)>'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/pg.rb:3:in `<top (required)>'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:72:in `require'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:70:in `each'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:70:in `block in require'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:59:in `each'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler/runtime.rb:59:in `require'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.2/lib/bundler.rb:132:in `require'
from F:/my apps/meshworks-redo/config/application.rb:7:in `<top (required)>'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:24:in `require'
from C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:24:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I tried re installing the pg gem, no luck.
A friend of mine got the same problem when using Ruby 2.0 on Windows 7 with Postgres. It occurs not only when trying to destroy a controller, but for every database action (including rake db:create). The problem is that the pg_ext.so file is not included for ruby 2.0. It is included for 1.9, but simply copying this to the 2.0 does not seem work. However, I found another method to obtain the correct pg_ext.so. Not exactly sure why this works, but it works for him. Here is what you need to do:
Go to the folder where 2.0/pg_ext.so (the file that could not be found) should be located. In your case C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1-x86-mingw32/lib/.
Create a folder called '2.0' (without the quotes) here.
In this folder you will need the correct pg_ext.so file. You can obtain this in the following way:
Manually install the pg gem ("gem install pg" in console). This installs the non x86-mingw32 version of the gem. It does not fix the problem, but it does create the correct pg_ext.so. I think this is because it compiles the pg gem for your system, so for ruby 2.0. You can then use this pg_ext.so file with the pg x86-mingw32 version. You will need DevKit in order to compile and install pg (http://rubyinstaller.org/add-ons/devkit/).
Go to the location of pg_ext.so in the pg-0.14.1 gem folder. In your case this would be C:/Users/rrw/.pik/rubies/Ruby-200-p0/lib/ruby/gems/2.0.0/gems/pg-0.14.1/lib.
Copy the file pg_ext.so from this folder to the newly pg-0.14.1-x86-mingw32/lib/2.0/ folder in step 2.
Now retry your commands and check if everything works. If it does not, delete your Gemfile.lock and re-run bundle install.
The same problem with this gem might occur with other mingw32 gems as well. IFor example, I had the same problem with the bcrypt-rails gem. Following the same steps as described above fixed the problem. I am now successfully running Ruby 2.0 on Windows 7.
Ps. If you have any other problems running the pg gem on Windows 7 64 bit, then try to install the 32 bit x86 version of Ruby (the RubyInstaller) and postgresql. Furthermore, make sure you include the Ruby folders in your path (this is an option while installing ruby 2.0 using the RubyInstaller) as well as the Postgresql lib and bin folders.
Good luck!

Resources