The Crystal Programming Language Forum

Error: Instantiation, when executing method inside class that has no "initialize" method

Error: Instantiation, when executing method inside class that has no “initialize” method

Can you share the code? Otherwise we can only guess.

yes of couse!

require “option_parser”
require “./network”

module Block
module Cli

class Options
  @seed_ip : String
  property seed_ip = Network::TESTNET_SEED_HOST
  property host_ip : String? = nil
  property port : Int32? = nil
  property? mine = false
  property? web = false
  property? local = false

def!(args : Array(String))
  options =

  OptionParser.parse args do |parser|
    parser.banner = "Usage: Block [arguments]"

    parser.on("-s IP", "--seed-ip=IP", "First node to connect, TestNet by default") { |i| options.seed_ip = i }
    parser.on("-i IP", "--host-ip=IP", "Node's public ip, If the node is public") { |i| options.host_ip = i }
    parser.on("-p PORT", "--port=PORT", "Node's public port, If the node is public") { |i| options.port = i.to_i }
    parser.on("-l", "--local-net", "Prevents node from connecting to public nodes") { |i| options.local = true }
    parser.on("-w", "--web", "Start web server without making the node public") { |i| options.web = true }
    parser.on("-m", "--mine", "Enable mining") { options.mine = true }

    parser.on("-h", "--help", "Show this help") do
      puts parser

    parser.on("-v", "--version", "Show node version") do
      puts "Block-crystal v#{VERSION}"
      exit 0

  run! options

def!(options : Options)
  blockchain =

  seed_ip = options.local? ? nil : options.seed_ip
  network = seed_ip

  # Read from file system
  Storage::File.load_and_sync blockchain

  # Sync with network
  Storage::Network.load_and_sync blockchain, network

  blockchain.verbose = true

  # Start web server if enabled
  if options.web? || options.port || options.host_ip
    spawn Web.start! network, blockchain, options.port, options.host_ip

  # Start miner if mining
  spawn Miner.start! blockchain if options.mine?



getting this error

In src/

3 |! ARGV
Error: instantiating ‘Block::Cli:Module#run!(Array(String))’

code for executing the first code.

require “./Block”! ARGV

Can you provide a reduced example that produces the error? Ideally on

something similar to this: Carcin

but when executing the code is showing:

Error: instantiating ‘Block::Cli:Module#run!’

I’m sorry, but I can’t help if I’m not able to reproduce the error. Error: instantiating ‘Block::Cli:Module#run!’ isn’t really enough to go off of.

okay, thanks a lot for your time