ugexe / zef

Raku Module Management
Artistic License 2.0
207 stars 44 forks source link

Zef throws `Type check failed for return value; expected IO::Path but got Any (Any)` when it can't find the `META6.json` #483

Closed rawleyfowler closed 1 year ago

rawleyfowler commented 1 year ago

Context

I just installed Zef on a FreeBSD machine, with the newest build of Rakudo. Whenever I try to install a local module with zef install --force . I get the following type error:

Type check failed for return value; expected IO::Path but got Any (Any)

Expected Behavior

I expect it to install my local module.

Actual Behavior

It raises a type error.

Steps to Reproduce

$ zef install --force --debug .
Type check failed for return value; expected IO::Path but got Any (Any)

Your Environment

I have my raku installed at $HOME/.local/bin/rakudo Not sure if that would be causing this.

Just to rule out any suspicion on the module I'm trying to build it's just a simple module:

unit module Util;

sub read_file (Str $url) returns Seq is export {
    return $url.IO.lines;
}

Another thing I will mention is that I have never used zef before, and that I am very new to Raku. So if I'm missing something, please let me know!

rawleyfowler commented 1 year ago

Turns out, this was because I was cd'd into the wrong directory. This error is thrown if it can't find your META6.json

xylemase commented 1 year ago

I have the same problem described.

But, I cannot follow the comment "Turns out, this was because I was cd'd into the wrong directory. This error is thrown if it can't find your META6.json". What is the correct directory to be in? I tried searching my disc for instances of META6.json. Several exist, and they seem to be associated with previously installed raku modules. I tried changing to a subdirectory common to all these, but I still get the problem described when I run zef install Adverb::Eject and several other modules.

rawleyfowler commented 1 year ago

@xylemase You need to be in a directory that contains a META6.json to be able to run zef.

ugexe commented 1 year ago

The error message should be improved. For example when the install target is a path (starts with .) and also doesn't exist it shows:

$ raku -I. bin/zef install ./barz
The following were recognized as file paths but don't exist as such - ./barz

A similar error should be used when the install target exists as a path on the file system, and that path is a directory (and not an e.g. foo.tar.gz file), and that directory doesn't contain a META6.json file. As this issues shows, that is not the case currently:

$ mkdir barz
$ raku -I. bin/zef install ./barz
Type check failed for return value; expected IO::Path but got Any (Any)
xylemase commented 1 year ago

Hello, I found out where my existing META6.json files are in my .zef folder. They all seem to be attached to prior zef downloads. I created a directory there called "my_naive_dir", copied one of the existing META6.json files into it, cd'd into it myself, upgraded zef, and then attempted to run a zef install from there.

I got the same result as in my last post here:

(base) mgipson-ltmx7ad:my_naive_dir mgipson$ zef update ===> Updating fez mirror: http://360.zef.pm/ ===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json ===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json ===> Updated fez mirror: http://360.zef.pm/ ===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json ===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json

Content Storage |Distribution Count

Zef::Repository::Ecosystems |705
Zef::Repository::LocalCache |9
Zef::Repository::Ecosystems|1906
Zef::Repository::Ecosystems |2592

(base) mgipson-ltmx7ad:my_naive_dir mgipson$ zef install Adverb::Eject ===> Searching for: Adverb::Eject ===> Extraction: Failed to find a META6.json file for Adverb::Eject:ver<0.0.3>:auth -- failure is likely [Adverb::Eject] Extracting with plugin Zef::Service::Shell::tar+{<anon|1>} aborted. Type check failed for return value; expected IO::Path but got Any (Any) (base) mgipson-ltmx7ad:my_naive_dir mgipson$ ls META6.json (base) mgipson-ltmx7ad:my_naive_dir mgipson$

As far as I can tell, I complied with @rawleyfowler 's comment:

@xylemase You need to be in a directory that contains a META6.json to be able to run zef.

But even after this, zef install is not working.

ugexe commented 1 year ago

You need to run zef install . inside that directory, not zef install Adverb::Eject. Also you mention "copied one of the existing META6.json files into it" yet that isn't correct either, you need the entire project not just the META6.json file.

xylemase commented 1 year ago

I'm sorry, but I don't understand your instructions.I think there might be some misunderstanding between us about what I am trying to do. I want to install Adverb::Eject, or any of a number of other modules. I am accustomed to doing such a thing with CPAN or Conda, PIP, or even, in the somewhat distant past, with Zef. When I do this I can usually be anywhere on the disk and invoke something like Zef install Adverb::Eject. @ugexe, You say >"you need the entire project not just the META6.json file." So, what project would I copy?

