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

Readonly 2.02+ not working with Storable #27

Open
ksmadsen opened this issue Dec 22, 2016 · 5 comments
Open

Readonly 2.02+ not working with Storable #27

ksmadsen opened this issue Dec 22, 2016 · 5 comments
Labels

Comments

@ksmadsen
Copy link

When storing a Readonly variable with Storable::store, retrieving the value again using Storable::retrieve results in the error message:

Can't locate Readonly/Scalar.pm in @INC (you may need to install the Readonly::Scalar module)

The following test-script illustrates the problem:

use Storable;
use Readonly;

Readonly my $a => 1;
store(\$a, "test");
retrieve("test");

The error also appears for arrays and hashes.

Using Readonly 2.01 works, and it appears that the issue is with the stored value, as Readonly 2.02 can retrieve files stored by Readonly 2.01. Trying to retrieve a file stored by Readonly 2.02, using Readonly 2.01 gives the same error message.

I've bisected the problem, and it appears to be caused by commit 03fea5a

I'm using Perl 5.24 and Storable 2.51.

@sanko sanko added the wontfix label Dec 22, 2016
@ksmadsen
Copy link
Author

I've dug a bit deeper into it, and it appears that the following also fails with the same error message:

use Readonly;
Readonly my $a => 1;
Readonly::Clone $a;

However, if I change the declaration of the read only scalar to be Readonly::Scalar, it works.

Is this by design, and is that why you marked it wontfix?

@sanko
Copy link
Owner

sanko commented Dec 22, 2016

You're free to fork, repair, and submit a PR.

@offsides
Copy link

offsides commented Dec 3, 2021

This appears to be caused by the STORABLE_freeze functions, and the fact that the 3 sub-packages (Readonly::Scalar, Readonly::Hash and Readonly::Array) are contained within Readonly.pm and not separate packages (the error states that it can't locate Readonly/.pm). I don't know what the solution is, but I also don't know what the reason for including those functions was.

@offsides
Copy link

offsides commented Dec 3, 2021

Further investigation and testing makes me wonder what the point of the STORABLE_freeze functions is, and if they were ever tested. Because commenting them out doesn't seem to break anything, and it makes Storable work again. Is there any reason not to just remove them?

@sanko
Copy link
Owner

sanko commented Dec 4, 2021

Pull requests with tests welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants