stevieb9 / berrybrew

Perlbrew for Windows!
Other
63 stars 9 forks source link

'berrybrew use' does not affect output of 'berrybrew modules export' #312

Closed atcroft closed 1 year ago

atcroft commented 2 years ago

modules

Usage: berrybrew modules <command> [option]

Allows you the ability to export the currently installed module list from one instance of Perl for import and installation on a different instance of Perl.

modules commands

export Exports a list of all installed modules in the current Perl

import Imports a previously exported module list and installs them in the current perl

import command has an optional argument, which is the name of the instance of Perl that you've previously exported from. If no argument is sent in, we'll list the available exports you can choose to install from.

Commands:

  1. berrybrew use --win 5.10.1_32
  2. perl -v
  3. perl -le "foreach (@INC) { print; }"
  4. berrybrew list
  5. berrybrew available
  6. berrybrew modules export
  7. berrybrew version

Actual behavior:

  1. <berrybrew use perl-5.10.1_32>

    c:\Programming\berrybrew>

  2. <berrybrew use perl-5.10.1_32>

    c:\Programming\berrybrew>perl -v

    This is perl, v5.10.1 (*) built for MSWin32-x86-multi-thread

    Copyright 1987-2009, Larry Wall

    Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

    Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.

  3. <berrybrew use perl-5.10.1_32>

    c:\Programming\berrybrew>perl -le "foreach (@INC) { print; }" C:/Programming/berrybrew/instances/5.10.1_32/perl/lib C:/Programming/berrybrew/instances/5.10.1_32/perl/site/lib .

  4. <berrybrew use perl-5.10.1_32>

    c:\Programming\berrybrew>berrybrew list

    5.32.1_64       *
    5.32.1_64_PDL
    (list removed for clarity -AC)
    5.10.1_32
  5. <berrybrew use perl-5.10.1_32>

    c:\Programming\berrybrew>berrybrew available

    The following Strawberry Perls are available:

    5.32.1_64       [installed]  *
    5.32.1_64_PDL   [installed]
    (list removed for clarity -AC)
    5.10.1_32       [installed]
    5.8.9_32

    * Currently using

  6. <berrybrew use perl-5.10.1_32>

    c:\Programming\berrybrew>berrybrew modules export

    successfully wrote out C:\Programming\berrybrew\instances\modules\5.32.1_64 module list file
  7. <berrybrew use perl-5.10.1_32>

    c:\Programming\berrybrew>berrybrew version 1.34

Expected behavior:

Expect 'use $version' to result in modules list for $version. (In the example above, the expected module list to be output would be for 5.10.1_32 instead of 5.32.1_64 listed.)

atcroft commented 2 years ago

Realized there was a newer version. Installed berrybrew v.1.36, and see the same behavior as listed above when run with v.1.34.

stevieb9 commented 1 year ago

On the roadmap. Thank you for such detailed feedback. Actually, it's remarkable feedback.

stevieb9 commented 1 year ago

I have figured out why this is happening. Essentially, when temporarily useing a perl, berrybrew doesn't know that it's the perl in use. It recognizes the previously switched version as the one to use for exporting modules. The check happens in PerlInUse(), so I will look at whether this can be sanely changed, or whether it'll be best to throw a warning that export can't happen in a temporary perl.

Another issue related though, is that the module export routine can't be run on 5.10.1. I can't remember why right now, but it's clear that it was an explicit decision because something wasn't working:

            StrawberryPerl perl = PerlInUse();

            if (string.IsNullOrEmpty(perl.Name)) {
                Console.Error.WriteLine("\nno Perl is in use. Run 'berrybrew switch' to enable one before exporting a module list\n");
                Exit((int)ErrorCodes.PERL_NONE_IN_USE);
            }

            if (perl.Name == "5.10.1_32") {
                Console.Error.WriteLine("\nmodules command requires a Perl version greater than 5.10\n");
                Exit((int)ErrorCodes.PERL_MIN_VER_GREATER_510);
            }
stevieb9 commented 1 year ago

Fixed in 1.38.

We no longer allow using berrybrew modules export in a temporary, useed instance.