I thought that the purpose of zef install ... was to install a project.

xylemase commented 1 year ago

Also,

(base) mgipson-ltmx7ad:my_naive_dir mgipson$ ls
META6.json
(base) mgipson-ltmx7ad:my_naive_dir mgipson$ zef install .
===> Searching for missing dependencies: Terminal::Print
===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Updating fez mirror: http://360.zef.pm/
===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated fez mirror: http://360.zef.pm/
===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Searching for missing dependencies: Term::termios
===> Extraction: Failed to find a META6.json file for Terminal::Print:ver<0.973>:auth<zef:terminal-printers> -- failure is likely
[Terminal::Print] Extracting with plugin Zef::Service::Shell::tar+{<anon|1>} aborted.
Type check failed for return value; expected IO::Path but got Any (Any)
(base) mgipson-ltmx7ad:my_naive_dir mgipson$ 
ugexe commented 1 year ago

(base) mgipson-ltmx7ad:my_naive_dir mgipson$ ls META6.json

Also you mention "copied one of the existing META6.json files into it" yet that isn't correct either, you need the entire project not just the META6.json file.

xylemase commented 1 year ago

Thank you for repeating your answer from before. However, that is not helping me.

I find this page, which says this is how you install CSV::Parser. zef install CSV::Parser. I think you authored this page. It doesn't say anything there about copying the project in the first place. I am under the impression that this IS the way you copy the project, but maybe you and I mean different things by the word "project". It seems that this may be where the misunderstanding is.

xylemase commented 1 year ago
(base) mgipson-ltmx7ad:my_naive_dir mgipson$ zef upgrade
===> Searching for: ECMA262Regex, JSON::Pointer, JSON::Schema, Cro::Core
===> Updating fez mirror: http://360.zef.pm/
===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated fez mirror: http://360.zef.pm/
===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
The following distributions will be upgraded: ECMA262Regex:ver<1.1.3>:auth<zef:jnthn>, Cro::Core:ver<0.8.9>:auth<zef:cro>
===> Updating: ECMA262Regex:ver<1.1.3>:auth<zef:jnthn>, Cro::Core:ver<0.8.9>:auth<zef:cro>
===> Extraction: Failed to find a META6.json file for http://360.zef.pm/E/CM/ECMA262REGEX/3a4fe0e76818a36d56d4048a93244cb41c519368.tar.gz -- failure is likely
[http://360.zef.pm/E/CM/ECMA262REGEX/3a4fe0e76818a36d56d4048a93244cb41c519368.tar.gz] Extracting with plugin Zef::Service::Shell::tar+{<anon|1>} aborted.
Type check failed for return value; expected IO::Path but got Any (Any)
===> Extraction: Failed to find a META6.json file for http://360.zef.pm/C/RO/CRO_CORE/538b8cccf6f4881e380cbc18735cf895d3940275.tar.gz -- failure is likely
[http://360.zef.pm/C/RO/CRO_CORE/538b8cccf6f4881e380cbc18735cf895d3940275.tar.gz] Extracting with plugin Zef::Service::Shell::tar+{<anon|1>} aborted.
Type check failed for return value; expected IO::Path but got Any (Any)
!!!> Failed upgrading *all* modules
(base) mgipson-ltmx7ad:my_naive_dir mgipson$ zef update
===> Updating fez mirror: http://360.zef.pm/
===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated fez mirror: http://360.zef.pm/
===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
----------------------------------------------------
Content Storage                  |Distribution Count
----------------------------------------------------
Zef::Repository::Ecosystems<cpan>|1906              
Zef::Repository::Ecosystems<fez> |2594              
Zef::Repository::LocalCache      |9                 
Zef::Repository::Ecosystems<p6c> |705               
----------------------------------------------------
(base) mgipson-ltmx7ad:my_naive_dir mgipson$ zef install .
Type check failed for return value; expected IO::Path but got Any (Any)
(base) mgipson-ltmx7ad:my_naive_dir mgipson$ 
ugexe commented 1 year ago

It would help if you opened a new issue and follow the instructions in issue template. Specifically it would have you run with --verbose or --debug to give more info, as well as list the output of zef list --installed which would show which outdated version of zef you are running (which is evident by the fact it is updating e.g. https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json and not https://raw.githubusercontent.com/Raku/REA/main/META.json). I would suggest running zef nuke home site StoreDir (warning: this will uninstall all existing modules), and then reinstalling the latest version of zef via the instructions in the zef `README.md

xylemase commented 1 year ago

Thank you ! I will do what you suggest!

xylemase commented 1 year ago

I followed your suggestion, and zef is working for me now. Thank you!