naqvis / cryplot

Crystal plotting library powered by gnuplot
MIT License
22 stars 3 forks source link

Palettes Enum is empty #1

Open stellarpower opened 2 years ago

stellarpower commented 2 years ago

Doing a shards install, I presume the downloading of palettes not completed successfully - upon build of the sample programs, I get:

Dependencies are satisfied
Building: sample1
Error target sample1 failed to compile:
Showing last frame. Use --error-trace for full trace.

In lib/cryplot/src/plot/palettes.cr:9:3

 9 | enum Palette
     ^
Error: enum Palette must have at least one member

Looking at the generated file:

  # Gnuplot color palettes adapted from https://github.com/Gnuplotting/gnuplot-palettes
  enum Palette
    def to_s(io : IO) : Nil
      io << self.to_s.downcase
    end

    def data
      Cryplot.palettes[self]
    end
  end

  class_getter palettes : Hash(Palette, String) { get_palettes }

  private def self.get_palettes
    pals = Hash(Palette, String).new

    pals
  end

Presume something with the download of the palettes repo hasn't worked or has changed since initial version(?).

I'm on Crystal 1.5.0-dev [792027789] (2022-05-25)

Cheers!

stellarpower commented 2 years ago

Update: looks like the script needs git here: system("git submodule update --init") - gen_palettes.cr:5

As I downloaded using shards install, the folder is a checkout, not a repo itself. Quick workaround would be to check if this command fails, and spit out an error, but longer-term probably a different method of downloading would be better.

naqvis commented 2 years ago

Thanks @stellarpower . Seems some functionality has been changed in latest version of lang. I've changed post install to invoke shell script to perform the work. Have tested it on Mac and assumes same should work on *nix based systems as well.

nuxeh commented 9 months ago

Hi I'm seeing this with Crystal 1.2.0 (2022-01-01) on linux (nixos) with a shards install.

Any idea how to fix?

naqvis commented 9 months ago

Any idea how to fix?

try to run install.sh and see if it succeeds. if no, then restrict your shard.yml to use version 0.1.0 of this shard

hutou commented 2 months ago

Hi, I tried both suggestions : none of them works, I still get the message Error: enum Palette must have at least one member. It seems that shards install does not download any palette :

$ ls -l lib/cryplot/deps/gnuplot-palettes/
total 0

(Crystal version 1.13.0) What can I do, apart from a manual download?

naqvis commented 2 months ago

install.sh try to retrieve the submodule first. Look like that step is failing. Try to manually run in shard folder and see if git get that submodule downloaded properly?

git submodule update --init

One this step is done. Shell performs below operation

if [ ! -d "deps/gnuplot-palettes" ]
then
    echo "missing directory 'deps/gnuplot-palettes'. Seems  git submodule didn't work"
    exit 2
fi

crystal run scripts/gen_palettes.cr

Try above steps manually see what error you see?

hutou commented 2 months ago

Sorry, but I don't really understand your suggestions, not being a knowledgeable Git user. The git submodule update --init statement doesn't seem to have any effect: it's supposed to update what? Retrieve the submodule? What exactly is the shard folder you're referring to in your last post? The deps/gnuplot-palettes/ directory is indeed created after the shards install, but it's empty. I've "solved" the problem by performing a manual download, but it's not very satisfactory!

I'm not a Gnuplot user either, and I must confess that I'm struggling to use your library. A "beginner" tutorial would be very welcome, even if I've found some help in CrystalDocs (discovered a bit by chance, as it's not mentioned in the README).

Thanks for your help

naqvis commented 2 months ago

Thanks @hutou for your comments

Sorry, but I don't really understand your suggestions, not being a knowledgeable Git user. The git submodule update --init statement doesn't seem to have any effect: it's supposed to update what? Retrieve the submodule? What exactly is the shard folder you're referring to in your last post? The deps/gnuplot-palettes/ directory is indeed created after the shards install, but it's empty. I've "solved" the problem by performing a manual download, but it's not very satisfactory!

This shard make use of another repo containing the gnuplot palletes and that dependency is linked via git submodule feature. All that shard install script tries to do is download that dependency and run script (written in crystal) to generate crystal bindings.

I'm not a Gnuplot user either, and I must confess that I'm struggling to use your library. A "beginner" tutorial would be very welcome, even if I've found some help in CrystalDocs (discovered a bit by chance, as it's not mentioned in the README).

I had written the shard instructions, details, and examples with assumption that users of this module have enough knowledge of the domain (gnuplot) and they understand what they are trying to use. that is user has previous knowledge and understanding of the gnuPlot and they would like to utilize that within Crystal Ecosystem.

For Tutorial and other documentation on gnuplot please refer to gnuplot homepage

hutou commented 2 months ago

Hi, My Gnuplot skills have greatly increased since this past weekend, and I've been able to use your library as expected. Thanks for sharing.

As for updating gnuplot-palettes, still complete failure (under ArchLinux+Gnome system, up to date). The git submodule update --init command has no effect whatsoever. So there seems to be a hidden problem somewhere! A search for "git submodule not working" on the Net shows that problems with submodules are not uncommon! Please, can you check that everything is ok on your side? Thanks

naqvis commented 2 months ago

I just tried running install.sh on my Mac and couldn't reproduce that problem

image