Skip to content

BUG - (Windows) Errors due to hardcoded colon as path separator #264

Open

Description

@AljenU

Part of #242

On Windows, the path separator is a semicolon, whereas on unix it is a colon.

In many places in aa, a colon is hardcoded to be used in interactions with paths. This gives both direct and indirect errors when running aa.

Unfortunately, the colon also has other uses in matlab code, thus there are more than 10k places where it appears in the code.

** To fix **
Use the matlab provided pathsep instead of a hardcoded colon

At least, the 100 places with ':' should be looked at. However, that will not cover all problems, as the : will also be part of longer strings (in regular expressions for instance).

For more complete coverage, create a script that can go over all places in m files where the : is used, and does regular expression matching to reduce the number of suspect lines that should be manually looked at.

Activity

  1. changed the title [-]BUG - Errors due to hardcoded colon as path separator[/-] [+]BUG - (Windows) Errors due to hardcoded colon as path separator[/+] on Nov 5, 2021
  2. AljenU commented on Nov 8, 2021

    @AljenU
    CollaboratorAuthor

    In aa_init, there is the following code

    % Path for matlabtools
    if isfield(aap.directory_conventions,'matlabtoolsdir') && ~isempty(aap.directory_conventions.matlabtoolsdir)
        addpath(strrep(aap.directory_conventions.matlabtoolsdir,':',pathsep))
    end
    

    It seems to me, that the strrep does not do anything on *nix systems, so why is it not just addpath(aap.directory_conventions.matlabtoolsdir) within the if?

    For Windows compatibility, will need to change this code, however I do not yet understand it.

    @tiborauer Ideas?

  3. tiborauer commented on Nov 8, 2021

    @tiborauer
    Member

    The reason for this implementation is to allow specifying multiple directories separated with ":" (which is the conventional list separator in aa XML).
    You are right, in *nix systems, strrep is not needed. And for Windows, we may have to come up with a more clever solution (e.g ignoring ":" before "\").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions