Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crystal deps has been removed #13

Closed
f-fr opened this issue Jun 25, 2018 · 18 comments
Closed

crystal deps has been removed #13

f-fr opened this issue Jun 25, 2018 · 18 comments

Comments

@f-fr
Copy link
Contributor

f-fr commented Jun 25, 2018

When trying to install the shard using shards install I get

Fetching https://github.com/Papierkorb/qt5.cr.git
Fetching https://github.com/Papierkorb/bindgen.git
Fetching https://github.com/Papierkorb/toka.git
Installing qt5 (0.1.0)
Installing bindgen (0.6.1)
Postinstall crystal deps
Failed crystal deps:
Please use 'shards': 'crystal deps' has been removed
@f-fr f-fr changed the title crystal deps has been remove crystal deps has been removed Jun 25, 2018
@Papierkorb
Copy link
Owner

Oh hi, this is caused by bindgens shard.yml, its postinstall hook needs to be updated to reflect that change. Can you PR that over there?

@f-fr
Copy link
Contributor Author

f-fr commented Jun 25, 2018

It seems as if shard.yml of qt5.cr also contains the lines

scripts:
 postinstall: crystal deps build

so should it be updated, too? Whats the “correct” fix, replace that line by “shards build”?
(I'm pretty new to crystal/shards so I have no idea how this should work, sorry)

@Papierkorb
Copy link
Owner

Yeah that should work. You can verify by running shards build in the bindgen/ directory.

@f-fr
Copy link
Contributor Author

f-fr commented Jun 25, 2018

It took me some time to even find the "bindgen/" directory, because shards seems to remove the directory immediately if the installation fails.

Anyway, I just cloned bindgen and ran shards build in that directory. It seems to do something but then stops with the following error message:

Fetching https://github.com/Papierkorb/toka.git
Installing toka (0.1.2)
Building: bindgen
Error target bindgen failed to compile:
Error in src/bindgen.cr:57: instantiating 'Bindgen::Tool:Class#new(String, Bindgen::Configuration, Bool)'

tool = Bindgen::Tool.new(File.dirname(config_path), config, opts.stats)
                     ^~~

in src/bindgen/tool.cr:34: instantiating 'Bindgen::Processor::Runner:Class#new(Bindgen::Configuration, Bindgen::TypeDatabase)'

      @processors = Processor::Runner.new(@config, @database)
                                      ^~~

in src/bindgen/processor/runner.cr:10: instance variable '@processors' of Bindgen::Processor::Runner must be Array(Bindgen::Processor::Base), not Array(Bindgen::Processor::AutoContainerInstantiation | Bindgen::Processor::CopyStructs | Bindgen::Processor::CppWrapper | Bindgen::Processor::CrystalBinding | Bindgen::Processor::CrystalWrapper | Bindgen::Processor::DefaultConstructor | Bindgen::Processor::DumpGraph | Bindgen::Processor::Enums | Bindgen::Processor::ExternC | Bindgen::Processor::FilterMethods | Bindgen::Processor::FunctionClass | Bindgen::Processor::Functions | Bindgen::Processor::Inheritance | Bindgen::Processor::InstantiateContainers | Bindgen::Processor::Macros | Bindgen::Processor::Qt | Bindgen::Processor::SanityCheck | Bindgen::Processor::VirtualOverride)

        @processors = config.processors.map do |name|
        ^~~~~~~~~~~

So now a little bit lost how to proceed. This is probably a different issue and I should file it in bindgens repo (right?), but should the "crystal deps" thing be fixed first?

@Papierkorb
Copy link
Owner

Papierkorb commented Jun 25, 2018

Both issues are bindgen issues in any case. That issue there is new, looks like the type inference algorithm of Crystal got stupider. The #map block starting in src/bindgen/processor/runner.cr:10 needs an .as(Processor::Base) appended to the last line of its body, so the expression that comes before its end (<- Edit). That should fix it.

I myself am not using Crystal currently, so recent changes in the language are beyond me.

@RX14
Copy link

RX14 commented Jun 25, 2018

It's not related to type inference, see crystal-lang/crystal#6024.

@f-fr
Copy link
Contributor Author

f-fr commented Jun 25, 2018

@RX14 thanks, but should the following example work:

class Base
  def self.create : Base
    A.new
  end

end

class A < Base
end

class AnyOf < Base
  @children : Array(Base)

  def initialize
    @children = [Base.create]
  end
end

AnyOf.new

The declaration of Base.create states that the return type is Base not A, so why crystal assumes that the call to Base.create returns an A?

@RX14
Copy link

RX14 commented Jun 25, 2018

Return type restrictions are not casts, they're constraints. self.create returns type A, but the return type restriction of Base doesn't error because A is a Base. You need to use A.new.as(Base).

https://carc.in/#/r/4e3d

@f-fr
Copy link
Contributor Author

f-fr commented Jun 25, 2018

I see, interesting. That makes sense but might lead to surprising errors (in particular if using external shards or so). Anyway, thanks for the explanation.

@PerrinHH
Copy link

PerrinHH commented Jul 6, 2018

I just tried installing it myself (8-year Rubyist new to Crystal) using the steps described here, and it seems to me that this project needs URGENT re-compiliing and testing with the newest Crystal compiler, particularly the Bindgen stuff! I got an avalanche of cascading Type-related errors when I compiled it using crystal 0.25.1.

Thank you!

@Papierkorb
Copy link
Owner

@PerrinHH You're welcome to do so, I'm not interested in Crystal much anymore.

@RX14
Copy link

RX14 commented Jul 7, 2018

@Papierkorb that's sad to hear, just lack of time?

@PerrinHH
Copy link

PerrinHH commented Jul 8, 2018

As for me, I tried.And I came to a point where the backtrace responded this:

in src/bindgen/crystal/format.cr:120: undefined method 'key?' for Hash(String, Int64)

Which means that this Hash does not respond to the key? method (which it should, according to documentation). Any ideas what I am supposed to do now? Thank you.

@oprypin
Copy link

oprypin commented Jul 8, 2018

No it doesn't

https://crystal-lang.org/api/0.25.1/Hash.html

It's has_key? now

@PerrinHH
Copy link

PerrinHH commented Jul 8, 2018

You're correct. The documentation I read referred do Crystal 0.24.2.

(Classical case for "Polish your glasses and read the small print.")

@PerrinHH
Copy link

PerrinHH commented Jul 9, 2018

UPDATE:

Took me a little to fix the bindgen compilation errors caused by the Crystal update to 0.25.1. But finally I got it. Bindgen compiles. Yeeeah!

Now: How can I link my private Bindgen update to qt5? Building qt5 still results in downloading the "old" bindgen sources that still produce this error:

Please use 'shards': 'crystal deps' has been removed

What can I do now? Since shards deletes all downloaded files on error, I'm really stuck. Please help. Thank you.

@mamantoha
Copy link

@PerrinHH,
should be fixed in #14.
Please check.

@docelic
Copy link
Collaborator

docelic commented May 26, 2020

Closing this issue as both bindgen's and qt5.cr's commits for the reported problem have been merged.
Bindgen now works with Crystal 0.34.0 and is at release v0.7.0.
Qt5.cr is being updated/worked on - see #29.

@docelic docelic closed this as completed May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants