Menu

#157 Honour env perl dynamically on linux

Next Release
open
nobody
5
2016-05-12
2015-04-22
salmonix
No

On linux, EPIC does not seem to honour env perl, falls back to system perl.
This is a problem when development uses perlbrew and switches between different perl versions.
The workaround is to write a bash wrapper that returns the active perl version parsing the perlbrew init file, but this is somewhat ugly.

Related

Feature Requests: #157

Discussion

  • Jan Ploski

    Jan Ploski - 2015-04-22

    EPIC invokes whichever Perl executable you specified via Preferences.

     
  • salmonix

    salmonix - 2015-04-22

    Yes, but does not honour /usr/bin/env perl, nor any PERL5LIB variables that are exported in .bashrc ( or similar way ).
    I use perl-5.20.2 via perlbrew switch, standard way. If I define 'env perl' as interpreter in Preferences regardless that I have switched using perlbrew to other perl versions or not, I statically receive the system perl ( 5.16.2 ), although env perl is properly set to 5.20.2 otherwise. ( eg. in the terminal )
    The only workaround I have been able to find is to make a bash script that invokes the active perl version parsing the perlbrew init file, and set that wrapper to be the perl interpreter.

     
    • Jan Ploski

      Jan Ploski - 2015-04-22

      Whether environment variables are inherited by Eclipse or not depends on how you start Eclipse. If you start it from a shell, it does inherit the environment from the shell. This is true for any Unix process. Generally, whichever environment manipulation you perform (e.g. changing PATH or PERL5LIB) in the terminal (shell) only applies to that single shell and subprocesses spawned from it.

      But given that the environment inheritance happens when the process is created (i.e. when Eclipse is started) and that you want to manipulate it thereafter, I believe that a wrapper around the perl interpreter is not a bad solution.

      Alternatively (or additionally) you can set environment variables explicitly in each launch configuration on the Environment tab - e.g. create a separate launch configuration for each version of Perl.

       
      • salmonix

        salmonix - 2015-04-23

        Yes. For some reason I expected that the variables set in .bashrc will be
        inherited, also the env perl that is set for the user by perlbrew, as it
        happens with other applications ( eg. scilab with certain lib variables,
        etc. ). Anyway, I post my current solution for perlbrew, might be useful:

        !/bin/bash

        ACTIVE_PERL=grep -o 'PERLBREW_PATH=.*' $HOME/.perlbrew/init | sed -e 's/"\|:/\n/g' | awk '/perls\/perl/ { print $0."/perl" }'
        $ACTIVE_PERL "$@"

        Save it, make it executable and set it as the perl interpreter. If the user
        switches perl version with perlbrew, this wrapper will follow that. If any
        variable is to be set, can be set here, too.

        On Wed, Apr 22, 2015 at 2:14 PM, Jan Ploski jploski@users.sf.net wrote:

        Whether environment variables are inherited by Eclipse or not depends on
        how you start Eclipse. If you start it from a shell, it does inherit the
        environment from the shell. This is true for any Unix process. Generally,
        whichever environment manipulation you perform (e.g. changing PATH or
        PERL5LIB) in the terminal (shell) only applies to that single shell and
        subprocesses spawned from it.

        But given that the environment inheritance happens when the process is
        created (i.e. when Eclipse is started) and that you want to manipulate it
        thereafter, I believe that a wrapper around the perl interpreter is not a
        bad solution.

        Alternatively (or additionally) you can set environment variables
        explicitly in each launch configuration on the Environment tab - e.g.
        create a separate launch configuration for each version of Perl.


        Status: open
        Group: Next Release (example)
        Labels: various interpreter
        Created: Wed Apr 22, 2015 07:39 AM UTC by salmonix
        Last Updated: Wed Apr 22, 2015 11:54 AM UTC
        Owner: nobody

        On linux, EPIC does not seem to honour env perl, falls back to system perl.
        This is a problem when development uses perlbrew and switches between
        different perl versions.
        The workaround is to write a bash wrapper that returns the active perl
        version parsing the perlbrew init file, but this is somewhat ugly.


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/e-p-i-c/feature-requests/157/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

         

        Related

        Feature Requests: #157

  • Oliver Trosien

    Oliver Trosien - 2016-05-11

    A proper solution could be to implement management of multiple local perl installations, just like for java, where you can register different JREs. If you want to test your code for multiple versions of perl this would come in handy.

     

Log in to post a comment.