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

Bad warning about .pm files #5482

Open
DarthGandalf opened this issue Dec 2, 2023 · 10 comments
Open

Bad warning about .pm files #5482

DarthGandalf opened this issue Dec 2, 2023 · 10 comments
Labels
configuration Issues that can be resolved by reconfiguration

Comments

@DarthGandalf
Copy link

The Problem

Because the selection of packages at Raku Land is so limited, I wanted to reuse some Perl5 code from CPAN via Inline::Perl5. To avoid polluting system directories, I installed it via cpanm -L . Foo::Bar.

Expected Behavior

No warning

Actual Behavior

Saw 1 occurrence of deprecated code.
================================================================================
.pm file extension in raku library path seen at:
  file#/var/tmp/foo, line 0
Please use the .rakumod extension for raku modules, or include a META6.json file that explicitly declares each raku module file instead.
--------------------------------------------------------------------------------
Please contact the author to have these occurrences of deprecated code
adapted, so that this message will disappear!

Steps to Reproduce

  1. echo "use lib '.';" > a.raku;
  2. touch B.rakumod
  3. echo "use B;" >> a.raku
  4. mkdir -p c/d/e
  5. touch c/d/e/unrelated.pm
  6. raku a.raku

Note that mere existence of a .pm file shows this warning, even if it's in a deep subdir like ./perl5lib

Environment

  • Operating system: Gentoo Linux
  • Compiler version (rakudo -v or raku -v): v2023.10.
@ugexe
Copy link
Member

ugexe commented Dec 2, 2023

The directory you provide to lib isn’t for Perl modules, and everything under it is counted as part of the same raku distribution. If you insist on this file structure, then provide a META6.json in the lib path as the error suggests

@ugexe
Copy link
Member

ugexe commented Dec 2, 2023

Note that in the future when rakudo no longer treats .pm files as Raku modules this deprecation message will go away, and things will work the way you want.

@DarthGandalf
Copy link
Author

The directory you provide to lib isn’t for Perl modules

I know. The goal was to use it with use lib:from<Perl5> '.'; but the warning happens regardless of that line

@niner
Copy link
Collaborator

niner commented Dec 2, 2023

I would put those modules into a sub directory called p5lib and then just use lib:from<Perl5> 'p5lib';

Actually I would do neither and instead declare those modules as dependencies in your META6.json: "depends": [{"name": "Foo::Bar", "from": "Perl5"}]. That will make it clear what your code needs and allow for the user to install those modules in their preferred way. E.g. at my former work place we generated RPM packages for Raku modules and those Perl dependencies were automatically translated to RPM dependencies and the Perl packages installed that way. Note that you can always use the PERLLIB environment variable to point Perl at some manually installed packages.

@DarthGandalf
Copy link
Author

I would put those modules into a sub directory called p5lib

That still triggers the warning

Re translation to RPM, interesting idea. Too heavy for my use case though. Even META6.json is a bit heavy... But if it's the common practice in Raku for modules which are not going to be distributed, except that merely pushing the code to github for posterity, to have META6.json file, that should work then.

@2colours
Copy link
Contributor

2colours commented Dec 3, 2023

This is kind of a recurring topic, I would say, that use lib is not really meant for anything serious:

  1. it eagerly builds the given folder into a compilation unit repository, meaning that the larger the folder, the slower it is for you to start up your script that does use lib
  2. if you were to do use lib in a module to cross-share code between your own modules, that module cannot be precompiled any longer

For your use case, the former seems more concerning. I remember discussions about the latter more, and with that, the conclusion really seemed to be that it's largely unsalvageable.

@ab5tract ab5tract added the configuration Issues that can be resolved by reconfiguration label Dec 3, 2023
@ugexe
Copy link
Member

ugexe commented Dec 6, 2023

That still triggers the warning

That suggests you are still adding a Raku library path that contains .pm files somewhere under it. Considering that you don't want to have a META6.json file I would expect your code to be structures like so:

.
├── lib
│   └── MyModule.rakumod
└── p5lib
    └── PerlModule.pm

and used like so: raku -e 'use lib "lib"; use lib:from<Perl5> "p5lib"; ...'

@DarthGandalf
Copy link
Author

Yeah, I didn't have a separate subdir for lib/. But having p5lib in ../ silences it.

@2colours
Copy link
Contributor

2colours commented Jan 8, 2024

@DarthGandalf what do you think about this issue now? I'm not sure if it's still an issue - at least not the issue that was opened?

@DarthGandalf
Copy link
Author

That's up to you. If you wish to close it, or to change the way how it warns, I don't mind either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Issues that can be resolved by reconfiguration
Projects
None yet
Development

No branches or pull requests

5 participants