Git Product home page Git Product logo

Comments (13)

bcardiff avatar bcardiff commented on July 4, 2024

You are probably using crystal-mysql 0.3.0, check with the latest 0.3.1.

from crystal-mysql.

crisward avatar crisward commented on July 4, 2024

Sorry, hadn't run crystal deps update since my last git pull, perils of working on 2 machines. It was semi-deliberate to avoid pulling the broken kemal-session-file, but that's been fixed now.
Many thanks... and good luck on the journey to crystal 1.0 in 2017.

from crystal-mysql.

crisward avatar crisward commented on July 4, 2024

Spoke too soon. Sent to my ci and got the same error. Seems the local fix I made wasn't overwritten by a crystal deps update. For clarification here is my ci output.
Also crystal is on Crystal 0.20.3 (2016-12-23)

gitlab-ci-multi-runner 1.2.0 (3a4fcd4)
Using Shell executor...
Running on cris2.local...
Fetching changes...
Removing .shards/
Removing lib/
HEAD is now at c8e798b updated deps
Checking out c8e798bf as master...
$ crystal deps update
Updating https://github.com/kemalcr/kemal.git
Updating https://github.com/luislavena/radix.git
Updating https://github.com/jeromegn/kilt.git
Updating https://github.com/RX14/multipart.cr.git
Updating https://github.com/jeromegn/slang.git
Updating https://github.com/crystal-lang/crystal-mysql.git
Updating https://github.com/crystal-lang/crystal-db.git
Updating https://github.com/kemalcr/kemal-session-file.git
Updating https://github.com/kemalcr/kemal-session.git
Installing kemal (0.17.4)
Installing radix (0.3.5)
Installing kilt (0.3.3)
Installing multipart (0.1.1)
Installing slang (1.4.1)
Installing mysql (0.3.1)
Installing db (0.3.3)
Installing kemal-session-file (0.3.0)
Installing kemal-session (master)
$ crystal spec -v
Error in spec/spec_helper.cr:10: instantiating 'DB:Module#open(String)'

    @@db : DB::Database = DB.open(DBURL)
                             ^~~~

in lib/db/src/db.cr:103: instantiating 'build_database(String)'

    build_database(uri)
    ^~~~~~~~~~~~~~

in lib/db/src/db.cr:117: instantiating 'build_database(URI)'

    build_database(URI.parse(connection_string))
    ^~~~~~~~~~~~~~

in lib/db/src/db.cr:121: instantiating 'DB::Database:Class#new(DB::Driver+, URI)'

    Database.new(driver_class(uri.scheme).new, uri)
             ^~~

in lib/db/src/db/database.cr:50: instantiating 'DB::Driver+#build_connection(DB::Database)'

        conn = @driver.build_connection(self).as(Connection)
                       ^~~~~~~~~~~~~~~~

in lib/mysql/src/mysql/driver.cr:3: instantiating 'MySql::Connection:Class#new(DB::Database)'

    MySql::Connection.new(db)
                      ^~~

in lib/mysql/src/mysql/connection.cr:22: instantiating 'read_packet(MySql::Protocol::HandshakeV10:Class)'

      handshake = read_packet(Protocol::HandshakeV10)
                  ^~~~~~~~~~~

in lib/mysql/src/mysql/connection.cr:57: instantiating 'read_packet()'

    read_packet do |packet|
    ^~~~~~~~~~~

in lib/mysql/src/mysql/connection.cr:47: instantiating 'build_read_packet()'

    packet = build_read_packet
             ^~~~~~~~~~~~~~~~~

in lib/mysql/src/mysql/connection.cr:65: instantiating 'MySql::ReadPacket:Class#new(TCPSocket+, MySql::Connection)'

    ReadPacket.new(@socket, self)
               ^~~

instance variable '@remaining' of MySql::ReadPacket must be Int32, not Nil

Error: instance variable '@remaining' is initialized inside a begin-rescue, so it can potentially be left uninitialized if an exception is raised and rescued

ERROR: Build failed: exit status 1

from crystal-mysql.

tbrand avatar tbrand commented on July 4, 2024

I got this as well.

from crystal-mysql.

crisward avatar crisward commented on July 4, 2024

As a temp fix, feel free to use my branch crisward/crystal-mysql for now.

from crystal-mysql.

tbrand avatar tbrand commented on July 4, 2024

Thanks @criward! Will use it 👍

from crystal-mysql.

bcardiff avatar bcardiff commented on July 4, 2024

I would like to be able to reproduce/isolate the issue a little bit more.

ReadPacket declaration in 0.3.1 begins as:

class MySql::ReadPacket
  include IO

  @length : Int32 = 0
  @remaining : Int32 = 0
  @seq : UInt8 = 0u8

  def initialize(@io : IO, @connection : Connection)
    begin
      ...
    rescue IO::EOFError
      raise DB::ConnectionLost.new(@connection)
    end
  end

So the ivars should not be nilable.

Can you both @tbrand @crisward check that there is no cache ~/.crystal / ~/.cache bothering or wrong ./lib/crystal-mysql/src/mysql/read_packet.cr in your path.

@tbrand what is your environment?

from crystal-mysql.

crisward avatar crisward commented on July 4, 2024

I deleted my project/.shards folder and removed everything in ~/.cache/crystal/, then did a fresh crystal deps.

It now seems to compile again.

Bit odd it's doing it on my ci server too. I'll have a quick look into it and see if I can find the offending cache.

from crystal-mysql.

crisward avatar crisward commented on July 4, 2024

No matter what I delete, I can't get it to compile on the ci server. I've deleted every cache I can find, and it's still throws the same error above. It works fine with my fork, just not the main release.

from crystal-mysql.

crisward avatar crisward commented on July 4, 2024

Just swapped my local copy back to mysql (0.3.1) from my fork, got the same error.
Still using Crystal 0.20.3 (2016-12-23) as one of my upstream dependencies hasn't been updated to 0.20.4.

Update: tried with 0.20.4, same error

from crystal-mysql.

rdp avatar rdp commented on July 4, 2024

Make sure your crystal version is the same everywhere FWIW...0.20.5 help?

OK I did run into this. The following compiles great:

require "mysql"

def go
  db = DB.open "something"
end

However this fails with what appears to be the OP's same message:

require "mysql"

class MyDb
  @@db = DB.open "anything"
end

from crystal-mysql.

bcardiff avatar bcardiff commented on July 4, 2024

This is great! it is a bug in the compiler :-). Seriously thanks for sharing some snippets so we can found what was different between yours experiments and mine.

from crystal-mysql.

bcardiff avatar bcardiff commented on July 4, 2024

Since the fix in the compiler my taken a little bit longer, I've just merged #23 to unblock the class var initializers scenario.

from crystal-mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.