Hyperledger Composer Rest Servers on Separate Physical Machines - hyperledger

I have managed to install a hyperledger composer network on two separate physical machines where each machine has one user in separate organizations. I am able to start the rest server on the same peer as where I started the composer network, but am unable to start a rest server on the other peer.
When I issue
composer-rest-server -c bob-org2#network -n never -w true
I get
Connection fails: Error: Error trying to ping. Error: 2 UNKNOWN: error executing chaincode: could not get ChaincodeDeploymentSpec for network:0.0.1: get ChaincodeDeploymentSpec for network/mychannel from LSCC error: chaincode fingerprint mismatch data mismatch
It will be retried for the next request.
Exception: Error: Error trying to ping. Error: 2 UNKNOWN: error executing chaincode: could not get ChaincodeDeploymentSpec for network:0.0.1: get ChaincodeDeploymentSpec for network/mychannel from LSCC error: chaincode fingerprint mismatch data mismatch
Error: Error trying to ping. Error: 2 UNKNOWN: error executing chaincode: could not get ChaincodeDeploymentSpec for network:0.0.1: get ChaincodeDeploymentSpec for bl-security-network/mychannel from LSCC error: chaincode fingerprint mismatch data mismatch
at _checkRuntimeVersions.then.catch (/home/ubuntu/.nvm/versions/node/v8.11.1/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:787:34)
at
I see this should be possible based on this answer:
How should composer setup to be done for hyperledger fabric network deployment for multiple orgs on multiple physical machine
I see errors in the docker container peer0.org1.example.com-peer0.org1.example.com-network-0.0.1
bl-security-network#0.0.1 start /usr/local/src
start-network "--peer.address" "10.0.0.224:7052"
running start.js E0510 07:49:44.580450529 17
ssl_transport_security.cc:238] Could not get common name of subject
from certificate. 2018-05-10T07:49:44.630Z [8d62931a] ERROR
:NodeDataCollection :get() Error: Object
with ID 'Asset:org.hyperledger.composer.system.AssetRegistry' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.644Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.654Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Asset:org.hyperledger.composer.system.TransactionRegistry' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.663Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.672Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Asset:org.hyperledger.composer.system.HistorianRecord' in collection
with ID '$sysregistries' does not exist 2018-05-10T07:49:44.681Z
[8d62931a] ERROR :NodeDataCollection :get()
Error: Object with ID
'Transaction:org.hyperledger.composer.system.AddAsset' in collection
with ID '$sysregistries' does not exist 2018-05-10T07:49:44.694Z
[8d62931a] ERROR :NodeDataCollection :get()
Error: Object with ID
'Transaction:org.hyperledger.composer.system.UpdateAsset' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.704Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.RemoveAsset' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.714Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.AddParticipant' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.723Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.UpdateParticipant' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.732Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.RemoveParticipant' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.747Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Asset:org.hyperledger.composer.system.Identity' in collection with ID
'$sysregistries' does not exist 2018-05-10T07:49:44.756Z [8d62931a]
ERROR :NodeDataCollection :get() Error:
Object with ID
'Transaction:org.hyperledger.composer.system.IssueIdentity' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.765Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.BindIdentity' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.775Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.ActivateCurrentIdentity'
in collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.784Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.RevokeIdentity' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.794Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.StartBusinessNetwork' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.805Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.ResetBusinessNetwork' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.813Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.SetLogLevel' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:49:44.822Z [8d62931a] ERROR :NodeDataCollection
:get() Error: Object with ID
'Participant:blil.security.FilePartic' in collection with ID
'$sysregistries' does not exist 2018-05-10T07:49:44.835Z [8d62931a]
ERROR :NodeDataCollection :get() Error:
Object with ID 'Transaction:blil.security.addToLogFile' in collection
with ID '$sysregistries' does not exist 2018-05-10T07:49:44.852Z
[8d62931a] ERROR :NodeDataCollection :get()
Error: Object with ID 'org.hyperledger.composer.system.NetworkAdmin'
in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist 2018-05-10T07:49:44.852Z [8d62931a] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist Error: Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:49:44.854Z
[8d62931a] INFO :IdentityManager :()
Binding in the tx names and impl 2018-05-10T07:49:44.863Z [8d62931a]
INFO :EngineTransactions :createHistorianRecord() created
historian record 2018-05-10T07:49:44.869Z [8d62931a] ERROR
:NodeDataCollection :get() Error: Object
with ID 'org.hyperledger.composer.system.NetworkAdmin' in collection
with ID 'Asset:org.hyperledger.composer.system.ParticipantRegistry'
does not exist 2018-05-10T07:49:44.869Z [8d62931a] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist Error: Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:49:44.876Z
[8d62931a] INFO :EngineTransactions :createHistorianRecord()
created historian record 2018-05-10T07:49:44.888Z [8d62931a] ERROR
:NodeDataCollection :get() Error: Object
with ID 'alice-org1' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist 2018-05-10T07:49:44.889Z [8d62931a] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID 'alice-org1' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist Error: Object with ID 'alice-org1' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:49:44.908Z
[8d62931a] INFO :EngineTransactions :createHistorianRecord()
created historian record 2018-05-10T07:49:44.914Z [8d62931a] ERROR
:NodeDataCollection :get() Error: Object
with ID 'bob-org2' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist 2018-05-10T07:49:44.914Z [8d62931a] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID 'bob-org2' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist Error: Object with ID 'bob-org2' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:49:44.925Z
[8d62931a] INFO :EngineTransactions :createHistorianRecord()
created historian record 2018-05-10T07:49:44.932Z [8d62931a] ERROR
:NodeDataCollection :get() Error: Object
with ID 'org.hyperledger.composer.system.NetworkAdmin' in collection
with ID 'Asset:org.hyperledger.composer.system.ParticipantRegistry'
does not exist 2018-05-10T07:49:44.932Z [8d62931a] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist Error: Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:49:44.935Z
[8d62931a] ERROR :NodeDataCollection :get()
Error: Object with ID 'org.hyperledger.composer.system.NetworkAdmin'
in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist 2018-05-10T07:49:44.935Z [8d62931a] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist Error: Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:49:44.939Z
[8d62931a] INFO :EngineTransactions :createHistorianRecord()
created historian record 2018-05-10T07:51:29.627Z [3ac15224] ERROR
:NodeDataCollection :get() Error: Object
with ID 'Asset:org.hyperledger.composer.system.AssetRegistry' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.641Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.649Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Asset:org.hyperledger.composer.system.TransactionRegistry' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.657Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.666Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Asset:org.hyperledger.composer.system.HistorianRecord' in collection
with ID '$sysregistries' does not exist 2018-05-10T07:51:29.675Z
[3ac15224] ERROR :NodeDataCollection :get()
Error: Object with ID
'Transaction:org.hyperledger.composer.system.AddAsset' in collection
with ID '$sysregistries' does not exist 2018-05-10T07:51:29.685Z
[3ac15224] ERROR :NodeDataCollection :get()
Error: Object with ID
'Transaction:org.hyperledger.composer.system.UpdateAsset' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.696Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.RemoveAsset' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.709Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.AddParticipant' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.718Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.UpdateParticipant' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.726Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.RemoveParticipant' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.734Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Asset:org.hyperledger.composer.system.Identity' in collection with ID
'$sysregistries' does not exist 2018-05-10T07:51:29.741Z [3ac15224]
ERROR :NodeDataCollection :get() Error:
Object with ID
'Transaction:org.hyperledger.composer.system.IssueIdentity' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.750Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.BindIdentity' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.759Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.ActivateCurrentIdentity'
in collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.766Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.RevokeIdentity' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.773Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.StartBusinessNetwork' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.780Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.ResetBusinessNetwork' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.787Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Transaction:org.hyperledger.composer.system.SetLogLevel' in
collection with ID '$sysregistries' does not exist
2018-05-10T07:51:29.794Z [3ac15224] ERROR :NodeDataCollection
:get() Error: Object with ID
'Participant:blil.security.FilePartic' in collection with ID
'$sysregistries' does not exist 2018-05-10T07:51:29.804Z [3ac15224]
ERROR :NodeDataCollection :get() Error:
Object with ID 'Transaction:blil.security.addToLogFile' in collection
with ID '$sysregistries' does not exist 2018-05-10T07:51:29.815Z
[3ac15224] ERROR :NodeDataCollection :get()
Error: Object with ID 'org.hyperledger.composer.system.NetworkAdmin'
in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist 2018-05-10T07:51:29.815Z [3ac15224] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist Error: Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:51:29.816Z
[3ac15224] INFO :IdentityManager :()
Binding in the tx names and impl 2018-05-10T07:51:29.822Z [3ac15224]
INFO :EngineTransactions :createHistorianRecord() created
historian record 2018-05-10T07:51:29.828Z [3ac15224] ERROR
:NodeDataCollection :get() Error: Object
with ID 'org.hyperledger.composer.system.NetworkAdmin' in collection
with ID 'Asset:org.hyperledger.composer.system.ParticipantRegistry'
does not exist 2018-05-10T07:51:29.828Z [3ac15224] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist Error: Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:51:29.834Z
[3ac15224] INFO :EngineTransactions :createHistorianRecord()
created historian record 2018-05-10T07:51:29.840Z [3ac15224] ERROR
:NodeDataCollection :get() Error: Object
with ID 'alice-org1' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist 2018-05-10T07:51:29.840Z [3ac15224] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID 'alice-org1' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist Error: Object with ID 'alice-org1' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:51:29.849Z
[3ac15224] INFO :EngineTransactions :createHistorianRecord()
created historian record 2018-05-10T07:51:29.854Z [3ac15224] ERROR
:NodeDataCollection :get() Error: Object
with ID 'bob-org2' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist 2018-05-10T07:51:29.854Z [3ac15224] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID 'bob-org2' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist Error: Object with ID 'bob-org2' in collection with ID
'Participant:org.hyperledger.composer.system.NetworkAdmin' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:51:29.863Z
[3ac15224] INFO :EngineTransactions :createHistorianRecord()
created historian record 2018-05-10T07:51:29.871Z [3ac15224] ERROR
:NodeDataCollection :get() Error: Object
with ID 'org.hyperledger.composer.system.NetworkAdmin' in collection
with ID 'Asset:org.hyperledger.composer.system.ParticipantRegistry'
does not exist 2018-05-10T07:51:29.871Z [3ac15224] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist Error: Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:51:29.874Z
[3ac15224] ERROR :NodeDataCollection :get()
Error: Object with ID 'org.hyperledger.composer.system.NetworkAdmin'
in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist 2018-05-10T07:51:29.874Z [3ac15224] ERROR :Resolver
:resolveRelationship() Failed to resolve relationship
{"stack":["{Error}Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist Error: Object with ID
'org.hyperledger.composer.system.NetworkAdmin' in collection with ID
'Asset:org.hyperledger.composer.system.ParticipantRegistry' does not
exist"," at NodeDataCollection.get
(/usr/local/src/node_modules/composer-runtime-hlfv1/lib/nodedatacollection.js:73:28)","
at "," at process._tickCallback
(internal/process/next_tick.js:188:7)"]} 2018-05-10T07:51:29.878Z
[3ac15224] INFO :EngineTransactions :createHistorianRecord()
created historian record

Now I managed to get past the previous issue by rectifying my composer versions to both be 0.19.5 as opposed to being different 0.19.x .

Related

RSpec factories with FactoryBot 'uninitialized constant FactoryBot'

I am setting up request specs following this tutorial.
If I run the tests with bundle exec rspec I get the following error:
An error occurred while loading ./spec/factories/entities_spec.rb.
Failure/Error:
FactoryBot.define do
factory :entity do
name { FFaker::Lorem.word }
end
end
NameError:
uninitialized constant FactoryBot
The tutorial only asks to add some configuration to the rails_helper.rb file. I can't figure where I need to add a require 'factory_bot'. If I add it to the top of the rails_helper.rb file, the error persists. And if I add it to the factories/entity_spec.rb file, I get this error:
An error occurred while loading ./spec/requests/entities_spec.rb.
Failure/Error:
factory :entity do
name { FFaker::Lorem.word }
end
FactoryBot::DuplicateDefinitionError:
Factory already registered: entity
Simply renaming my factories/*.rb files from e.g. factories/user_spec.rb to factories/user.rb solved the problem.

Rspec TypeError: superclass mismatch for class Cipher

I get an error when i'm trying to launch rspec :
An error occurred while loading ./spec/factories_spec.rb.
Failure/Error:
FactoryGirl.factories.map(&:name).each do |factory_name|
describe "The #{factory_name} factory" do
it 'is valid' do
build(factory_name).should be_valid
end
end
end
NameError:
uninitialized constant FactoryGirl
# ./spec/factories_spec.rb:1:in `<top (required)>'
/usr/lib/x86_64-linux-gnu/ruby/2.4.0/openssl.so: warning: already initialized constant OpenSSL::VERSION
/usr/lib/x86_64-linux-gnu/ruby/2.4.0/openssl.so: warning: already initialized constant OpenSSL::OPENSSL_VERSION
/usr/lib/x86_64-linux-gnu/ruby/2.4.0/openssl.so: warning: already initialized constant OpenSSL::OPENSSL_LIBRARY_VERSION
and
An error occurred while loading ./spec/helpers/date_helper_spec.rb.
Failure/Error: require File.expand_path('../../config/environment', __FILE__)
TypeError:
superclass mismatch for class Cipher
# /var/lib/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support.rb:24:in `require'
Please comment if you need more informations
About the former error. You probably are using some modern version of FactoryGirl, and now it calls FactoryBot and uses FactoryBot constant. So use FactoryBot instead of FactoryGirl
About the latter one. Maybe you have your Cipher class defined multiple times in multiple places and that's why you're getting this error. Or maybe you're trying to call it different than OpenSSL::Cipher. Any details about Cipher class could clarify the situation

Cannot seed data in the production database using heroku

I am using heroku to deploy my rails app. I am trying to seed some data in the production by running the command heroku run rake db:seed. However, the command is not working. I am not able to seed files in production. The seeds.rb file is given below.
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# end
5.times do
Scoreboard.create!(name_of_scoreboard: "scoreboard_abc",
name_of_organization: "abcdef",
name_of_activity: "ghijklmn",
user_id: 1,
states: "state",
country: "state",
cities: "state")
end
I get the following message in the terminal when I run the command.
$ heroku run rake db:seed
Running rake db:seed on ⬢ app... up, run.4751
ActiveRecord::SchemaMigration Load (2.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
I run `heroku restart` but the objects isn't seeded in the production database. I have tried seeding this file in development and it works perfectly. I am not sure what's wrong.
running heroku run rake db:setup gives me the following error
DETAIL: User does not have CONNECT privilege.
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
I also get the following errors.
psql:/app/db/structure.sql:955: ERROR: multiple primary keys for table "mailboxer_conversation_opt_outs" are not allowed
psql:/app/db/structure.sql:963: ERROR: multiple primary keys for table "mailboxer_conversations" are not allowed
psql:/app/db/structure.sql:971: ERROR: multiple primary keys for table "mailboxer_notifications" are not allowed
psql:/app/db/structure.sql:979: ERROR: multiple primary keys for table "mailboxer_receipts" are not allowed
psql:/app/db/structure.sql:987: ERROR: multiple primary keys for table "managers" are not allowed
psql:/app/db/structure.sql:995: ERROR: multiple primary keys for table "pg_search_documents" are not allowed
psql:/app/db/structure.sql:1003: ERROR: multiple primary keys for table "pictures" are not allowed
psql:/app/db/structure.sql:1011: ERROR: multiple primary keys for table "requests" are not allowed
psql:/app/db/structure.sql:1027: ERROR: multiple primary keys for table "scoreboards" are not allowed
psql:/app/db/structure.sql:1035: ERROR: multiple primary keys for table "statuses" are not allowed
psql:/app/db/structure.sql:1043: ERROR: multiple primary keys for table "team_matches" are not allowed
psql:/app/db/structure.sql:1051: ERROR: multiple primary keys for table "team_members" are not allowed
psql:/app/db/structure.sql:1059: ERROR: multiple primary keys for table "teams" are not allowed
psql:/app/db/structure.sql:1067: ERROR: multiple primary keys for table "topics" are not allowed
psql:/app/db/structure.sql:1075: ERROR: multiple primary keys for table "users" are not allowed
psql:/app/db/structure.sql:1082: ERROR: relation "index_categories_on_scoreboard_id" already exists
psql:/app/db/structure.sql:1089: ERROR: relation "index_documents_on_category_id" already exists
psql:/app/db/structure.sql:1096: ERROR: relation "index_events_on_scoreboard_id" already exists
psql:/app/db/structure.sql:1103: ERROR: relation "index_favourites_on_scoreboard_id" already exists
psql:/app/db/structure.sql:1110: ERROR: relation "index_favourites_on_user_id" already exists
psql:/app/db/structure.sql:1117: ERROR: relation "index_favourites_on_user_id_and_scoreboard_id" already exists
psql:/app/db/structure.sql:1124: ERROR: relation "index_invitations_on_scoreboard_
I think I am running the migration files that already exist. As a result, I am getting a uniqueness error.
I think you have migrations pending. You can try:
Heroku run rake db:migrate db:seed
Try these steps,
heroku run rake db:schema:load
heroku run rake db:migrate
heroku run rake db:seed

Devise throws and error during migration

I am trying to use Devise in my rails app but when I get to the point to migrate my database Devise gives me this error:
rake db:migrate
== 20141016065244 AddDeviseToPatients: migrating ==============================
-- change_table(:patients)
-> 0.0127s
-- add_index(:patients, :email, {:unique=>true})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::ConstraintException: UNIQUE constraint failed: patients.email: CREATE UNIQUE INDEX "index_patients_on_email" ON "patients" ("email")
I am trying to use devise in an already started project where the "User" table is called "Patient".
This is that table:
"Patient(id: integer, name: string, loginName: string, login: integer, created_at: datetime, updated_at: datetime)"
So what simple error am I making? :)
Here's the migration file: https://gist.github.com/macmattias/1c81717dbf218d18dc72
The field email is missing?
You need to add a field email to your table patients.

chef template variable #node seems to throw error

I'm going through peepcode's Chef tutorial, so far so good. For some reason there is a failure when using template variables. The example is for nginx.
In the nginx/attributes/nginx.rb I have:
default[:nginx][:worker_processes] = 4
In the nginx.conf.erb template I refer to:
worker_processes <%= #node[:nginx][:worker_processes] %>;
Below is the error I get running chef-solo:
Template Context:
-----------------
on line #2
1: user www-data;
2: worker_processes <%= #node[:nginx][:worker_processes] %>;
3:
4: error_log /var/log/nginx/error.log;
5: pid /var/run/nginx.pid;
[2013-07-14T19:46:36+02:00] ERROR: Running exception handlers
[2013-07-14T19:46:36+02:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2013-07-14T19:46:36+02:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-07-14T19:46:36+02:00] FATAL: Chef::Mixin::Template::TemplateError: undefined method `[]' for nil:NilClass
Other part of the error output:
Starting Chef Client, version 11.4.4
Compiling Cookbooks...
Converging 3 resources
Recipe: nginx::default
* package[nginx] action install (up to date)
* service[nginx] action enable (up to date)
* service[nginx] action start (up to date)
* template[/etc/nginx/nginx.conf] action create
================================================================================
Error executing action `create` on resource 'template[/etc/nginx/nginx.conf]'
================================================================================
Chef::Mixin::Template::TemplateError
------------------------------------
undefined method `[]' for nil:NilClass
Resource Declaration:
---------------------
# In /cookbooks/nginx/recipes/default.rb
8: template "/etc/nginx/nginx.conf" do
9: notifies :reload, "service[nginx]"
10: end
Compiled Resource:
------------------
# Declared in /cookbooks/nginx/recipes/default.rb:8:in `from_file'
template("/etc/nginx/nginx.conf") do
provider Chef::Provider::Template
action "create"
retries 0
retry_delay 2
path "/etc/nginx/nginx.conf"
backup 5
source "nginx.conf.erb"
cookbook_name :nginx
recipe_name "default"
end
You can access object variables (the ones that start with #) in templates, only if you passed them through variables method of template like that:
template("/etc/nginx/nginx.conf") do
[...]
variables( :my_var => node )
[...]
end
Then you will have #my_var available in template. But you don't have to pass the node, because it is already available in templates. You just have to access it not as an object variable. The following code in template should work.
<%= node[:nginx][:worker_processes] %>
Just remove the # from the front of node.
The node object is not accessible via an instance variable (the thing starting with an # sign). Instead, it is a method in the current context.
Change:
<%= #node[:nginx][:worker_processes] %>
to
<%= node[:nginx][:worker_processes] %>
Notice the removal of the #-sign? You only need the #-sign when passing in variables to the template via the variables parameter.

Resources