Haruno19 / starfetch

command line tool that displays constellations
GNU General Public License v3.0
330 stars 15 forks source link

Constellations cannot be printed #10

Closed auroraanna closed 2 years ago

auroraanna commented 2 years ago

I installed with sudo make install However I get

➜ /usr/local/bin/starfetch        
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::replace: __pos (which is 18446744073709551615) > this->size() (which is 723)
zsh: IOT instruction (core dumped)  /usr/local/bin/starfetch

or

✗ /usr/local/bin/starfetch -n orion
Error: the constellation you asked for isn't recognized.

starfetch is a command line tool that displays information about a constellation alongside its scheme.

Usage: starfetch [OPTION] [CONSTELLATION NAME]
    -h      Prints this help message.
    -n      Shows the selected constellation.
    -r      Shows a random constellation.
    -l      Prints the list of all the available constellations.

If launched with no arguments, the behaviour is the same as with '-r'.

Examples:   starfetch -r
            starfetch -n orion
            starfetch
Haruno19 commented 2 years ago

That's weird. Could you please post the output of ls /usr/local/starfetch/res/constellations/?

auroraanna commented 2 years ago
➜ ls /usr/local/starfetch/res/constellations/
antlia.json    aries.json      cassiopeia.json      gemini.json  ophiuchus.json    scorpio.json     virgo.json
apus.json      bootes.json     corona_borealis.json  leo.json    orion.json    taurus.json
aquarius.json  cancer.json     crux.json        libra.json   pisces.json       ursa_major.json
ara.json       capricorn.json  cygnus.json      lupus.json   sagittarius.json  ursa_minor.json
Haruno19 commented 2 years ago

I'm not able to replicate this bug; I tried on both MacOS and (Arch) Linux, and it worked as expected. Therefore, if possible, I need to investigate on this issue directly on your environment.

It looks like either the path or pathc variables do not assume the expected value, resulting in starfetch not finding the .json files path. In order to verify this, could you please replace src/starfetch.cpp with this version (or just add a print statement like cout << pathc << endl; somewhere around line 60 of src/starfetch.cpp), re-install it and run again /usr/bin/starfetch -n orion please?

Thank you for your cooperation.

Haruno19 commented 2 years ago

Upon further examination, considering the output of /usr/local/bin/starfetch it looks like string::begin on string s is returning a very high value (18446744073709551615), which, I suspect, means that s is empty. The only thing that will lead to this outcome is the file f with path /usr/local/starfetch/res/template not being opened properly (which still is wired, because the basic_string::replace function is called only if f gets opened correctly).

Knowing what the path or pathc variables contain during execution will probably help solving this mystery.

auroraanna commented 2 years ago

I'm not able to replicate this bug; I tried on both MacOS and (Arch) Linux, and it worked as expected. Therefore, if possible, I need to investigate on this issue directly on your environment.

It looks like either the path or pathc variables do not assume the expected value, resulting in starfetch not finding the .json files path. In order to verify this, could you please replace src/starfetch.cpp with this version (or just add a print statement like cout << pathc << endl; somewhere around line 60 of src/starfetch.cpp), re-install it and run again /usr/bin/starfetch -n orion please?

Thank you for your cooperation.

➜ /usr/local/bin/starfetch -n orion
Error: the constellation you asked for isn't recognized.

starfetch is a command line tool that displays information about a constellation alongside its scheme.

Usage: starfetch [OPTION] [CONSTELLATION NAME]
    -h      Prints this help message.
    -n      Shows the selected constellation.
    -r      Shows a random constellation.
    -l      Prints the list of all the available constellations.

If launched with no arguments, the behaviour is the same as with '-r'.

Examples:   starfetch -r
            starfetch -n orion
            starfetch

still the same

auroraanna commented 2 years ago

I guess this has to do with NixOS?

auroraanna commented 2 years ago

There is no /usr/local/starfetch/res/template on my machine. There is also nothing about that folder in the Makefile.

Haruno19 commented 2 years ago

Uh? There's no template file under the res folder? That's definitely what's causing this problem.

The makefile does this: cp -rf ./res ${INSTALL_DIR}/starfetch/, which copies the whole res folder into /usr/local/starfetch/, and the template file is inside that.

Can you please check if starfetch/res/template is present when you extract starfetch.tar.gz? It definitely is contained in the archive.

image
Haruno19 commented 2 years ago

I don't know if it has to do with the fact that the template file has no extension, but I find it really weird? If that's the case, I can fix this easily by giving it an extension and change the code accordingly, but it shouldn't be needed.

auroraanna commented 2 years ago

Umm… so originally I did git pull to update and got this issue. I now deleted the repo folder and cloned it again - issue solved :facepalm:

I have no idea why though and I don't care either.